human-ids 1.0.13 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +191 -80
- package/dist/dictionaries/en.d.ts +3 -0
- package/dist/dictionaries/en.js +983 -0
- package/dist/dictionaries/es.d.ts +3 -0
- package/dist/dictionaries/es.js +986 -0
- package/dist/dictionaries/index.d.ts +45 -0
- package/dist/dictionaries/index.js +57 -0
- package/dist/index.d.ts +246 -0
- package/dist/index.js +135 -0
- package/package.json +38 -11
- package/CHANGELOG.md +0 -66
- package/dictionaries/en.js +0 -224
- package/dictionaries/es.js +0 -221
- package/dictionaries/index.js +0 -9
- package/index.d.ts +0 -31
- package/index.js +0 -97
- package/tests/index.test.js +0 -34
package/dictionaries/en.js
DELETED
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
const words = {
|
|
2
|
-
adjectives: {
|
|
3
|
-
silly: "silly",
|
|
4
|
-
silly: "silly",
|
|
5
|
-
happy: "happy",
|
|
6
|
-
funny: "funny",
|
|
7
|
-
kind: "kind",
|
|
8
|
-
brave: "brave",
|
|
9
|
-
calm: "calm",
|
|
10
|
-
shiny: "shiny",
|
|
11
|
-
witty: "witty",
|
|
12
|
-
sunny: "sunny",
|
|
13
|
-
friendly: "friendly",
|
|
14
|
-
clever: "clever",
|
|
15
|
-
loud: "loud",
|
|
16
|
-
gentle: "gentle",
|
|
17
|
-
honest: "honest",
|
|
18
|
-
polite: "polite",
|
|
19
|
-
caring: "caring",
|
|
20
|
-
playful: "playful",
|
|
21
|
-
cheerful: "cheerful",
|
|
22
|
-
cozy: "cozy",
|
|
23
|
-
daring: "daring",
|
|
24
|
-
patient: "patient",
|
|
25
|
-
eager: "eager",
|
|
26
|
-
creative: "creative",
|
|
27
|
-
quirky: "quirky",
|
|
28
|
-
loyal: "loyal",
|
|
29
|
-
sincere: "sincere",
|
|
30
|
-
thoughtful: "thoughtful",
|
|
31
|
-
wise: "wise",
|
|
32
|
-
sensible: "sensible",
|
|
33
|
-
charming: "charming",
|
|
34
|
-
joyful: "joyful",
|
|
35
|
-
breezy: "breezy",
|
|
36
|
-
vivid: "vivid",
|
|
37
|
-
delightful: "delightful",
|
|
38
|
-
peaceful: "peaceful",
|
|
39
|
-
radiant: "radiant",
|
|
40
|
-
bubbly: "bubbly",
|
|
41
|
-
carefree: "carefree",
|
|
42
|
-
genuine: "genuine",
|
|
43
|
-
lively: "lively",
|
|
44
|
-
mellow: "mellow",
|
|
45
|
-
optimistic: "optimistic",
|
|
46
|
-
relaxed: "relaxed",
|
|
47
|
-
sweet: "sweet",
|
|
48
|
-
tender: "tender",
|
|
49
|
-
vibrant: "vibrant",
|
|
50
|
-
wonderful: "wonderful",
|
|
51
|
-
blissful: "blissful",
|
|
52
|
-
graceful: "graceful",
|
|
53
|
-
gleeful: "gleeful",
|
|
54
|
-
satisfied: "satisfied",
|
|
55
|
-
zesty: "zesty",
|
|
56
|
-
jolly: "jolly",
|
|
57
|
-
merry: "merry",
|
|
58
|
-
festive: "festive",
|
|
59
|
-
amusing: "amusing",
|
|
60
|
-
upbeat: "upbeat",
|
|
61
|
-
content: "content",
|
|
62
|
-
energetic: "energetic",
|
|
63
|
-
bouncy: "bouncy",
|
|
64
|
-
spunky: "spunky",
|
|
65
|
-
harmonious: "harmonious",
|
|
66
|
-
serene: "serene",
|
|
67
|
-
smooth: "smooth",
|
|
68
|
-
comfortable: "comfortable",
|
|
69
|
-
playful: "playful",
|
|
70
|
-
proud: "proud",
|
|
71
|
-
elegant: "elegant",
|
|
72
|
-
dynamic: "dynamic",
|
|
73
|
-
fearless: "fearless",
|
|
74
|
-
brilliant: "brilliant",
|
|
75
|
-
captivating: "captivating",
|
|
76
|
-
exuberant: "exuberant",
|
|
77
|
-
whimsical: "whimsical",
|
|
78
|
-
romantic: "romantic",
|
|
79
|
-
enchanting: "enchanting",
|
|
80
|
-
careful: "careful",
|
|
81
|
-
gallant: "gallant",
|
|
82
|
-
gracious: "gracious",
|
|
83
|
-
spirited: "spirited",
|
|
84
|
-
amiable: "amiable",
|
|
85
|
-
cordial: "cordial",
|
|
86
|
-
rhythmic: "rhythmic",
|
|
87
|
-
gleaming: "gleaming",
|
|
88
|
-
excellent: "excellent",
|
|
89
|
-
adventurous: "adventurous",
|
|
90
|
-
sparkling: "sparkling",
|
|
91
|
-
dreamy: "dreamy",
|
|
92
|
-
spontaneous: "spontaneous",
|
|
93
|
-
inspiring: "inspiring",
|
|
94
|
-
vital: "vital",
|
|
95
|
-
radiant: "radiant",
|
|
96
|
-
refreshing: "refreshing",
|
|
97
|
-
bountiful: "bountiful",
|
|
98
|
-
fabulous: "fabulous",
|
|
99
|
-
playful: "playful",
|
|
100
|
-
zippy: "zippy",
|
|
101
|
-
snazzy: "snazzy",
|
|
102
|
-
pizzazz: "pizzazz"
|
|
103
|
-
},
|
|
104
|
-
colors: {
|
|
105
|
-
red: "red",
|
|
106
|
-
blue: "blue",
|
|
107
|
-
green: "green",
|
|
108
|
-
yellow: "yellow",
|
|
109
|
-
orange: "orange",
|
|
110
|
-
purple: "purple",
|
|
111
|
-
pink: "pink",
|
|
112
|
-
brown: "brown",
|
|
113
|
-
black: "black",
|
|
114
|
-
white: "white",
|
|
115
|
-
gray: "gray",
|
|
116
|
-
silver: "silver",
|
|
117
|
-
gold: "gold",
|
|
118
|
-
beige: "beige",
|
|
119
|
-
turquoise: "turquoise",
|
|
120
|
-
teal: "teal",
|
|
121
|
-
navy: "navy",
|
|
122
|
-
maroon: "maroon",
|
|
123
|
-
olive: "olive",
|
|
124
|
-
indigo: "indigo"
|
|
125
|
-
},
|
|
126
|
-
nouns: {
|
|
127
|
-
cat: "cat",
|
|
128
|
-
dog: "dog",
|
|
129
|
-
bird: "bird",
|
|
130
|
-
rabbit: "rabbit",
|
|
131
|
-
unicorn: "unicorn",
|
|
132
|
-
flower: "flower",
|
|
133
|
-
tree: "tree",
|
|
134
|
-
river: "river",
|
|
135
|
-
ocean: "ocean",
|
|
136
|
-
mountain: "mountain",
|
|
137
|
-
cloud: "cloud",
|
|
138
|
-
sun: "sun",
|
|
139
|
-
moon: "moon",
|
|
140
|
-
star: "star",
|
|
141
|
-
butterfly: "butterfly",
|
|
142
|
-
bee: "bee",
|
|
143
|
-
breeze: "breeze",
|
|
144
|
-
wave: "wave",
|
|
145
|
-
rain: "rain",
|
|
146
|
-
snow: "snow",
|
|
147
|
-
leaf: "leaf",
|
|
148
|
-
stone: "stone",
|
|
149
|
-
sand: "sand",
|
|
150
|
-
boat: "boat",
|
|
151
|
-
bridge: "bridge",
|
|
152
|
-
castle: "castle",
|
|
153
|
-
dream: "dream",
|
|
154
|
-
fire: "fire",
|
|
155
|
-
key: "key",
|
|
156
|
-
lock: "lock",
|
|
157
|
-
music: "music",
|
|
158
|
-
book: "book",
|
|
159
|
-
pen: "pen",
|
|
160
|
-
chair: "chair",
|
|
161
|
-
table: "table",
|
|
162
|
-
window: "window",
|
|
163
|
-
door: "door",
|
|
164
|
-
mirror: "mirror",
|
|
165
|
-
light: "light",
|
|
166
|
-
shadow: "shadow",
|
|
167
|
-
dream: "dream",
|
|
168
|
-
smile: "smile",
|
|
169
|
-
laughter: "laughter",
|
|
170
|
-
friend: "friend",
|
|
171
|
-
love: "love",
|
|
172
|
-
hope: "hope",
|
|
173
|
-
joy: "joy",
|
|
174
|
-
peace: "peace",
|
|
175
|
-
heart: "heart",
|
|
176
|
-
soul: "soul",
|
|
177
|
-
rainbow: "rainbow",
|
|
178
|
-
star: "star",
|
|
179
|
-
planet: "planet",
|
|
180
|
-
galaxy: "galaxy",
|
|
181
|
-
butterfly: "butterfly",
|
|
182
|
-
garden: "garden",
|
|
183
|
-
forest: "forest",
|
|
184
|
-
meadow: "meadow",
|
|
185
|
-
field: "field",
|
|
186
|
-
journey: "journey",
|
|
187
|
-
adventure: "adventure",
|
|
188
|
-
magic: "magic",
|
|
189
|
-
fantasy: "fantasy",
|
|
190
|
-
imagination: "imagination",
|
|
191
|
-
whisper: "whisper",
|
|
192
|
-
giggles: "giggles",
|
|
193
|
-
treasure: "treasure",
|
|
194
|
-
wonder: "wonder",
|
|
195
|
-
serenity: "serenity",
|
|
196
|
-
silence: "silence",
|
|
197
|
-
harmony: "harmony",
|
|
198
|
-
inspiration: "inspiration",
|
|
199
|
-
creativity: "creativity",
|
|
200
|
-
dreamer: "dreamer",
|
|
201
|
-
explorer: "explorer",
|
|
202
|
-
dancer: "dancer",
|
|
203
|
-
artist: "artist",
|
|
204
|
-
story: "story",
|
|
205
|
-
memory: "memory",
|
|
206
|
-
wisdom: "wisdom",
|
|
207
|
-
joy: "joy",
|
|
208
|
-
happiness: "happiness",
|
|
209
|
-
kindness: "kindness",
|
|
210
|
-
gentleness: "gentleness",
|
|
211
|
-
gratitude: "gratitude",
|
|
212
|
-
freedom: "freedom",
|
|
213
|
-
peace: "peace",
|
|
214
|
-
hope: "hope",
|
|
215
|
-
faith: "faith",
|
|
216
|
-
unity: "unity",
|
|
217
|
-
sunset: "sunset",
|
|
218
|
-
sunrise: "sunrise",
|
|
219
|
-
twilight: "twilight",
|
|
220
|
-
midnight: "midnight"
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
module.exports = words;
|
package/dictionaries/es.js
DELETED
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
const words = {
|
|
2
|
-
adjectives: {
|
|
3
|
-
alegre: "alegre",
|
|
4
|
-
amable: "amable",
|
|
5
|
-
audaz: "audaz",
|
|
6
|
-
brillante: "brillante",
|
|
7
|
-
calmo: "calmo",
|
|
8
|
-
calido: "calido",
|
|
9
|
-
chistoso: "chistoso",
|
|
10
|
-
contento: "contento",
|
|
11
|
-
creativo: "creativo",
|
|
12
|
-
dulce: "dulce",
|
|
13
|
-
divertido: "divertido",
|
|
14
|
-
encantador: "encantador",
|
|
15
|
-
energetico: "energetico",
|
|
16
|
-
entusiasta: "entusiasta",
|
|
17
|
-
esplendido: "esplendido",
|
|
18
|
-
fresco: "fresco",
|
|
19
|
-
gentil: "gentil",
|
|
20
|
-
gracioso: "gracioso",
|
|
21
|
-
habil: "habil",
|
|
22
|
-
hermoso: "hermoso",
|
|
23
|
-
honrado: "honrado",
|
|
24
|
-
inteligente: "inteligente",
|
|
25
|
-
jovial: "jovial",
|
|
26
|
-
jugueton: "jugueton",
|
|
27
|
-
leal: "leal",
|
|
28
|
-
liviano: "liviano",
|
|
29
|
-
luminoso: "luminoso",
|
|
30
|
-
maravilloso: "maravilloso",
|
|
31
|
-
modesto: "modesto",
|
|
32
|
-
noble: "noble",
|
|
33
|
-
optimista: "optimista",
|
|
34
|
-
paciente: "paciente",
|
|
35
|
-
poderoso: "poderoso",
|
|
36
|
-
radiante: "radiante",
|
|
37
|
-
resplandeciente: "resplandeciente",
|
|
38
|
-
sabio: "sabio",
|
|
39
|
-
sereno: "sereno",
|
|
40
|
-
simpatico: "simpatico",
|
|
41
|
-
soñador: "soñador",
|
|
42
|
-
talentoso: "talentoso",
|
|
43
|
-
tierno: "tierno",
|
|
44
|
-
tranquilo: "tranquilo",
|
|
45
|
-
valiente: "valiente",
|
|
46
|
-
vibrante: "vibrante",
|
|
47
|
-
amigable: "amigable",
|
|
48
|
-
bueno: "bueno",
|
|
49
|
-
celestial: "celestial",
|
|
50
|
-
deseable: "deseable",
|
|
51
|
-
elegante: "elegante",
|
|
52
|
-
especial: "especial",
|
|
53
|
-
excelente: "excelente",
|
|
54
|
-
fascinante: "fascinante",
|
|
55
|
-
feliz: "feliz",
|
|
56
|
-
generoso: "generoso",
|
|
57
|
-
honesto: "honesto",
|
|
58
|
-
iluminado: "iluminado",
|
|
59
|
-
increible: "increible",
|
|
60
|
-
inolvidable: "inolvidable",
|
|
61
|
-
magistral: "magistral",
|
|
62
|
-
pacifico: "pacifico",
|
|
63
|
-
placentero: "placentero",
|
|
64
|
-
positivo: "positivo",
|
|
65
|
-
radioso: "radioso",
|
|
66
|
-
relajado: "relajado",
|
|
67
|
-
satisfecho: "satisfecho",
|
|
68
|
-
sencillo: "sencillo",
|
|
69
|
-
sincero: "sincero",
|
|
70
|
-
solicito: "solicito",
|
|
71
|
-
sorprendente: "sorprendente",
|
|
72
|
-
tenaz: "tenaz",
|
|
73
|
-
triunfante: "triunfante",
|
|
74
|
-
unico: "unico",
|
|
75
|
-
vivaz: "vivaz",
|
|
76
|
-
volador: "volador",
|
|
77
|
-
zumbon: "zumbon",
|
|
78
|
-
armonico: "armonico",
|
|
79
|
-
añorable: "añorable",
|
|
80
|
-
bondadoso: "bondadoso",
|
|
81
|
-
capaz: "capaz",
|
|
82
|
-
cordial: "cordial",
|
|
83
|
-
encantado: "encantado",
|
|
84
|
-
entrañable: "entrañable",
|
|
85
|
-
fascinante: "fascinante",
|
|
86
|
-
fertil: "fertil",
|
|
87
|
-
gozoso: "gozoso",
|
|
88
|
-
habilidoso: "habilidoso",
|
|
89
|
-
honesto: "honesto",
|
|
90
|
-
ideal: "ideal",
|
|
91
|
-
inigualable: "inigualable",
|
|
92
|
-
jugueton: "jugueton",
|
|
93
|
-
luminoso: "luminoso",
|
|
94
|
-
majestuoso: "majestuoso",
|
|
95
|
-
optimista: "optimista",
|
|
96
|
-
radiante: "radiante",
|
|
97
|
-
resplandeciente: "resplandeciente",
|
|
98
|
-
soñador: "soñador",
|
|
99
|
-
talentoso: "talentoso",
|
|
100
|
-
valiente: "valiente",
|
|
101
|
-
vibrante: "vibrante"
|
|
102
|
-
},
|
|
103
|
-
colors: {
|
|
104
|
-
rojo: "rojo",
|
|
105
|
-
azul: "azul",
|
|
106
|
-
verde: "verde",
|
|
107
|
-
amarillo: "amarillo",
|
|
108
|
-
naranja: "naranja",
|
|
109
|
-
morado: "morado",
|
|
110
|
-
rosa: "rosa",
|
|
111
|
-
marron: "marron",
|
|
112
|
-
negro: "negro",
|
|
113
|
-
blanco: "blanco",
|
|
114
|
-
gris: "gris",
|
|
115
|
-
plateado: "plateado",
|
|
116
|
-
dorado: "dorado",
|
|
117
|
-
beige: "beige",
|
|
118
|
-
turquesa: "turquesa",
|
|
119
|
-
celeste: "celeste",
|
|
120
|
-
magenta: "magenta",
|
|
121
|
-
granate: "granate",
|
|
122
|
-
oliva: "oliva",
|
|
123
|
-
añil: "añil"
|
|
124
|
-
},
|
|
125
|
-
nouns: {
|
|
126
|
-
gato: "gato",
|
|
127
|
-
perro: "perro",
|
|
128
|
-
pajaro: "pajaro",
|
|
129
|
-
conejo: "conejo",
|
|
130
|
-
unicornio: "unicornio",
|
|
131
|
-
flor: "flor",
|
|
132
|
-
arbol: "arbol",
|
|
133
|
-
rio: "rio",
|
|
134
|
-
oceano: "oceano",
|
|
135
|
-
montaña: "montana",
|
|
136
|
-
nube: "nube",
|
|
137
|
-
sol: "sol",
|
|
138
|
-
luna: "luna",
|
|
139
|
-
estrella: "estrella",
|
|
140
|
-
mariposa: "mariposa",
|
|
141
|
-
abeja: "abeja",
|
|
142
|
-
brisa: "brisa",
|
|
143
|
-
ola: "ola",
|
|
144
|
-
lluvia: "lluvia",
|
|
145
|
-
nieve: "nieve",
|
|
146
|
-
hoja: "hoja",
|
|
147
|
-
piedra: "piedra",
|
|
148
|
-
arena: "arena",
|
|
149
|
-
barco: "barco",
|
|
150
|
-
puente: "puente",
|
|
151
|
-
castillo: "castillo",
|
|
152
|
-
sueño: "sueno",
|
|
153
|
-
fuego: "fuego",
|
|
154
|
-
llave: "llave",
|
|
155
|
-
libro: "libro",
|
|
156
|
-
pluma: "pluma",
|
|
157
|
-
silla: "silla",
|
|
158
|
-
mesa: "mesa",
|
|
159
|
-
ventana: "ventana",
|
|
160
|
-
puerta: "puerta",
|
|
161
|
-
espejo: "espejo",
|
|
162
|
-
luz: "luz",
|
|
163
|
-
sombra: "sombra",
|
|
164
|
-
sueño: "sueno",
|
|
165
|
-
sonrisa: "sonrisa",
|
|
166
|
-
risa: "risa",
|
|
167
|
-
amigo: "amigo",
|
|
168
|
-
amor: "amor",
|
|
169
|
-
esperanza: "esperanza",
|
|
170
|
-
alegria: "alegria",
|
|
171
|
-
paz: "paz",
|
|
172
|
-
corazon: "corazon",
|
|
173
|
-
alma: "alma",
|
|
174
|
-
arcoiris: "arcoiris",
|
|
175
|
-
estrella: "estrella",
|
|
176
|
-
planeta: "planeta",
|
|
177
|
-
galaxia: "galaxia",
|
|
178
|
-
mariposa: "mariposa",
|
|
179
|
-
jardin: "jardin",
|
|
180
|
-
bosque: "bosque",
|
|
181
|
-
prado: "prado",
|
|
182
|
-
campo: "campo",
|
|
183
|
-
viaje: "viaje",
|
|
184
|
-
aventura: "aventura",
|
|
185
|
-
magia: "magia",
|
|
186
|
-
fantasia: "fantasia",
|
|
187
|
-
imaginacion: "imaginacion",
|
|
188
|
-
susurro: "susurro",
|
|
189
|
-
risitas: "risitas",
|
|
190
|
-
tesoro: "tesoro",
|
|
191
|
-
maravilla: "maravilla",
|
|
192
|
-
serenidad: "serenidad",
|
|
193
|
-
silencio: "silencio",
|
|
194
|
-
armonia: "armonia",
|
|
195
|
-
inspiracion: "inspiracion",
|
|
196
|
-
creatividad: "creatividad",
|
|
197
|
-
soñador: "sonador",
|
|
198
|
-
explorador: "explorador",
|
|
199
|
-
bailarin: "bailarin",
|
|
200
|
-
artista: "artista",
|
|
201
|
-
historia: "historia",
|
|
202
|
-
memoria: "memoria",
|
|
203
|
-
sabiduria: "sabiduria",
|
|
204
|
-
alegria: "alegria",
|
|
205
|
-
felicidad: "felicidad",
|
|
206
|
-
amabilidad: "amabilidad",
|
|
207
|
-
gentileza: "gentileza",
|
|
208
|
-
gratitud: "gratitud",
|
|
209
|
-
libertad: "libertad",
|
|
210
|
-
paz: "paz",
|
|
211
|
-
esperanza: "esperanza",
|
|
212
|
-
fe: "fe",
|
|
213
|
-
unidad: "unidad",
|
|
214
|
-
atardecer: "atardecer",
|
|
215
|
-
amanecer: "amanecer",
|
|
216
|
-
crepusculo: "crepusculo",
|
|
217
|
-
medianoche: "medianoche"
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
module.exports = words;
|
package/dictionaries/index.js
DELETED
package/index.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
declare module 'human-ids' {
|
|
2
|
-
interface IdGeneratorSettings {
|
|
3
|
-
lang: string;
|
|
4
|
-
adjective?: boolean;
|
|
5
|
-
color?: boolean;
|
|
6
|
-
noun?: boolean;
|
|
7
|
-
randomOrder?: boolean;
|
|
8
|
-
separator?: string;
|
|
9
|
-
asObject?: boolean;
|
|
10
|
-
number?: {
|
|
11
|
-
min?: number;
|
|
12
|
-
max?: number;
|
|
13
|
-
completeWithZeros?: boolean;
|
|
14
|
-
};
|
|
15
|
-
dictionary?: {
|
|
16
|
-
adjectives: {
|
|
17
|
-
[key: string]: string[];
|
|
18
|
-
};
|
|
19
|
-
colors: {
|
|
20
|
-
[key: string]: string[];
|
|
21
|
-
};
|
|
22
|
-
nouns: {
|
|
23
|
-
[key: string]: string[];
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function generateId(settings?: IdGeneratorSettings): string;
|
|
29
|
-
|
|
30
|
-
export = generateId;
|
|
31
|
-
}
|
package/index.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
const dictionaries = require('./dictionaries');
|
|
2
|
-
|
|
3
|
-
const defaultSettings = {
|
|
4
|
-
lang: 'es',
|
|
5
|
-
adjective: true,
|
|
6
|
-
color: true,
|
|
7
|
-
noun: true,
|
|
8
|
-
randomOrder: false,
|
|
9
|
-
separator: '-',
|
|
10
|
-
asObject: false,
|
|
11
|
-
number: {
|
|
12
|
-
min: 0,
|
|
13
|
-
max: 999,
|
|
14
|
-
sets: 1,
|
|
15
|
-
completeWithZeros: false,
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
function generateId(userSettings = {}) {
|
|
20
|
-
const settings = {...defaultSettings, ...userSettings};
|
|
21
|
-
const lang = dictionaries[settings.lang] ? settings.lang : dictionaries[settings.lang?.split('-')[0]] ? settings.lang?.split('-')[0] : 'en';
|
|
22
|
-
const useAdjective = settings.adjective || false;
|
|
23
|
-
const useColor = settings.color || false;
|
|
24
|
-
const useNoun = settings.noun || false;
|
|
25
|
-
const numberMin = settings.number && settings.number.min !== undefined ? settings.number.min : 0;
|
|
26
|
-
const numberMax = settings.number && settings.number.max !== undefined ? settings.number.max : 999;
|
|
27
|
-
const numberSets = settings.number && settings.number.sets || 1;
|
|
28
|
-
const completeWithZeros = settings.number && settings.number.completeWithZeros || false;
|
|
29
|
-
|
|
30
|
-
function getRandomNumber(min, max) {
|
|
31
|
-
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function formatNumber(number) {
|
|
35
|
-
if (completeWithZeros) {
|
|
36
|
-
const maxNumberLength = numberMax.toString().length;
|
|
37
|
-
return number.toString().padStart(maxNumberLength, '0');
|
|
38
|
-
} else {
|
|
39
|
-
return number.toString();
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function getAdjectives() {
|
|
44
|
-
return settings.dictionary && settings.dictionary.adjectives ? settings.dictionary.adjectives : dictionaries[lang].adjectives;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function getColors() {
|
|
48
|
-
return settings.dictionary && settings.dictionary.colors ? settings.dictionary.colors : dictionaries[lang].colors;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function getNouns() {
|
|
52
|
-
return settings.dictionary && settings.dictionary.nouns ? settings.dictionary.nouns : dictionaries[lang].nouns;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const parts = [];
|
|
56
|
-
|
|
57
|
-
if (useAdjective) {
|
|
58
|
-
const adjectives = Object.values(getAdjectives());
|
|
59
|
-
const adjective = adjectives[Math.floor(Math.random() * adjectives.length)];
|
|
60
|
-
parts.push(adjective);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (useColor) {
|
|
64
|
-
const colors = Object.values(getColors());
|
|
65
|
-
const color = colors[Math.floor(Math.random() * colors.length)];
|
|
66
|
-
parts.push(color);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (useNoun) {
|
|
70
|
-
const nouns = Object.values(getNouns());
|
|
71
|
-
const noun = nouns[Math.floor(Math.random() * nouns.length)];
|
|
72
|
-
parts.push(noun);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
for (let i = 0; i < numberSets; i++) {
|
|
76
|
-
const number = getRandomNumber(numberMin, numberMax);
|
|
77
|
-
const formattedNumber = formatNumber(number);
|
|
78
|
-
parts.push(formattedNumber);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (settings.randomOrder) {
|
|
82
|
-
parts.sort(() => Math.random() - 0.5);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (settings.asObject) {
|
|
86
|
-
const object = {};
|
|
87
|
-
const keys = ['adjective', 'color', 'noun', 'number'];
|
|
88
|
-
parts.forEach((part, index) => {
|
|
89
|
-
object[keys[index]] = part;
|
|
90
|
-
});
|
|
91
|
-
return object;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return parts.join(`${settings.separator}`);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
module.exports = generateId;
|
package/tests/index.test.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
const generateId = require('../index');
|
|
2
|
-
|
|
3
|
-
describe('generateId', () => {
|
|
4
|
-
test('should return a unique ID', () => {
|
|
5
|
-
const testLength = 1000;
|
|
6
|
-
const settings = {
|
|
7
|
-
lang: 'en',
|
|
8
|
-
adjective: true,
|
|
9
|
-
color: true,
|
|
10
|
-
noun: true,
|
|
11
|
-
randomOrder: true,
|
|
12
|
-
separator: '-',
|
|
13
|
-
asObject: false,
|
|
14
|
-
number: {
|
|
15
|
-
min: 0,
|
|
16
|
-
max: 9999,
|
|
17
|
-
completeWithZeros: true
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const ids = new Set();
|
|
22
|
-
|
|
23
|
-
// Generate testLength IDs
|
|
24
|
-
for (let i = 0; i < testLength; i++) {
|
|
25
|
-
const id = generateId(settings);
|
|
26
|
-
|
|
27
|
-
console.log(`${i} ID: ${id}`);
|
|
28
|
-
ids.add(id);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Assert uniqueness
|
|
32
|
-
expect(ids.size).toBe(testLength);
|
|
33
|
-
});
|
|
34
|
-
});
|