소스 검색

ref: js-utils for random and room name generator (#3975)

j8
virtuacoplenny 6 년 전
부모
커밋
a667c9bff2
No account linked to committer's email address

+ 22
- 7
package-lock.json 파일 보기

@@ -3398,6 +3398,11 @@
3398 3398
         "multicast-dns-service-types": "^1.1.0"
3399 3399
       }
3400 3400
     },
3401
+    "bowser": {
3402
+      "version": "1.9.1",
3403
+      "resolved": "https://registry.npmjs.org/bowser/-/bowser-1.9.1.tgz",
3404
+      "integrity": "sha512-UXti1JB6oK8hO983AImunnV6j/fqAEeDlPXh99zhsP5g32oLbxJJ6qcOaUesR+tqqhnUVQHlRJyD0dfiV0Hxaw=="
3405
+    },
3401 3406
     "bplist-creator": {
3402 3407
       "version": "0.0.7",
3403 3408
       "resolved": "https://registry.npmjs.org/bplist-creator/-/bplist-creator-0.0.7.tgz",
@@ -8243,18 +8248,13 @@
8243 8248
       "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls="
8244 8249
     },
8245 8250
     "js-utils": {
8246
-      "version": "github:jitsi/js-utils#446497893023aa8dec403e0e4e35a22cae6bc87d",
8247
-      "from": "github:jitsi/js-utils#446497893023aa8dec403e0e4e35a22cae6bc87d",
8251
+      "version": "github:jitsi/js-utils#73a67a7a60d52f8e895f50939c8fcbd1f20fe7b5",
8252
+      "from": "github:jitsi/js-utils#73a67a7a60d52f8e895f50939c8fcbd1f20fe7b5",
8248 8253
       "requires": {
8249 8254
         "bowser": "1.9.1",
8250 8255
         "js-md5": "0.7.3"
8251 8256
       },
8252 8257
       "dependencies": {
8253
-        "bowser": {
8254
-          "version": "1.9.1",
8255
-          "resolved": "https://registry.npmjs.org/bowser/-/bowser-1.9.1.tgz",
8256
-          "integrity": "sha512-UXti1JB6oK8hO983AImunnV6j/fqAEeDlPXh99zhsP5g32oLbxJJ6qcOaUesR+tqqhnUVQHlRJyD0dfiV0Hxaw=="
8257
-        },
8258 8258
         "js-md5": {
8259 8259
           "version": "0.7.3",
8260 8260
           "resolved": "https://registry.npmjs.org/js-md5/-/js-md5-0.7.3.tgz",
@@ -8481,6 +8481,21 @@
8481 8481
         "strophejs-plugin-disco": "0.0.2",
8482 8482
         "webrtc-adapter": "github:webrtc/adapter#1eec19782b4058d186341263e7d049cea3e3290a",
8483 8483
         "yaeti": "1.0.1"
8484
+      },
8485
+      "dependencies": {
8486
+        "js-md5": {
8487
+          "version": "0.7.3",
8488
+          "resolved": "https://registry.npmjs.org/js-md5/-/js-md5-0.7.3.tgz",
8489
+          "integrity": "sha512-ZC41vPSTLKGwIRjqDh8DfXoCrdQIyBgspJVPXHBGu4nZlAEvG3nf+jO9avM9RmLiGakg7vz974ms99nEV0tmTQ=="
8490
+        },
8491
+        "js-utils": {
8492
+          "version": "github:jitsi/js-utils#446497893023aa8dec403e0e4e35a22cae6bc87d",
8493
+          "from": "github:jitsi/js-utils#446497893023aa8dec403e0e4e35a22cae6bc87d",
8494
+          "requires": {
8495
+            "bowser": "1.9.1",
8496
+            "js-md5": "0.7.3"
8497
+          }
8498
+        }
8484 8499
       }
8485 8500
     },
8486 8501
     "libflacjs": {

+ 1
- 1
package.json 파일 보기

@@ -48,7 +48,7 @@
48 48
     "jquery-contextmenu": "2.4.5",
49 49
     "jquery-i18next": "1.2.0",
50 50
     "js-md5": "0.6.1",
51
-    "js-utils": "github:jitsi/js-utils#446497893023aa8dec403e0e4e35a22cae6bc87d",
51
+    "js-utils": "github:jitsi/js-utils#73a67a7a60d52f8e895f50939c8fcbd1f20fe7b5",
52 52
     "jsc-android": "224109.1.0",
53 53
     "jsrsasign": "8.0.12",
54 54
     "jwt-decode": "2.2.0",

+ 1
- 3
react/features/app/getRouteToRender.js 파일 보기

@@ -1,5 +1,6 @@
1 1
 // @flow
2 2
 
3
+import { generateRoomWithoutSeparator } from 'js-utils/random';
3 4
 import type { Component } from 'react';
4 5
 
5 6
 import { isRoomValid } from '../base/conference';
@@ -12,13 +13,10 @@ import { UnsupportedDesktopBrowser } from '../unsupported-browser';
12 13
 import {
13 14
     BlankPage,
14 15
     WelcomePage,
15
-    generateRoomWithoutSeparator,
16 16
     isWelcomePageAppEnabled,
17 17
     isWelcomePageUserEnabled
18 18
 } from '../welcome';
19 19
 
20
-declare var interfaceConfig: Object;
21
-
22 20
 /**
23 21
  * Object describing application route.
24 22
  *

+ 2
- 1
react/features/base/participants/reducer.js 파일 보기

@@ -1,7 +1,8 @@
1 1
 // @flow
2 2
 
3
+import { randomHexString } from 'js-utils/random';
4
+
3 5
 import { ReducerRegistry, set } from '../redux';
4
-import { randomHexString } from '../util';
5 6
 
6 7
 import {
7 8
     DOMINANT_SPEAKER_CHANGED,

+ 3
- 1
react/features/base/settings/reducer.js 파일 보기

@@ -1,11 +1,13 @@
1 1
 // @flow
2
+
3
+import { randomHexString } from 'js-utils/random';
2 4
 import _ from 'lodash';
3 5
 
4 6
 import { APP_WILL_MOUNT } from '../app';
5 7
 import JitsiMeetJS, { browser } from '../lib-jitsi-meet';
6 8
 import { ReducerRegistry } from '../redux';
7 9
 import { PersistenceRegistry } from '../storage';
8
-import { assignIfDefined, randomHexString } from '../util';
10
+import { assignIfDefined } from '../util';
9 11
 
10 12
 import { SETTINGS_UPDATED } from './actionTypes';
11 13
 

+ 0
- 1
react/features/base/util/index.js 파일 보기

@@ -1,5 +1,4 @@
1 1
 export * from './helpers';
2 2
 export * from './httpUtils';
3 3
 export * from './loadScript';
4
-export * from './randomUtil';
5 4
 export * from './uri';

+ 0
- 85
react/features/base/util/randomUtil.js 파일 보기

@@ -1,85 +0,0 @@
1
-// @flow
2
-
3
-/**
4
- * Alphanumeric characters.
5
- * @const
6
- */
7
-const ALPHANUM
8
-    = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
9
-
10
-/**
11
- * Hexadecimal digit characters.
12
- * @const
13
- */
14
-const HEX_DIGITS = '0123456789abcdef';
15
-
16
-/**
17
- * Generate a string with random alphanumeric characters with a specific length.
18
- *
19
- * @param {number} length - The length of the string to return.
20
- * @returns {string} A string of random alphanumeric characters with the
21
- * specified length.
22
- */
23
-export function randomAlphanumString(length: number) {
24
-    return _randomString(length, ALPHANUM);
25
-}
26
-
27
-/**
28
- * Get random element of array or string.
29
- *
30
- * @param {Array|string} arr - Source.
31
- * @returns {Array|string} Array element or string character.
32
- */
33
-export function randomElement(arr: Array<*> | string) {
34
-    return arr[randomInt(0, arr.length - 1)];
35
-}
36
-
37
-/**
38
- * Returns a random hex digit.
39
- *
40
- * @returns {Array|string}
41
- */
42
-export function randomHexDigit() {
43
-    return randomElement(HEX_DIGITS);
44
-}
45
-
46
-/**
47
- * Generates a string of random hexadecimal digits with a specific length.
48
- *
49
- * @param {number} length - The length of the string to return.
50
- * @returns {string} A string of random hexadecimal digits with the specified
51
- * length.
52
- */
53
-export function randomHexString(length: number) {
54
-    return _randomString(length, HEX_DIGITS);
55
-}
56
-
57
-/**
58
- * Generates random int within the range [min, max].
59
- *
60
- * @param {number} min - The minimum value for the generated number.
61
- * @param {number} max - The maximum value for the generated number.
62
- * @returns {number} Random int number.
63
- */
64
-export function randomInt(min: number, max: number) {
65
-    return Math.floor(Math.random() * (max - min + 1)) + min;
66
-}
67
-
68
-/**
69
- * Generates a string of random characters with a specific length.
70
- *
71
- * @param {number} length - The length of the string to return.
72
- * @param {string} characters - The characters from which the returned string is
73
- * to be constructed.
74
- * @private
75
- * @returns {string} A string of random characters with the specified length.
76
- */
77
-function _randomString(length, characters) {
78
-    let result = '';
79
-
80
-    for (let i = 0; i < length; ++i) {
81
-        result += randomElement(characters);
82
-    }
83
-
84
-    return result;
85
-}

+ 1
- 1
react/features/calendar-sync/actions.native.js 파일 보기

@@ -1,8 +1,8 @@
1 1
 // @flow
2
+import { generateRoomWithoutSeparator } from 'js-utils/random';
2 3
 
3 4
 import { getDefaultURL } from '../app';
4 5
 import { openDialog } from '../base/dialog';
5
-import { generateRoomWithoutSeparator } from '../welcome';
6 6
 
7 7
 import { refreshCalendar } from './actions';
8 8
 import { addLinkToCalendarEntry } from './functions.native';

+ 2
- 1
react/features/calendar-sync/actions.web.js 파일 보기

@@ -1,5 +1,7 @@
1 1
 // @flow
2 2
 
3
+import { generateRoomWithoutSeparator } from 'js-utils/random';
4
+
3 5
 import { loadGoogleAPI } from '../google-api';
4 6
 
5 7
 import { refreshCalendar, setCalendarEvents } from './actions';
@@ -14,7 +16,6 @@ import {
14 16
     SET_LOADING_CALENDAR_EVENTS
15 17
 } from './actionTypes';
16 18
 import { _getCalendarIntegration, isCalendarEnabled } from './functions';
17
-import { generateRoomWithoutSeparator } from '../welcome';
18 19
 
19 20
 export * from './actions.any';
20 21
 

+ 1
- 1
react/features/overlay/components/AbstractPageReloadOverlay.js 파일 보기

@@ -1,5 +1,6 @@
1 1
 // @flow
2 2
 
3
+import { randomInt } from 'js-utils/random';
3 4
 import React, { Component } from 'react';
4 5
 
5 6
 import {
@@ -11,7 +12,6 @@ import {
11 12
     isFatalJitsiConferenceError,
12 13
     isFatalJitsiConnectionError
13 14
 } from '../../base/lib-jitsi-meet';
14
-import { randomInt } from '../../base/util';
15 15
 
16 16
 import ReloadButton from './ReloadButton';
17 17
 

+ 1
- 2
react/features/welcome/components/AbstractWelcomePage.js 파일 보기

@@ -1,13 +1,12 @@
1 1
 // @flow
2 2
 
3
+import { generateRoomWithoutSeparator } from 'js-utils/random';
3 4
 import { Component } from 'react';
4 5
 
5 6
 import { createWelcomePageEvent, sendAnalytics } from '../../analytics';
6 7
 import { appNavigate } from '../../app';
7 8
 import { isRoomValid } from '../../base/conference';
8 9
 
9
-import { generateRoomWithoutSeparator } from '../functions';
10
-
11 10
 /**
12 11
  * {@code AbstractWelcomePage}'s React {@code Component} prop types.
13 12
  */

+ 0
- 3
react/features/welcome/functions.js 파일 보기

@@ -4,9 +4,6 @@ import { getAppProp } from '../base/app';
4 4
 import { toState } from '../base/redux';
5 5
 
6 6
 declare var APP: Object;
7
-declare var config: Object;
8
-
9
-export * from './roomnameGenerator';
10 7
 
11 8
 /**
12 9
  * Determines whether the {@code WelcomePage} is enabled by the app itself

+ 0
- 243
react/features/welcome/roomnameGenerator.js 파일 보기

@@ -1,243 +0,0 @@
1
-/* @flow */
2
-
3
-import { randomElement } from '../base/util';
4
-
5
-/*
6
-const _NOUN_ = [
7
-];
8
-*/
9
-
10
-/**
11
- * The list of plural nouns.
12
- * @const
13
- */
14
-const _PLURALNOUN_ = [
15
-    'Aliens', 'Animals', 'Antelopes', 'Ants', 'Apes', 'Apples', 'Baboons',
16
-    'Bacteria', 'Badgers', 'Bananas', 'Bats', 'Bears', 'Birds', 'Bonobos',
17
-    'Brides', 'Bugs', 'Bulls', 'Butterflies', 'Cheetahs', 'Cherries', 'Chicken',
18
-    'Children', 'Chimps', 'Clowns', 'Cows', 'Creatures', 'Dinosaurs', 'Dogs',
19
-    'Dolphins', 'Donkeys', 'Dragons', 'Ducks', 'Dwarfs', 'Eagles', 'Elephants',
20
-    'Elves', 'Fathers', 'Fish', 'Flowers', 'Frogs', 'Fruit', 'Fungi',
21
-    'Galaxies', 'Geese', 'Goats', 'Gorillas', 'Hedgehogs', 'Hippos', 'Horses',
22
-    'Hunters', 'Insects', 'Kids', 'Knights', 'Lemons', 'Lemurs', 'Leopards',
23
-    'LifeForms', 'Lions', 'Lizards', 'Mice', 'Monkeys', 'Monsters', 'Mushrooms',
24
-    'Octopodes', 'Oranges', 'Orangutans', 'Organisms', 'Pants', 'Parrots',
25
-    'Penguins', 'People', 'Pigeons', 'Pigs', 'Pineapples', 'Plants', 'Potatoes',
26
-    'Priests', 'Rats', 'Reptiles', 'Reptilians', 'Rhinos', 'Seagulls', 'Sheep',
27
-    'Siblings', 'Snakes', 'Spaghetti', 'Spiders', 'Squid', 'Squirrels',
28
-    'Stars', 'Students', 'Teachers', 'Tigers', 'Tomatoes', 'Trees', 'Vampires',
29
-    'Vegetables', 'Viruses', 'Vulcans', 'Weasels', 'Werewolves', 'Whales',
30
-    'Witches', 'Wizards', 'Wolves', 'Workers', 'Worms', 'Zebras'
31
-];
32
-
33
-/*
34
-const _PLACE_ = [
35
-    'Pub', 'University', 'Airport', 'Library', 'Mall', 'Theater', 'Stadium',
36
-    'Office', 'Show', 'Gallows', 'Beach', 'Cemetery', 'Hospital', 'Reception',
37
-    'Restaurant', 'Bar', 'Church', 'House', 'School', 'Square', 'Village',
38
-    'Cinema', 'Movies', 'Party', 'Restroom', 'End', 'Jail', 'PostOffice',
39
-    'Station', 'Circus', 'Gates', 'Entrance', 'Bridge'
40
-];
41
-*/
42
-
43
-/**
44
- * The list of verbs.
45
- * @const
46
- */
47
-const _VERB_ = [
48
-    'Abandon', 'Adapt', 'Advertise', 'Answer', 'Anticipate', 'Appreciate',
49
-    'Approach', 'Argue', 'Ask', 'Bite', 'Blossom', 'Blush', 'Breathe', 'Breed',
50
-    'Bribe', 'Burn', 'Calculate', 'Clean', 'Code', 'Communicate', 'Compute',
51
-    'Confess', 'Confiscate', 'Conjugate', 'Conjure', 'Consume', 'Contemplate',
52
-    'Crawl', 'Dance', 'Delegate', 'Devour', 'Develop', 'Differ', 'Discuss',
53
-    'Dissolve', 'Drink', 'Eat', 'Elaborate', 'Emancipate', 'Estimate', 'Expire',
54
-    'Extinguish', 'Extract', 'Facilitate', 'Fall', 'Feed', 'Finish', 'Floss',
55
-    'Fly', 'Follow', 'Fragment', 'Freeze', 'Gather', 'Glow', 'Grow', 'Hex',
56
-    'Hide', 'Hug', 'Hurry', 'Improve', 'Intersect', 'Investigate', 'Jinx',
57
-    'Joke', 'Jubilate', 'Kiss', 'Laugh', 'Manage', 'Meet', 'Merge', 'Move',
58
-    'Object', 'Observe', 'Offer', 'Paint', 'Participate', 'Party', 'Perform',
59
-    'Plan', 'Pursue', 'Pierce', 'Play', 'Postpone', 'Pray', 'Proclaim',
60
-    'Question', 'Read', 'Reckon', 'Rejoice', 'Represent', 'Resize', 'Rhyme',
61
-    'Scream', 'Search', 'Select', 'Share', 'Shoot', 'Shout', 'Signal', 'Sing',
62
-    'Skate', 'Sleep', 'Smile', 'Smoke', 'Solve', 'Spell', 'Steer', 'Stink',
63
-    'Substitute', 'Swim', 'Taste', 'Teach', 'Terminate', 'Think', 'Type',
64
-    'Unite', 'Vanish', 'Worship'
65
-];
66
-
67
-/**
68
- * The list of adverbs.
69
- * @const
70
- */
71
-const _ADVERB_ = [
72
-    'Absently', 'Accurately', 'Accusingly', 'Adorably', 'AllTheTime', 'Alone',
73
-    'Always', 'Amazingly', 'Angrily', 'Anxiously', 'Anywhere', 'Appallingly',
74
-    'Apparently', 'Articulately', 'Astonishingly', 'Badly', 'Barely',
75
-    'Beautifully', 'Blindly', 'Bravely', 'Brightly', 'Briskly', 'Brutally',
76
-    'Calmly', 'Carefully', 'Casually', 'Cautiously', 'Cleverly', 'Constantly',
77
-    'Correctly', 'Crazily', 'Curiously', 'Cynically', 'Daily', 'Dangerously',
78
-    'Deliberately', 'Delicately', 'Desperately', 'Discreetly', 'Eagerly',
79
-    'Easily', 'Euphoricly', 'Evenly', 'Everywhere', 'Exactly', 'Expectantly',
80
-    'Extensively', 'Ferociously', 'Fiercely', 'Finely', 'Flatly', 'Frequently',
81
-    'Frighteningly', 'Gently', 'Gloriously', 'Grimly', 'Guiltily', 'Happily',
82
-    'Hard', 'Hastily', 'Heroically', 'High', 'Highly', 'Hourly', 'Humbly',
83
-    'Hysterically', 'Immensely', 'Impartially', 'Impolitely', 'Indifferently',
84
-    'Intensely', 'Jealously', 'Jovially', 'Kindly', 'Lazily', 'Lightly',
85
-    'Loudly', 'Lovingly', 'Loyally', 'Magnificently', 'Malevolently', 'Merrily',
86
-    'Mightily', 'Miserably', 'Mysteriously', 'NOT', 'Nervously', 'Nicely',
87
-    'Nowhere', 'Objectively', 'Obnoxiously', 'Obsessively', 'Obviously',
88
-    'Often', 'Painfully', 'Patiently', 'Playfully', 'Politely', 'Poorly',
89
-    'Precisely', 'Promptly', 'Quickly', 'Quietly', 'Randomly', 'Rapidly',
90
-    'Rarely', 'Recklessly', 'Regularly', 'Remorsefully', 'Responsibly',
91
-    'Rudely', 'Ruthlessly', 'Sadly', 'Scornfully', 'Seamlessly', 'Seldom',
92
-    'Selfishly', 'Seriously', 'Shakily', 'Sharply', 'Sideways', 'Silently',
93
-    'Sleepily', 'Slightly', 'Slowly', 'Slyly', 'Smoothly', 'Softly', 'Solemnly',
94
-    'Steadily', 'Sternly', 'Strangely', 'Strongly', 'Stunningly', 'Surely',
95
-    'Tenderly', 'Thoughtfully', 'Tightly', 'Uneasily', 'Vanishingly',
96
-    'Violently', 'Warmly', 'Weakly', 'Wearily', 'Weekly', 'Weirdly', 'Well',
97
-    'Well', 'Wickedly', 'Wildly', 'Wisely', 'Wonderfully', 'Yearly'
98
-];
99
-
100
-/**
101
- * The list of adjectives.
102
- * @const
103
- */
104
-const _ADJECTIVE_ = [
105
-    'Abominable', 'Accurate', 'Adorable', 'All', 'Alleged', 'Ancient', 'Angry',
106
-    'Anxious', 'Appalling', 'Apparent', 'Astonishing', 'Attractive', 'Awesome',
107
-    'Baby', 'Bad', 'Beautiful', 'Benign', 'Big', 'Bitter', 'Blind', 'Blue',
108
-    'Bold', 'Brave', 'Bright', 'Brisk', 'Calm', 'Camouflaged', 'Casual',
109
-    'Cautious', 'Choppy', 'Chosen', 'Clever', 'Cold', 'Cool', 'Crawly',
110
-    'Crazy', 'Creepy', 'Cruel', 'Curious', 'Cynical', 'Dangerous', 'Dark',
111
-    'Delicate', 'Desperate', 'Difficult', 'Discreet', 'Disguised', 'Dizzy',
112
-    'Dumb', 'Eager', 'Easy', 'Edgy', 'Electric', 'Elegant', 'Emancipated',
113
-    'Enormous', 'Euphoric', 'Evil', 'Fast', 'Ferocious', 'Fierce', 'Fine',
114
-    'Flawed', 'Flying', 'Foolish', 'Foxy', 'Freezing', 'Funny', 'Furious',
115
-    'Gentle', 'Glorious', 'Golden', 'Good', 'Green', 'Green', 'Guilty',
116
-    'Hairy', 'Happy', 'Hard', 'Hasty', 'Hazy', 'Heroic', 'Hostile', 'Hot',
117
-    'Humble', 'Humongous', 'Humorous', 'Hysterical', 'Idealistic', 'Ignorant',
118
-    'Immense', 'Impartial', 'Impolite', 'Indifferent', 'Infuriated',
119
-    'Insightful', 'Intense', 'Interesting', 'Intimidated', 'Intriguing',
120
-    'Jealous', 'Jolly', 'Jovial', 'Jumpy', 'Kind', 'Laughing', 'Lazy', 'Liquid',
121
-    'Lonely', 'Longing', 'Loud', 'Loving', 'Loyal', 'Macabre', 'Mad', 'Magical',
122
-    'Magnificent', 'Malevolent', 'Medieval', 'Memorable', 'Mere', 'Merry',
123
-    'Mighty', 'Mischievous', 'Miserable', 'Modified', 'Moody', 'Most',
124
-    'Mysterious', 'Mystical', 'Needy', 'Nervous', 'Nice', 'Objective',
125
-    'Obnoxious', 'Obsessive', 'Obvious', 'Opinionated', 'Orange', 'Painful',
126
-    'Passionate', 'Perfect', 'Pink', 'Playful', 'Poisonous', 'Polite', 'Poor',
127
-    'Popular', 'Powerful', 'Precise', 'Preserved', 'Pretty', 'Purple', 'Quick',
128
-    'Quiet', 'Random', 'Rapid', 'Rare', 'Real', 'Reassuring', 'Reckless', 'Red',
129
-    'Regular', 'Remorseful', 'Responsible', 'Rich', 'Rude', 'Ruthless', 'Sad',
130
-    'Scared', 'Scary', 'Scornful', 'Screaming', 'Selfish', 'Serious', 'Shady',
131
-    'Shaky', 'Sharp', 'Shiny', 'Shy', 'Simple', 'Sleepy', 'Slow', 'Sly',
132
-    'Small', 'Smart', 'Smelly', 'Smiling', 'Smooth', 'Smug', 'Sober', 'Soft',
133
-    'Solemn', 'Square', 'Square', 'Steady', 'Strange', 'Strong', 'Stunning',
134
-    'Subjective', 'Successful', 'Surly', 'Sweet', 'Tactful', 'Tense',
135
-    'Thoughtful', 'Tight', 'Tiny', 'Tolerant', 'Uneasy', 'Unique', 'Unseen',
136
-    'Warm', 'Weak', 'Weird', 'WellCooked', 'Wild', 'Wise', 'Witty', 'Wonderful',
137
-    'Worried', 'Yellow', 'Young', 'Zealous'
138
-];
139
-
140
-/*
141
-const _PRONOUN_ = [
142
-];
143
-*/
144
-
145
-/*
146
-const _CONJUNCTION_ = [
147
-    'And', 'Or', 'For', 'Above', 'Before', 'Against', 'Between'
148
-];
149
-*/
150
-
151
-/**
152
- * Maps a string (category name) to the array of words from that category.
153
- * @const
154
- */
155
-const CATEGORIES: { [key: string]: Array<string> } = {
156
-    _ADJECTIVE_,
157
-    _ADVERB_,
158
-    _PLURALNOUN_,
159
-    _VERB_
160
-
161
-//    _CONJUNCTION_,
162
-//    _NOUN_,
163
-//    _PLACE_,
164
-//    _PRONOUN_,
165
-};
166
-
167
-/**
168
- * The list of room name patterns.
169
- * @const
170
- */
171
-const PATTERNS = [
172
-    '_ADJECTIVE__PLURALNOUN__VERB__ADVERB_'
173
-
174
-    // BeautifulFungiOrSpaghetti
175
-    //    '_ADJECTIVE__PLURALNOUN__CONJUNCTION__PLURALNOUN_',
176
-
177
-    // AmazinglyScaryToy
178
-    //    '_ADVERB__ADJECTIVE__NOUN_',
179
-
180
-    // NeitherTrashNorRifle
181
-    //    'Neither_NOUN_Nor_NOUN_',
182
-    //    'Either_NOUN_Or_NOUN_',
183
-
184
-    // EitherCopulateOrInvestigate
185
-    //    'Either_VERB_Or_VERB_',
186
-    //    'Neither_VERB_Nor_VERB_',
187
-
188
-    //    'The_ADJECTIVE__ADJECTIVE__NOUN_',
189
-    //    'The_ADVERB__ADJECTIVE__NOUN_',
190
-    //    'The_ADVERB__ADJECTIVE__NOUN_s',
191
-    //    'The_ADVERB__ADJECTIVE__PLURALNOUN__VERB_',
192
-
193
-    // WolvesComputeBadly
194
-    //    '_PLURALNOUN__VERB__ADVERB_',
195
-
196
-    // UniteFacilitateAndMerge
197
-    //    '_VERB__VERB_And_VERB_',
198
-
199
-    // NastyWitchesAtThePub
200
-    //    '_ADJECTIVE__PLURALNOUN_AtThe_PLACE_',
201
-];
202
-
203
-/**
204
- * Generates a new room name.
205
- *
206
- * @returns {string} A newly-generated room name.
207
- */
208
-export function generateRoomWithoutSeparator() {
209
-    // XXX Note that if more than one pattern is available, the choice of 'name'
210
-    // won't have a uniform distribution amongst all patterns (names from
211
-    // patterns with fewer options will have higher probability of being chosen
212
-    // that names from patterns with more options).
213
-    let name = randomElement(PATTERNS);
214
-
215
-    while (_hasTemplate(name)) {
216
-        for (const template in CATEGORIES) { // eslint-disable-line guard-for-in
217
-            const word = randomElement(CATEGORIES[template]);
218
-
219
-            name = name.replace(template, word);
220
-        }
221
-    }
222
-
223
-    return name;
224
-}
225
-
226
-/**
227
- * Determines whether a specific string contains at least one of the
228
- * templates/categories.
229
- *
230
- * @param {string} s - String containing categories.
231
- * @private
232
- * @returns {boolean} True if the specified string contains at least one of the
233
- * templates/categories; otherwise, false.
234
- */
235
-function _hasTemplate(s) {
236
-    for (const template in CATEGORIES) {
237
-        if (s.indexOf(template) >= 0) {
238
-            return true;
239
-        }
240
-    }
241
-
242
-    return false;
243
-}

Loading…
취소
저장