Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
ref: js-utils for random and room name generator (#3975)
virtuacoplennya667c9bff2f3
diff --git a/package-lock.json b/package-lock.jsonindex be11638eef..4b27fe52e4 100644--- a/package-lock.json+++ b/package-lock.json@@ -3398,6 +3398,11 @@"multicast-dns-service-types": "^1.1.0"}},+ "bowser": {+ "version": "1.9.1",+ "resolved": "https://registry.npmjs.org/bowser/-/bowser-1.9.1.tgz",+ "integrity": "sha512-UXti1JB6oK8hO983AImunnV6j/fqAEeDlPXh99zhsP5g32oLbxJJ6qcOaUesR+tqqhnUVQHlRJyD0dfiV0Hxaw=="+ },"bplist-creator": {"version": "0.0.7","resolved": "https://registry.npmjs.org/bplist-creator/-/bplist-creator-0.0.7.tgz",@@ -8243,18 +8248,13 @@"integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls="},"js-utils": {- "version": "github:jitsi/js-utils#446497893023aa8dec403e0e4e35a22cae6bc87d",- "from": "github:jitsi/js-utils#446497893023aa8dec403e0e4e35a22cae6bc87d",+ "version": "github:jitsi/js-utils#73a67a7a60d52f8e895f50939c8fcbd1f20fe7b5",+ "from": "github:jitsi/js-utils#73a67a7a60d52f8e895f50939c8fcbd1f20fe7b5","requires": {"bowser": "1.9.1","js-md5": "0.7.3"},"dependencies": {- "bowser": {- "version": "1.9.1",- "resolved": "https://registry.npmjs.org/bowser/-/bowser-1.9.1.tgz",- "integrity": "sha512-UXti1JB6oK8hO983AImunnV6j/fqAEeDlPXh99zhsP5g32oLbxJJ6qcOaUesR+tqqhnUVQHlRJyD0dfiV0Hxaw=="- },"js-md5": {"version": "0.7.3","resolved": "https://registry.npmjs.org/js-md5/-/js-md5-0.7.3.tgz",@@ -8481,6 +8481,21 @@"strophejs-plugin-disco": "0.0.2","webrtc-adapter": "github:webrtc/adapter#1eec19782b4058d186341263e7d049cea3e3290a","yaeti": "1.0.1"+ },+ "dependencies": {+ "js-md5": {+ "version": "0.7.3",+ "resolved": "https://registry.npmjs.org/js-md5/-/js-md5-0.7.3.tgz",+ "integrity": "sha512-ZC41vPSTLKGwIRjqDh8DfXoCrdQIyBgspJVPXHBGu4nZlAEvG3nf+jO9avM9RmLiGakg7vz974ms99nEV0tmTQ=="+ },+ "js-utils": {+ "version": "github:jitsi/js-utils#446497893023aa8dec403e0e4e35a22cae6bc87d",+ "from": "github:jitsi/js-utils#446497893023aa8dec403e0e4e35a22cae6bc87d",+ "requires": {+ "bowser": "1.9.1",+ "js-md5": "0.7.3"+ }+ }}},"libflacjs": {diff --git a/package.json b/package.jsonindex e5dd2f3720..b66588bb3e 100644--- a/package.json+++ b/package.json@@ -48,7 +48,7 @@"jquery-contextmenu": "2.4.5","jquery-i18next": "1.2.0","js-md5": "0.6.1",- "js-utils": "github:jitsi/js-utils#446497893023aa8dec403e0e4e35a22cae6bc87d",+ "js-utils": "github:jitsi/js-utils#73a67a7a60d52f8e895f50939c8fcbd1f20fe7b5","jsc-android": "224109.1.0","jsrsasign": "8.0.12","jwt-decode": "2.2.0",diff --git a/react/features/app/getRouteToRender.js b/react/features/app/getRouteToRender.jsindex 2287f2217e..2df37afcb5 100644--- a/react/features/app/getRouteToRender.js+++ b/react/features/app/getRouteToRender.js@@ -1,5 +1,6 @@// @flow+import { generateRoomWithoutSeparator } from 'js-utils/random';import type { Component } from 'react';import { isRoomValid } from '../base/conference';@@ -12,13 +13,10 @@ import { UnsupportedDesktopBrowser } from '../unsupported-browser';import {BlankPage,WelcomePage,- generateRoomWithoutSeparator,isWelcomePageAppEnabled,isWelcomePageUserEnabled} from '../welcome';-declare var interfaceConfig: Object;-/*** Object describing application route.*diff --git a/react/features/base/participants/reducer.js b/react/features/base/participants/reducer.jsindex 59c4221033..648981df06 100644--- a/react/features/base/participants/reducer.js+++ b/react/features/base/participants/reducer.js@@ -1,7 +1,8 @@// @flow+import { randomHexString } from 'js-utils/random';+import { ReducerRegistry, set } from '../redux';-import { randomHexString } from '../util';import {DOMINANT_SPEAKER_CHANGED,diff --git a/react/features/base/settings/reducer.js b/react/features/base/settings/reducer.jsindex 818a75b4a4..90858d9c63 100644--- a/react/features/base/settings/reducer.js+++ b/react/features/base/settings/reducer.js@@ -1,11 +1,13 @@// @flow++import { randomHexString } from 'js-utils/random';import _ from 'lodash';import { APP_WILL_MOUNT } from '../app';import JitsiMeetJS, { browser } from '../lib-jitsi-meet';import { ReducerRegistry } from '../redux';import { PersistenceRegistry } from '../storage';-import { assignIfDefined, randomHexString } from '../util';+import { assignIfDefined } from '../util';import { SETTINGS_UPDATED } from './actionTypes';diff --git a/react/features/base/util/index.js b/react/features/base/util/index.jsindex 0e99d53725..85b614aecf 100644--- a/react/features/base/util/index.js+++ b/react/features/base/util/index.js@@ -1,5 +1,4 @@export * from './helpers';export * from './httpUtils';export * from './loadScript';-export * from './randomUtil';export * from './uri';diff --git a/react/features/base/util/randomUtil.js b/react/features/base/util/randomUtil.jsdeleted file mode 100644index a657ee8d2d..0000000000--- a/react/features/base/util/randomUtil.js+++ /dev/null@@ -1,85 +0,0 @@-// @flow--/**- * Alphanumeric characters.- * @const- */-const ALPHANUM- = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';--/**- * Hexadecimal digit characters.- * @const- */-const HEX_DIGITS = '0123456789abcdef';--/**- * Generate a string with random alphanumeric characters with a specific length.- *- * @param {number} length - The length of the string to return.- * @returns {string} A string of random alphanumeric characters with the- * specified length.- */-export function randomAlphanumString(length: number) {- return _randomString(length, ALPHANUM);-}--/**- * Get random element of array or string.- *- * @param {Array|string} arr - Source.- * @returns {Array|string} Array element or string character.- */-export function randomElement(arr: Array<*> | string) {- return arr[randomInt(0, arr.length - 1)];-}--/**- * Returns a random hex digit.- *- * @returns {Array|string}- */-export function randomHexDigit() {- return randomElement(HEX_DIGITS);-}--/**- * Generates a string of random hexadecimal digits with a specific length.- *- * @param {number} length - The length of the string to return.- * @returns {string} A string of random hexadecimal digits with the specified- * length.- */-export function randomHexString(length: number) {- return _randomString(length, HEX_DIGITS);-}--/**- * Generates random int within the range [min, max].- *- * @param {number} min - The minimum value for the generated number.- * @param {number} max - The maximum value for the generated number.- * @returns {number} Random int number.- */-export function randomInt(min: number, max: number) {- return Math.floor(Math.random() * (max - min + 1)) + min;-}--/**- * Generates a string of random characters with a specific length.- *- * @param {number} length - The length of the string to return.- * @param {string} characters - The characters from which the returned string is- * to be constructed.- * @private- * @returns {string} A string of random characters with the specified length.- */-function _randomString(length, characters) {- let result = '';-- for (let i = 0; i < length; ++i) {- result += randomElement(characters);- }-- return result;-}diff --git a/react/features/calendar-sync/actions.native.js b/react/features/calendar-sync/actions.native.jsindex dfe555354d..64536e8557 100644--- a/react/features/calendar-sync/actions.native.js+++ b/react/features/calendar-sync/actions.native.js@@ -1,8 +1,8 @@// @flow+import { generateRoomWithoutSeparator } from 'js-utils/random';import { getDefaultURL } from '../app';import { openDialog } from '../base/dialog';-import { generateRoomWithoutSeparator } from '../welcome';import { refreshCalendar } from './actions';import { addLinkToCalendarEntry } from './functions.native';diff --git a/react/features/calendar-sync/actions.web.js b/react/features/calendar-sync/actions.web.jsindex 783549d3b1..17674b33f0 100644--- a/react/features/calendar-sync/actions.web.js+++ b/react/features/calendar-sync/actions.web.js@@ -1,5 +1,7 @@// @flow+import { generateRoomWithoutSeparator } from 'js-utils/random';+import { loadGoogleAPI } from '../google-api';import { refreshCalendar, setCalendarEvents } from './actions';@@ -14,7 +16,6 @@ import {SET_LOADING_CALENDAR_EVENTS} from './actionTypes';import { _getCalendarIntegration, isCalendarEnabled } from './functions';-import { generateRoomWithoutSeparator } from '../welcome';export * from './actions.any';diff --git a/react/features/overlay/components/AbstractPageReloadOverlay.js b/react/features/overlay/components/AbstractPageReloadOverlay.jsindex c4d59b3dc6..5ac5dc5e6e 100644--- a/react/features/overlay/components/AbstractPageReloadOverlay.js+++ b/react/features/overlay/components/AbstractPageReloadOverlay.js@@ -1,5 +1,6 @@// @flow+import { randomInt } from 'js-utils/random';import React, { Component } from 'react';import {@@ -11,7 +12,6 @@ import {isFatalJitsiConferenceError,isFatalJitsiConnectionError} from '../../base/lib-jitsi-meet';-import { randomInt } from '../../base/util';import ReloadButton from './ReloadButton';diff --git a/react/features/welcome/components/AbstractWelcomePage.js b/react/features/welcome/components/AbstractWelcomePage.jsindex 02d089ca23..7ceb31a079 100644--- a/react/features/welcome/components/AbstractWelcomePage.js+++ b/react/features/welcome/components/AbstractWelcomePage.js@@ -1,13 +1,12 @@// @flow+import { generateRoomWithoutSeparator } from 'js-utils/random';import { Component } from 'react';import { createWelcomePageEvent, sendAnalytics } from '../../analytics';import { appNavigate } from '../../app';import { isRoomValid } from '../../base/conference';-import { generateRoomWithoutSeparator } from '../functions';-/*** {@code AbstractWelcomePage}'s React {@code Component} prop types.*/diff --git a/react/features/welcome/functions.js b/react/features/welcome/functions.jsindex 5e9aa8d25a..f8b38a3434 100644--- a/react/features/welcome/functions.js+++ b/react/features/welcome/functions.js@@ -4,9 +4,6 @@ import { getAppProp } from '../base/app';import { toState } from '../base/redux';declare var APP: Object;-declare var config: Object;--export * from './roomnameGenerator';/*** Determines whether the {@code WelcomePage} is enabled by the app itselfdiff --git a/react/features/welcome/roomnameGenerator.js b/react/features/welcome/roomnameGenerator.jsdeleted file mode 100644index 65ea76be71..0000000000--- a/react/features/welcome/roomnameGenerator.js+++ /dev/null@@ -1,243 +0,0 @@-/* @flow */--import { randomElement } from '../base/util';--/*-const _NOUN_ = [-];-*/--/**- * The list of plural nouns.- * @const- */-const _PLURALNOUN_ = [- 'Aliens', 'Animals', 'Antelopes', 'Ants', 'Apes', 'Apples', 'Baboons',- 'Bacteria', 'Badgers', 'Bananas', 'Bats', 'Bears', 'Birds', 'Bonobos',- 'Brides', 'Bugs', 'Bulls', 'Butterflies', 'Cheetahs', 'Cherries', 'Chicken',- 'Children', 'Chimps', 'Clowns', 'Cows', 'Creatures', 'Dinosaurs', 'Dogs',- 'Dolphins', 'Donkeys', 'Dragons', 'Ducks', 'Dwarfs', 'Eagles', 'Elephants',- 'Elves', 'Fathers', 'Fish', 'Flowers', 'Frogs', 'Fruit', 'Fungi',- 'Galaxies', 'Geese', 'Goats', 'Gorillas', 'Hedgehogs', 'Hippos', 'Horses',- 'Hunters', 'Insects', 'Kids', 'Knights', 'Lemons', 'Lemurs', 'Leopards',- 'LifeForms', 'Lions', 'Lizards', 'Mice', 'Monkeys', 'Monsters', 'Mushrooms',- 'Octopodes', 'Oranges', 'Orangutans', 'Organisms', 'Pants', 'Parrots',- 'Penguins', 'People', 'Pigeons', 'Pigs', 'Pineapples', 'Plants', 'Potatoes',- 'Priests', 'Rats', 'Reptiles', 'Reptilians', 'Rhinos', 'Seagulls', 'Sheep',- 'Siblings', 'Snakes', 'Spaghetti', 'Spiders', 'Squid', 'Squirrels',- 'Stars', 'Students', 'Teachers', 'Tigers', 'Tomatoes', 'Trees', 'Vampires',- 'Vegetables', 'Viruses', 'Vulcans', 'Weasels', 'Werewolves', 'Whales',- 'Witches', 'Wizards', 'Wolves', 'Workers', 'Worms', 'Zebras'-];--/*-const _PLACE_ = [- 'Pub', 'University', 'Airport', 'Library', 'Mall', 'Theater', 'Stadium',- 'Office', 'Show', 'Gallows', 'Beach', 'Cemetery', 'Hospital', 'Reception',- 'Restaurant', 'Bar', 'Church', 'House', 'School', 'Square', 'Village',- 'Cinema', 'Movies', 'Party', 'Restroom', 'End', 'Jail', 'PostOffice',- 'Station', 'Circus', 'Gates', 'Entrance', 'Bridge'-];-*/--/**- * The list of verbs.- * @const- */-const _VERB_ = [- 'Abandon', 'Adapt', 'Advertise', 'Answer', 'Anticipate', 'Appreciate',- 'Approach', 'Argue', 'Ask', 'Bite', 'Blossom', 'Blush', 'Breathe', 'Breed',- 'Bribe', 'Burn', 'Calculate', 'Clean', 'Code', 'Communicate', 'Compute',- 'Confess', 'Confiscate', 'Conjugate', 'Conjure', 'Consume', 'Contemplate',- 'Crawl', 'Dance', 'Delegate', 'Devour', 'Develop', 'Differ', 'Discuss',- 'Dissolve', 'Drink', 'Eat', 'Elaborate', 'Emancipate', 'Estimate', 'Expire',- 'Extinguish', 'Extract', 'Facilitate', 'Fall', 'Feed', 'Finish', 'Floss',- 'Fly', 'Follow', 'Fragment', 'Freeze', 'Gather', 'Glow', 'Grow', 'Hex',- 'Hide', 'Hug', 'Hurry', 'Improve', 'Intersect', 'Investigate', 'Jinx',- 'Joke', 'Jubilate', 'Kiss', 'Laugh', 'Manage', 'Meet', 'Merge', 'Move',- 'Object', 'Observe', 'Offer', 'Paint', 'Participate', 'Party', 'Perform',- 'Plan', 'Pursue', 'Pierce', 'Play', 'Postpone', 'Pray', 'Proclaim',- 'Question', 'Read', 'Reckon', 'Rejoice', 'Represent', 'Resize', 'Rhyme',- 'Scream', 'Search', 'Select', 'Share', 'Shoot', 'Shout', 'Signal', 'Sing',- 'Skate', 'Sleep', 'Smile', 'Smoke', 'Solve', 'Spell', 'Steer', 'Stink',- 'Substitute', 'Swim', 'Taste', 'Teach', 'Terminate', 'Think', 'Type',- 'Unite', 'Vanish', 'Worship'-];--/**- * The list of adverbs.- * @const- */-const _ADVERB_ = [- 'Absently', 'Accurately', 'Accusingly', 'Adorably', 'AllTheTime', 'Alone',- 'Always', 'Amazingly', 'Angrily', 'Anxiously', 'Anywhere', 'Appallingly',- 'Apparently', 'Articulately', 'Astonishingly', 'Badly', 'Barely',- 'Beautifully', 'Blindly', 'Bravely', 'Brightly', 'Briskly', 'Brutally',- 'Calmly', 'Carefully', 'Casually', 'Cautiously', 'Cleverly', 'Constantly',- 'Correctly', 'Crazily', 'Curiously', 'Cynically', 'Daily', 'Dangerously',- 'Deliberately', 'Delicately', 'Desperately', 'Discreetly', 'Eagerly',- 'Easily', 'Euphoricly', 'Evenly', 'Everywhere', 'Exactly', 'Expectantly',- 'Extensively', 'Ferociously', 'Fiercely', 'Finely', 'Flatly', 'Frequently',- 'Frighteningly', 'Gently', 'Gloriously', 'Grimly', 'Guiltily', 'Happily',- 'Hard', 'Hastily', 'Heroically', 'High', 'Highly', 'Hourly', 'Humbly',- 'Hysterically', 'Immensely', 'Impartially', 'Impolitely', 'Indifferently',- 'Intensely', 'Jealously', 'Jovially', 'Kindly', 'Lazily', 'Lightly',- 'Loudly', 'Lovingly', 'Loyally', 'Magnificently', 'Malevolently', 'Merrily',- 'Mightily', 'Miserably', 'Mysteriously', 'NOT', 'Nervously', 'Nicely',- 'Nowhere', 'Objectively', 'Obnoxiously', 'Obsessively', 'Obviously',- 'Often', 'Painfully', 'Patiently', 'Playfully', 'Politely', 'Poorly',- 'Precisely', 'Promptly', 'Quickly', 'Quietly', 'Randomly', 'Rapidly',- 'Rarely', 'Recklessly', 'Regularly', 'Remorsefully', 'Responsibly',- 'Rudely', 'Ruthlessly', 'Sadly', 'Scornfully', 'Seamlessly', 'Seldom',- 'Selfishly', 'Seriously', 'Shakily', 'Sharply', 'Sideways', 'Silently',- 'Sleepily', 'Slightly', 'Slowly', 'Slyly', 'Smoothly', 'Softly', 'Solemnly',- 'Steadily', 'Sternly', 'Strangely', 'Strongly', 'Stunningly', 'Surely',- 'Tenderly', 'Thoughtfully', 'Tightly', 'Uneasily', 'Vanishingly',- 'Violently', 'Warmly', 'Weakly', 'Wearily', 'Weekly', 'Weirdly', 'Well',- 'Well', 'Wickedly', 'Wildly', 'Wisely', 'Wonderfully', 'Yearly'-];--/**- * The list of adjectives.- * @const- */-const _ADJECTIVE_ = [- 'Abominable', 'Accurate', 'Adorable', 'All', 'Alleged', 'Ancient', 'Angry',- 'Anxious', 'Appalling', 'Apparent', 'Astonishing', 'Attractive', 'Awesome',- 'Baby', 'Bad', 'Beautiful', 'Benign', 'Big', 'Bitter', 'Blind', 'Blue',- 'Bold', 'Brave', 'Bright', 'Brisk', 'Calm', 'Camouflaged', 'Casual',- 'Cautious', 'Choppy', 'Chosen', 'Clever', 'Cold', 'Cool', 'Crawly',- 'Crazy', 'Creepy', 'Cruel', 'Curious', 'Cynical', 'Dangerous', 'Dark',- 'Delicate', 'Desperate', 'Difficult', 'Discreet', 'Disguised', 'Dizzy',- 'Dumb', 'Eager', 'Easy', 'Edgy', 'Electric', 'Elegant', 'Emancipated',- 'Enormous', 'Euphoric', 'Evil', 'Fast', 'Ferocious', 'Fierce', 'Fine',- 'Flawed', 'Flying', 'Foolish', 'Foxy', 'Freezing', 'Funny', 'Furious',- 'Gentle', 'Glorious', 'Golden', 'Good', 'Green', 'Green', 'Guilty',- 'Hairy', 'Happy', 'Hard', 'Hasty', 'Hazy', 'Heroic', 'Hostile', 'Hot',- 'Humble', 'Humongous', 'Humorous', 'Hysterical', 'Idealistic', 'Ignorant',- 'Immense', 'Impartial', 'Impolite', 'Indifferent', 'Infuriated',- 'Insightful', 'Intense', 'Interesting', 'Intimidated', 'Intriguing',- 'Jealous', 'Jolly', 'Jovial', 'Jumpy', 'Kind', 'Laughing', 'Lazy', 'Liquid',- 'Lonely', 'Longing', 'Loud', 'Loving', 'Loyal', 'Macabre', 'Mad', 'Magical',- 'Magnificent', 'Malevolent', 'Medieval', 'Memorable', 'Mere', 'Merry',- 'Mighty', 'Mischievous', 'Miserable', 'Modified', 'Moody', 'Most',- 'Mysterious', 'Mystical', 'Needy', 'Nervous', 'Nice', 'Objective',- 'Obnoxious', 'Obsessive', 'Obvious', 'Opinionated', 'Orange', 'Painful',- 'Passionate', 'Perfect', 'Pink', 'Playful', 'Poisonous', 'Polite', 'Poor',- 'Popular', 'Powerful', 'Precise', 'Preserved', 'Pretty', 'Purple', 'Quick',- 'Quiet', 'Random', 'Rapid', 'Rare', 'Real', 'Reassuring', 'Reckless', 'Red',- 'Regular', 'Remorseful', 'Responsible', 'Rich', 'Rude', 'Ruthless', 'Sad',- 'Scared', 'Scary', 'Scornful', 'Screaming', 'Selfish', 'Serious', 'Shady',- 'Shaky', 'Sharp', 'Shiny', 'Shy', 'Simple', 'Sleepy', 'Slow', 'Sly',- 'Small', 'Smart', 'Smelly', 'Smiling', 'Smooth', 'Smug', 'Sober', 'Soft',- 'Solemn', 'Square', 'Square', 'Steady', 'Strange', 'Strong', 'Stunning',- 'Subjective', 'Successful', 'Surly', 'Sweet', 'Tactful', 'Tense',- 'Thoughtful', 'Tight', 'Tiny', 'Tolerant', 'Uneasy', 'Unique', 'Unseen',- 'Warm', 'Weak', 'Weird', 'WellCooked', 'Wild', 'Wise', 'Witty', 'Wonderful',- 'Worried', 'Yellow', 'Young', 'Zealous'-];--/*-const _PRONOUN_ = [-];-*/--/*-const _CONJUNCTION_ = [- 'And', 'Or', 'For', 'Above', 'Before', 'Against', 'Between'-];-*/--/**- * Maps a string (category name) to the array of words from that category.- * @const- */-const CATEGORIES: { [key: string]: Array<string> } = {- _ADJECTIVE_,- _ADVERB_,- _PLURALNOUN_,- _VERB_--// _CONJUNCTION_,-// _NOUN_,-// _PLACE_,-// _PRONOUN_,-};--/**- * The list of room name patterns.- * @const- */-const PATTERNS = [- '_ADJECTIVE__PLURALNOUN__VERB__ADVERB_'-- // BeautifulFungiOrSpaghetti- // '_ADJECTIVE__PLURALNOUN__CONJUNCTION__PLURALNOUN_',-- // AmazinglyScaryToy- // '_ADVERB__ADJECTIVE__NOUN_',-- // NeitherTrashNorRifle- // 'Neither_NOUN_Nor_NOUN_',- // 'Either_NOUN_Or_NOUN_',-- // EitherCopulateOrInvestigate- // 'Either_VERB_Or_VERB_',- // 'Neither_VERB_Nor_VERB_',-- // 'The_ADJECTIVE__ADJECTIVE__NOUN_',- // 'The_ADVERB__ADJECTIVE__NOUN_',- // 'The_ADVERB__ADJECTIVE__NOUN_s',- // 'The_ADVERB__ADJECTIVE__PLURALNOUN__VERB_',-- // WolvesComputeBadly- // '_PLURALNOUN__VERB__ADVERB_',-- // UniteFacilitateAndMerge- // '_VERB__VERB_And_VERB_',-- // NastyWitchesAtThePub- // '_ADJECTIVE__PLURALNOUN_AtThe_PLACE_',-];--/**- * Generates a new room name.- *- * @returns {string} A newly-generated room name.- */-export function generateRoomWithoutSeparator() {- // XXX Note that if more than one pattern is available, the choice of 'name'- // won't have a uniform distribution amongst all patterns (names from- // patterns with fewer options will have higher probability of being chosen- // that names from patterns with more options).- let name = randomElement(PATTERNS);-- while (_hasTemplate(name)) {- for (const template in CATEGORIES) { // eslint-disable-line guard-for-in- const word = randomElement(CATEGORIES[template]);-- name = name.replace(template, word);- }- }-- return name;-}--/**- * Determines whether a specific string contains at least one of the- * templates/categories.- *- * @param {string} s - String containing categories.- * @private- * @returns {boolean} True if the specified string contains at least one of the- * templates/categories; otherwise, false.- */-function _hasTemplate(s) {- for (const template in CATEGORIES) {- if (s.indexOf(template) >= 0) {- return true;- }- }-- return false;-}