human-ids 1.0.14 → 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.
@@ -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;
@@ -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;
@@ -1,9 +0,0 @@
1
- const en = require('./en');
2
- const es = require('./es');
3
-
4
- const dictionaries = {
5
- en,
6
- es
7
- };
8
-
9
- module.exports = dictionaries;
package/index.d.ts DELETED
@@ -1,34 +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
- semantics?: {
11
- [key: string]: string['noun' | 'adjective' | 'color' | 'number'];
12
- } | null;
13
- number?: {
14
- min?: number;
15
- max?: number;
16
- completeWithZeros?: boolean;
17
- };
18
- dictionary?: {
19
- adjectives: {
20
- [key: string]: string[];
21
- };
22
- colors: {
23
- [key: string]: string[];
24
- };
25
- nouns: {
26
- [key: string]: string[];
27
- }
28
- };
29
- }
30
-
31
- function generateId(settings?: IdGeneratorSettings): string;
32
-
33
- export = generateId;
34
- }
package/index.js DELETED
@@ -1,123 +0,0 @@
1
- const dictionaries = require('./dictionaries');
2
-
3
- const defaultSettings = {
4
- lang: 'en',
5
- adjective: true,
6
- color: true,
7
- noun: true,
8
- randomOrder: false,
9
- separator: '-',
10
- asObject: false,
11
- semantics: {
12
- es: ['noun', 'color', 'adjective', 'number'],
13
- en: ['adjective', 'color', 'noun', 'number'],
14
- },
15
- number: {
16
- min: 0,
17
- max: 999,
18
- sets: 1,
19
- completeWithZeros: false,
20
- },
21
- };
22
-
23
- function generateId(userSettings = {}) {
24
- const settings = { ...defaultSettings, ...userSettings };
25
- const lang = dictionaries[settings.lang]
26
- ? settings.lang
27
- : dictionaries[settings.lang?.split('-')[0]]
28
- ? settings.lang?.split('-')[0]
29
- : 'en';
30
- const useAdjective = settings.adjective || false;
31
- const useColor = settings.color || false;
32
- const useNoun = settings.noun || false;
33
- const numberMin =
34
- settings.number && settings.number.min !== undefined ? settings.number.min : 0;
35
- const numberMax =
36
- settings.number && settings.number.max !== undefined ? settings.number.max : 999;
37
- const numberSets = settings.number && settings.number.sets || 1;
38
- const completeWithZeros =
39
- settings.number && settings.number.completeWithZeros || false;
40
-
41
- function getRandomNumber(min, max) {
42
- return Math.floor(Math.random() * (max - min + 1)) + min;
43
- }
44
-
45
- function formatNumber(number) {
46
- if (completeWithZeros) {
47
- const maxNumberLength = numberMax.toString().length;
48
- return number.toString().padStart(maxNumberLength, '0');
49
- } else {
50
- return number.toString();
51
- }
52
- }
53
-
54
- function getAdjectives() {
55
- return settings.dictionary && settings.dictionary.adjectives
56
- ? settings.dictionary.adjectives
57
- : dictionaries[lang].adjectives;
58
- }
59
-
60
- function getColors() {
61
- return settings.dictionary && settings.dictionary.colors
62
- ? settings.dictionary.colors
63
- : dictionaries[lang].colors;
64
- }
65
-
66
- function getNouns() {
67
- return settings.dictionary && settings.dictionary.nouns
68
- ? settings.dictionary.nouns
69
- : dictionaries[lang].nouns;
70
- }
71
-
72
- const parts = {};
73
-
74
- if (useAdjective) {
75
- const adjectives = Object.values(getAdjectives());
76
- const adjective = adjectives[Math.floor(Math.random() * adjectives.length)];
77
- parts.adjective = adjective;
78
- }
79
-
80
- if (useColor) {
81
- const colors = Object.values(getColors());
82
- const color = colors[Math.floor(Math.random() * colors.length)];
83
- parts.color = color;
84
- }
85
-
86
- if (useNoun) {
87
- const nouns = Object.values(getNouns());
88
- const noun = nouns[Math.floor(Math.random() * nouns.length)];
89
- parts.noun = noun;
90
- }
91
-
92
- for (let i = 0; i < numberSets; i++) {
93
- const number = getRandomNumber(numberMin, numberMax);
94
- const formattedNumber = formatNumber(number);
95
- parts[`number${i + 1}`] = formattedNumber;
96
- }
97
-
98
- if (settings.randomOrder) {
99
- const keys = Object.keys(parts);
100
- const shuffledKeys = keys.sort(() => Math.random() - 0.5);
101
- const shuffledParts = [];
102
- for (const key of shuffledKeys) {
103
- shuffledParts.push(parts[key]);
104
- }
105
- return shuffledParts.join(`${settings.separator}`);
106
- }
107
-
108
- if (settings.asObject) {
109
- return parts;
110
- }
111
-
112
-
113
- let semantics = settings.semantics && settings.semantics[lang] || settings.semantics.en;
114
-
115
- const result = semantics.map((key) => {
116
- if (key !== 'number') return parts[key];
117
-
118
- return Object.values(parts).filter((part) => !isNaN(part)).join('-');
119
- });
120
- return result.join(`${settings.separator}`);
121
- }
122
-
123
- module.exports = generateId;
@@ -1,82 +0,0 @@
1
- const generateId = require('../index');
2
-
3
- describe('generateId', () => {
4
- test('should return a unique ID with all possible scenarios', () => {
5
- const allScenarios = [
6
- {
7
- lang: 'es',
8
- adjective: true,
9
- color: true,
10
- noun: true,
11
- randomOrder: false,
12
- separator: '-',
13
- asObject: false,
14
- number: {
15
- min: 0,
16
- max: 9999,
17
- sets: 1,
18
- completeWithZeros: true
19
- }
20
- },
21
- {
22
- lang: 'en',
23
- adjective: false,
24
- color: true,
25
- noun: true,
26
- randomOrder: true,
27
- separator: '_',
28
- asObject: true,
29
- number: {
30
- min: 1000,
31
- max: 9999,
32
- sets: 2,
33
- completeWithZeros: false
34
- }
35
- },
36
- // Add more scenarios here...
37
- ];
38
-
39
- const ids = new Set();
40
-
41
- for (const scenario of allScenarios) {
42
- const id = generateId(scenario);
43
-
44
- console.log(`Scenario: ${JSON.stringify(scenario, null, 2)}\nID: ${id}`);
45
- ids.add(id);
46
- }
47
-
48
- // Assert uniqueness for all scenarios
49
- expect(ids.size).toBe(allScenarios.length);
50
- });
51
-
52
- test('should return a unique ID with iterations', () => {
53
- const testLength = 1000;
54
- const settings = {
55
- lang: 'es',
56
- adjective: true,
57
- color: true,
58
- noun: true,
59
- randomOrder: true,
60
- separator: '-',
61
- asObject: false,
62
- number: {
63
- min: 0,
64
- max: 9999,
65
- completeWithZeros: true
66
- }
67
- };
68
-
69
- const ids = new Set();
70
-
71
- // Generate testLength IDs
72
- for (let i = 0; i < testLength; i++) {
73
- const id = generateId(settings);
74
-
75
- console.log(`${i} ID: ${id}`);
76
- ids.add(id);
77
- }
78
-
79
- // Assert uniqueness
80
- expect(ids.size).toBe(testLength);
81
- });
82
- });