RunKit + npm: unique-names-generator

node v17.9.1
endpointsharetweet
const { uniqueNamesGenerator, adjectives, colors, names, animals } = require('unique-names-generator'); const dictionaries = [adjectives, adjectives, animals]; function generateSubdomainFromBranchName(branch) { return uniqueNamesGenerator({ dictionaries, length: dictionaries.length, separator: '-', style: 'lowerCase', seed: branch, }); } const testBranchNames = [ "test-witha-superbadreally-long-name-thatismore-than-the'mmaximum-characterslol-thisisfunny", "m'branch", "foo", "main", "correct-the-error-message-when-passwords/sc-83211", "correct-the-error-message-when-passwords-dont-match/sc-83211/attempt2", ]; const longestFirst = (a, b) => b.length - a.length; const longestInList = (list) => list.sort(longestFirst)[0]; const longestKey = dictionaries.map(longestInList).join('-').toLowerCase(); console.log(`longest possible key: ${longestKey} (${longestKey.length} chars)`) console.log(`keyspace: ${dictionaries.reduce((space, { length }) => space * length, 1)}`) testBranchNames.reduce((lookup, branch) => { return { ...lookup, [generateSubdomainFromBranchName(branch)]: branch, } }, {});
Created from: https://npm.runkit.com/unique-names-generator
Loading…