namejam 0.1.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/dist/index.js ADDED
@@ -0,0 +1,337 @@
1
+ //#region src/words/adjectives.ts
2
+ const adjectives = [
3
+ "Accursed",
4
+ "Arcane",
5
+ "Befuddled",
6
+ "Bewildered",
7
+ "Blursed",
8
+ "Bogus",
9
+ "Caffeinated",
10
+ "Chaotic",
11
+ "Chunky",
12
+ "Cracked",
13
+ "Crunchy",
14
+ "Cryptic",
15
+ "Cursed",
16
+ "Damp",
17
+ "Deranged",
18
+ "Disheveled",
19
+ "Doomed",
20
+ "Elusive",
21
+ "Ethereal",
22
+ "Feral",
23
+ "Flummoxed",
24
+ "Flustered",
25
+ "Forbidden",
26
+ "Frantic",
27
+ "Furious",
28
+ "Glitchy",
29
+ "Gobsmacked",
30
+ "Goofy",
31
+ "Grumpy",
32
+ "Hapless",
33
+ "Haunted",
34
+ "Hollering",
35
+ "Invisible",
36
+ "Irate",
37
+ "Janky",
38
+ "Jittery",
39
+ "Klutzy",
40
+ "Lanky",
41
+ "Listless",
42
+ "Luminous",
43
+ "Lurking",
44
+ "Majestic",
45
+ "Maniacal",
46
+ "Manic",
47
+ "Mystical",
48
+ "Nefarious",
49
+ "Nervy",
50
+ "Notorious",
51
+ "Oblivious",
52
+ "Ominous",
53
+ "Ornery",
54
+ "Panicked",
55
+ "Peculiar",
56
+ "Phantom",
57
+ "Plucky",
58
+ "Prickly",
59
+ "Querulous",
60
+ "Rabid",
61
+ "Rambling",
62
+ "Reckless",
63
+ "Restless",
64
+ "Rogue",
65
+ "Scruffy",
66
+ "Smol",
67
+ "Sneaky",
68
+ "Snarky",
69
+ "Soggy",
70
+ "Spicy",
71
+ "Spooky",
72
+ "Suspicious",
73
+ "Tangled",
74
+ "Thunderous",
75
+ "Turbulent",
76
+ "Uncanny",
77
+ "Unhinged",
78
+ "Vexed",
79
+ "Volatile",
80
+ "Wacky",
81
+ "Wobbly",
82
+ "Zealous"
83
+ ];
84
+ //#endregion
85
+ //#region src/words/nouns.ts
86
+ const nouns = [
87
+ "Armadillo",
88
+ "Axolotl",
89
+ "Banshee",
90
+ "Basilisk",
91
+ "Blobfish",
92
+ "Boggart",
93
+ "Capybara",
94
+ "Chimera",
95
+ "Coyote",
96
+ "Cryptid",
97
+ "Ferret",
98
+ "Fetch",
99
+ "Flamingo",
100
+ "Gargoyle",
101
+ "Gecko",
102
+ "Goblin",
103
+ "Gremlin",
104
+ "Hedgehog",
105
+ "Imp",
106
+ "Jackalope",
107
+ "Kelpie",
108
+ "Kraken",
109
+ "Lemur",
110
+ "Mantis",
111
+ "Mongoose",
112
+ "Mothman",
113
+ "Narwhal",
114
+ "Okapi",
115
+ "Opossum",
116
+ "Pangolin",
117
+ "Penguin",
118
+ "Platypus",
119
+ "Poltergeist",
120
+ "Porcupine",
121
+ "Quokka",
122
+ "Raccoon",
123
+ "Revenant",
124
+ "Salamander",
125
+ "Specter",
126
+ "Tapir",
127
+ "Tardigrade",
128
+ "Thunderbird",
129
+ "Toad",
130
+ "Vulture",
131
+ "Walrus",
132
+ "Wendigo",
133
+ "Wombat",
134
+ "Wraith",
135
+ "Wyrm",
136
+ "Yak",
137
+ "Anomaly",
138
+ "Artifact",
139
+ "Bandit",
140
+ "Bauble",
141
+ "Biscuit",
142
+ "Blender",
143
+ "Burrito",
144
+ "Carbuncle",
145
+ "Cassette",
146
+ "Cauldron",
147
+ "Chalice",
148
+ "Cipher",
149
+ "Cloak",
150
+ "Contraption",
151
+ "Doohickey",
152
+ "Dumpling",
153
+ "Enigma",
154
+ "Fiasco",
155
+ "Gizmo",
156
+ "Grimoire",
157
+ "Harbinger",
158
+ "Lantern",
159
+ "Maverick",
160
+ "Menace",
161
+ "Monocle",
162
+ "Muffin",
163
+ "Noodle",
164
+ "Paradox",
165
+ "Parchment",
166
+ "Pickle",
167
+ "Pretzel",
168
+ "Relic",
169
+ "Rogue",
170
+ "Ruckus",
171
+ "Scroll",
172
+ "Sigil",
173
+ "Spatula",
174
+ "Talisman",
175
+ "Thingamajig",
176
+ "Toaster",
177
+ "Vagrant",
178
+ "Waffle",
179
+ "Warlock",
180
+ "Widget",
181
+ "Wizard"
182
+ ];
183
+ //#endregion
184
+ //#region src/words/tech.ts
185
+ const tech = [
186
+ "Axiom",
187
+ "Axton",
188
+ "Byton",
189
+ "Cipher",
190
+ "Cyron",
191
+ "Daxon",
192
+ "Dexon",
193
+ "Draxon",
194
+ "Exon",
195
+ "Hexar",
196
+ "Hexon",
197
+ "Helix",
198
+ "Ionex",
199
+ "Kryox",
200
+ "Kronos",
201
+ "Kronox",
202
+ "Lyron",
203
+ "Matrix",
204
+ "Naxon",
205
+ "Neoron",
206
+ "Nexar",
207
+ "Nexon",
208
+ "Nexus",
209
+ "Omicron",
210
+ "Phazon",
211
+ "Photex",
212
+ "Photon",
213
+ "Praxon",
214
+ "Proton",
215
+ "Pulsar",
216
+ "Quantum",
217
+ "Quasar",
218
+ "Synthex",
219
+ "Synthos",
220
+ "Tachyon",
221
+ "Vector",
222
+ "Vertex",
223
+ "Vexar",
224
+ "Vexon",
225
+ "Vorex",
226
+ "Vorton",
227
+ "Vortex",
228
+ "Xaeon",
229
+ "Xyron",
230
+ "Zenon",
231
+ "Zephon",
232
+ "Zeron",
233
+ "Zython"
234
+ ];
235
+ //#endregion
236
+ //#region src/words/verbs.ts
237
+ const verbs = [
238
+ "Banishing",
239
+ "Bumbling",
240
+ "Careening",
241
+ "Conjuring",
242
+ "Devouring",
243
+ "Enchanting",
244
+ "Fleeing",
245
+ "Fumbling",
246
+ "Glitching",
247
+ "Haunting",
248
+ "Howling",
249
+ "Jinxing",
250
+ "Lumbering",
251
+ "Lurking",
252
+ "Menacing",
253
+ "Napping",
254
+ "Obliterating",
255
+ "Pillaging",
256
+ "Questing",
257
+ "Rambling",
258
+ "Rampaging",
259
+ "Scheming",
260
+ "Shambling",
261
+ "Stampeding",
262
+ "Stumbling",
263
+ "Tinkering",
264
+ "Unleashing",
265
+ "Vanishing",
266
+ "Wobbling",
267
+ "Yelling"
268
+ ];
269
+ //#endregion
270
+ //#region src/format.ts
271
+ function titleCase(word) {
272
+ return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
273
+ }
274
+ function applyFormat(words, casing, separator, suffix) {
275
+ let result;
276
+ switch (casing) {
277
+ case "lowercase":
278
+ result = words.map((w) => w.toLowerCase()).join(separator);
279
+ break;
280
+ case "uppercase":
281
+ result = words.map((w) => w.toUpperCase()).join(separator);
282
+ break;
283
+ case "title":
284
+ result = words.map(titleCase).join(separator);
285
+ break;
286
+ case "pascal":
287
+ result = words.map(titleCase).join("");
288
+ break;
289
+ case "camel": {
290
+ const [first, ...rest] = words.map(titleCase);
291
+ result = (first ?? "").toLowerCase() + rest.join("");
292
+ break;
293
+ }
294
+ }
295
+ return result + suffix;
296
+ }
297
+ //#endregion
298
+ //#region src/generate.ts
299
+ function pickUnique(arr, n) {
300
+ const copy = [...arr];
301
+ for (let i = 0; i < n; i++) {
302
+ const j = i + Math.floor(Math.random() * (copy.length - i));
303
+ [copy[i], copy[j]] = [copy[j], copy[i]];
304
+ }
305
+ return copy.slice(0, n);
306
+ }
307
+ function buildWords(style) {
308
+ switch (style) {
309
+ case "adj-noun": return [pickUnique(adjectives, 1)[0], pickUnique(nouns, 1)[0]];
310
+ case "adj-adj-noun": {
311
+ const [adj1, adj2] = pickUnique(adjectives, 2);
312
+ return [
313
+ adj1,
314
+ adj2,
315
+ pickUnique(nouns, 1)[0]
316
+ ];
317
+ }
318
+ case "verb-noun": return [pickUnique(verbs, 1)[0], pickUnique(nouns, 1)[0]];
319
+ case "noun-noun": return pickUnique(nouns, 2);
320
+ case "adj-tech": return [pickUnique(adjectives, 1)[0], pickUnique(tech, 1)[0]];
321
+ case "tech": return [pickUnique(tech, 1)[0]];
322
+ }
323
+ }
324
+ function buildSuffix(digits) {
325
+ if (!digits) return "";
326
+ let s = "";
327
+ for (let i = 0; i < digits; i++) s += Math.floor(Math.random() * 10).toString();
328
+ return s;
329
+ }
330
+ function generateName(options = {}) {
331
+ const { style = "adj-noun", separator = "-", casing = "lowercase", suffix } = options;
332
+ return applyFormat(buildWords(style), casing, separator, buildSuffix(suffix));
333
+ }
334
+ //#endregion
335
+ export { generateName };
336
+
337
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/words/adjectives.ts","../src/words/nouns.ts","../src/words/tech.ts","../src/words/verbs.ts","../src/format.ts","../src/generate.ts"],"sourcesContent":["export const adjectives: string[] = [\n \"Accursed\",\n \"Arcane\",\n \"Befuddled\",\n \"Bewildered\",\n \"Blursed\",\n \"Bogus\",\n \"Caffeinated\",\n \"Chaotic\",\n \"Chunky\",\n \"Cracked\",\n \"Crunchy\",\n \"Cryptic\",\n \"Cursed\",\n \"Damp\",\n \"Deranged\",\n \"Disheveled\",\n \"Doomed\",\n \"Elusive\",\n \"Ethereal\",\n \"Feral\",\n \"Flummoxed\",\n \"Flustered\",\n \"Forbidden\",\n \"Frantic\",\n \"Furious\",\n \"Glitchy\",\n \"Gobsmacked\",\n \"Goofy\",\n \"Grumpy\",\n \"Hapless\",\n \"Haunted\",\n \"Hollering\",\n \"Invisible\",\n \"Irate\",\n \"Janky\",\n \"Jittery\",\n \"Klutzy\",\n \"Lanky\",\n \"Listless\",\n \"Luminous\",\n \"Lurking\",\n \"Majestic\",\n \"Maniacal\",\n \"Manic\",\n \"Mystical\",\n \"Nefarious\",\n \"Nervy\",\n \"Notorious\",\n \"Oblivious\",\n \"Ominous\",\n \"Ornery\",\n \"Panicked\",\n \"Peculiar\",\n \"Phantom\",\n \"Plucky\",\n \"Prickly\",\n \"Querulous\",\n \"Rabid\",\n \"Rambling\",\n \"Reckless\",\n \"Restless\",\n \"Rogue\",\n \"Scruffy\",\n \"Smol\",\n \"Sneaky\",\n \"Snarky\",\n \"Soggy\",\n \"Spicy\",\n \"Spooky\",\n \"Suspicious\",\n \"Tangled\",\n \"Thunderous\",\n \"Turbulent\",\n \"Uncanny\",\n \"Unhinged\",\n \"Vexed\",\n \"Volatile\",\n \"Wacky\",\n \"Wobbly\",\n \"Zealous\",\n];\n","export const nouns: string[] = [\n // creatures & cryptids\n \"Armadillo\",\n \"Axolotl\",\n \"Banshee\",\n \"Basilisk\",\n \"Blobfish\",\n \"Boggart\",\n \"Capybara\",\n \"Chimera\",\n \"Coyote\",\n \"Cryptid\",\n \"Ferret\",\n \"Fetch\",\n \"Flamingo\",\n \"Gargoyle\",\n \"Gecko\",\n \"Goblin\",\n \"Gremlin\",\n \"Hedgehog\",\n \"Imp\",\n \"Jackalope\",\n \"Kelpie\",\n \"Kraken\",\n \"Lemur\",\n \"Mantis\",\n \"Mongoose\",\n \"Mothman\",\n \"Narwhal\",\n \"Okapi\",\n \"Opossum\",\n \"Pangolin\",\n \"Penguin\",\n \"Platypus\",\n \"Poltergeist\",\n \"Porcupine\",\n \"Quokka\",\n \"Raccoon\",\n \"Revenant\",\n \"Salamander\",\n \"Specter\",\n \"Tapir\",\n \"Tardigrade\",\n \"Thunderbird\",\n \"Toad\",\n \"Vulture\",\n \"Walrus\",\n \"Wendigo\",\n \"Wombat\",\n \"Wraith\",\n \"Wyrm\",\n \"Yak\",\n // objects, food & archetypes\n \"Anomaly\",\n \"Artifact\",\n \"Bandit\",\n \"Bauble\",\n \"Biscuit\",\n \"Blender\",\n \"Burrito\",\n \"Carbuncle\",\n \"Cassette\",\n \"Cauldron\",\n \"Chalice\",\n \"Cipher\",\n \"Cloak\",\n \"Contraption\",\n \"Doohickey\",\n \"Dumpling\",\n \"Enigma\",\n \"Fiasco\",\n \"Gizmo\",\n \"Grimoire\",\n \"Harbinger\",\n \"Lantern\",\n \"Maverick\",\n \"Menace\",\n \"Monocle\",\n \"Muffin\",\n \"Noodle\",\n \"Paradox\",\n \"Parchment\",\n \"Pickle\",\n \"Pretzel\",\n \"Relic\",\n \"Rogue\",\n \"Ruckus\",\n \"Scroll\",\n \"Sigil\",\n \"Spatula\",\n \"Talisman\",\n \"Thingamajig\",\n \"Toaster\",\n \"Vagrant\",\n \"Waffle\",\n \"Warlock\",\n \"Widget\",\n \"Wizard\",\n];\n","export const tech: string[] = [\n \"Axiom\",\n \"Axton\",\n \"Byton\",\n \"Cipher\",\n \"Cyron\",\n \"Daxon\",\n \"Dexon\",\n \"Draxon\",\n \"Exon\",\n \"Hexar\",\n \"Hexon\",\n \"Helix\",\n \"Ionex\",\n \"Kryox\",\n \"Kronos\",\n \"Kronox\",\n \"Lyron\",\n \"Matrix\",\n \"Naxon\",\n \"Neoron\",\n \"Nexar\",\n \"Nexon\",\n \"Nexus\",\n \"Omicron\",\n \"Phazon\",\n \"Photex\",\n \"Photon\",\n \"Praxon\",\n \"Proton\",\n \"Pulsar\",\n \"Quantum\",\n \"Quasar\",\n \"Synthex\",\n \"Synthos\",\n \"Tachyon\",\n \"Vector\",\n \"Vertex\",\n \"Vexar\",\n \"Vexon\",\n \"Vorex\",\n \"Vorton\",\n \"Vortex\",\n \"Xaeon\",\n \"Xyron\",\n \"Zenon\",\n \"Zephon\",\n \"Zeron\",\n \"Zython\",\n];\n","export const verbs: string[] = [\n \"Banishing\",\n \"Bumbling\",\n \"Careening\",\n \"Conjuring\",\n \"Devouring\",\n \"Enchanting\",\n \"Fleeing\",\n \"Fumbling\",\n \"Glitching\",\n \"Haunting\",\n \"Howling\",\n \"Jinxing\",\n \"Lumbering\",\n \"Lurking\",\n \"Menacing\",\n \"Napping\",\n \"Obliterating\",\n \"Pillaging\",\n \"Questing\",\n \"Rambling\",\n \"Rampaging\",\n \"Scheming\",\n \"Shambling\",\n \"Stampeding\",\n \"Stumbling\",\n \"Tinkering\",\n \"Unleashing\",\n \"Vanishing\",\n \"Wobbling\",\n \"Yelling\",\n];\n","import type { Casing } from \"./types.ts\";\n\nfunction titleCase(word: string): string {\n return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();\n}\n\nexport function applyFormat(\n words: string[],\n casing: Casing,\n separator: string,\n suffix: string,\n): string {\n let result: string;\n\n switch (casing) {\n case \"lowercase\":\n result = words.map((w) => w.toLowerCase()).join(separator);\n break;\n case \"uppercase\":\n result = words.map((w) => w.toUpperCase()).join(separator);\n break;\n case \"title\":\n result = words.map(titleCase).join(separator);\n break;\n case \"pascal\":\n result = words.map(titleCase).join(\"\");\n break;\n case \"camel\": {\n const [first, ...rest] = words.map(titleCase);\n result = (first ?? \"\").toLowerCase() + rest.join(\"\");\n break;\n }\n }\n\n return result + suffix;\n}\n","import { adjectives } from \"./words/adjectives.ts\";\nimport { nouns } from \"./words/nouns.ts\";\nimport { tech } from \"./words/tech.ts\";\nimport { verbs } from \"./words/verbs.ts\";\nimport { applyFormat } from \"./format.ts\";\nimport type { GenerateOptions, Style } from \"./types.ts\";\n\nfunction pickUnique(arr: string[], n: number): string[] {\n const copy = [...arr];\n for (let i = 0; i < n; i++) {\n const j = i + Math.floor(Math.random() * (copy.length - i));\n [copy[i], copy[j]] = [copy[j]!, copy[i]!];\n }\n return copy.slice(0, n);\n}\n\nfunction buildWords(style: Style): string[] {\n switch (style) {\n case \"adj-noun\":\n return [pickUnique(adjectives, 1)[0]!, pickUnique(nouns, 1)[0]!];\n case \"adj-adj-noun\": {\n const [adj1, adj2] = pickUnique(adjectives, 2);\n return [adj1!, adj2!, pickUnique(nouns, 1)[0]!];\n }\n case \"verb-noun\":\n return [pickUnique(verbs, 1)[0]!, pickUnique(nouns, 1)[0]!];\n case \"noun-noun\":\n return pickUnique(nouns, 2);\n case \"adj-tech\":\n return [pickUnique(adjectives, 1)[0]!, pickUnique(tech, 1)[0]!];\n case \"tech\":\n return [pickUnique(tech, 1)[0]!];\n }\n}\n\nfunction buildSuffix(digits: number | undefined): string {\n if (!digits) return \"\";\n let s = \"\";\n for (let i = 0; i < digits; i++) {\n s += Math.floor(Math.random() * 10).toString();\n }\n return s;\n}\n\nexport function generateName(options: GenerateOptions = {}): string {\n const {\n style = \"adj-noun\",\n separator = \"-\",\n casing = \"lowercase\",\n suffix,\n } = options;\n\n const words = buildWords(style);\n const suffixStr = buildSuffix(suffix);\n return applyFormat(words, casing, separator, suffixStr);\n}\n"],"mappings":";AAAA,MAAa,aAAuB;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;ACjFA,MAAa,QAAkB;CAE7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;AClGA,MAAa,OAAiB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;ACjDA,MAAa,QAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;AC7BA,SAAS,UAAU,MAAsB;CACvC,OAAO,KAAK,OAAO,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC,EAAE,YAAY;AAClE;AAEA,SAAgB,YACd,OACA,QACA,WACA,QACQ;CACR,IAAI;CAEJ,QAAQ,QAAR;EACE,KAAK;GACH,SAAS,MAAM,KAAK,MAAM,EAAE,YAAY,CAAC,EAAE,KAAK,SAAS;GACzD;EACF,KAAK;GACH,SAAS,MAAM,KAAK,MAAM,EAAE,YAAY,CAAC,EAAE,KAAK,SAAS;GACzD;EACF,KAAK;GACH,SAAS,MAAM,IAAI,SAAS,EAAE,KAAK,SAAS;GAC5C;EACF,KAAK;GACH,SAAS,MAAM,IAAI,SAAS,EAAE,KAAK,EAAE;GACrC;EACF,KAAK,SAAS;GACZ,MAAM,CAAC,OAAO,GAAG,QAAQ,MAAM,IAAI,SAAS;GAC5C,UAAU,SAAS,IAAI,YAAY,IAAI,KAAK,KAAK,EAAE;GACnD;EACF;CACF;CAEA,OAAO,SAAS;AAClB;;;AC5BA,SAAS,WAAW,KAAe,GAAqB;CACtD,MAAM,OAAO,CAAC,GAAG,GAAG;CACpB,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KAAK;EAC1B,MAAM,IAAI,IAAI,KAAK,MAAM,KAAK,OAAO,KAAK,KAAK,SAAS,EAAE;EAC1D,CAAC,KAAK,IAAI,KAAK,MAAM,CAAC,KAAK,IAAK,KAAK,EAAG;CAC1C;CACA,OAAO,KAAK,MAAM,GAAG,CAAC;AACxB;AAEA,SAAS,WAAW,OAAwB;CAC1C,QAAQ,OAAR;EACE,KAAK,YACH,OAAO,CAAC,WAAW,YAAY,CAAC,EAAE,IAAK,WAAW,OAAO,CAAC,EAAE,EAAG;EACjE,KAAK,gBAAgB;GACnB,MAAM,CAAC,MAAM,QAAQ,WAAW,YAAY,CAAC;GAC7C,OAAO;IAAC;IAAO;IAAO,WAAW,OAAO,CAAC,EAAE;GAAG;EAChD;EACA,KAAK,aACH,OAAO,CAAC,WAAW,OAAO,CAAC,EAAE,IAAK,WAAW,OAAO,CAAC,EAAE,EAAG;EAC5D,KAAK,aACH,OAAO,WAAW,OAAO,CAAC;EAC5B,KAAK,YACH,OAAO,CAAC,WAAW,YAAY,CAAC,EAAE,IAAK,WAAW,MAAM,CAAC,EAAE,EAAG;EAChE,KAAK,QACH,OAAO,CAAC,WAAW,MAAM,CAAC,EAAE,EAAG;CACnC;AACF;AAEA,SAAS,YAAY,QAAoC;CACvD,IAAI,CAAC,QAAQ,OAAO;CACpB,IAAI,IAAI;CACR,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,KAC1B,KAAK,KAAK,MAAM,KAAK,OAAO,IAAI,EAAE,EAAE,SAAS;CAE/C,OAAO;AACT;AAEA,SAAgB,aAAa,UAA2B,CAAC,GAAW;CAClE,MAAM,EACJ,QAAQ,YACR,YAAY,KACZ,SAAS,aACT,WACE;CAIJ,OAAO,YAFO,WAAW,KAEF,GAAG,QAAQ,WADhB,YAAY,MACuB,CAAC;AACxD"}
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "namejam",
3
+ "version": "0.1.0",
4
+ "description": "Generate funny, unique usernames",
5
+ "type": "module",
6
+ "engines": {
7
+ "node": ">=22.6.0"
8
+ },
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "default": "./dist/index.cjs"
18
+ }
19
+ }
20
+ },
21
+ "bin": {
22
+ "namejam": "./dist/cli.js"
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "src"
27
+ ],
28
+ "scripts": {
29
+ "build": "tsdown",
30
+ "postbuild": "for f in dist/index-*.d.ts; do mv \"$f\" dist/index.d.ts; done && for f in dist/index-*.d.cts; do mv \"$f\" dist/index.d.cts; done",
31
+ "dev": "tsdown --watch",
32
+ "prepublishOnly": "yarn build",
33
+ "lint": "biome lint --write .",
34
+ "format": "biome format --write .",
35
+ "check": "biome check --write ."
36
+ },
37
+ "devDependencies": {
38
+ "@biomejs/biome": "^2.4.15",
39
+ "tsdown": "^0.12.6",
40
+ "typescript": "^5.8.3"
41
+ }
42
+ }
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env -S node --strip-types
2
+ import { generateName } from "../generate.ts";
3
+ import type { Casing, GenerateOptions, Style } from "../types.ts";
4
+
5
+ const STYLES: Style[] = ["adj-noun", "adj-adj-noun", "verb-noun", "noun-noun", "adj-tech", "tech"];
6
+ const CASINGS: Casing[] = ["lowercase", "uppercase", "camel", "pascal", "title"];
7
+
8
+ const HELP = `
9
+ namejam — generate funny, unique usernames
10
+
11
+ Usage: namejam [options]
12
+
13
+ Options:
14
+ --style <style> Word pattern (default: adj-noun)
15
+ ${STYLES.join(" | ")}
16
+ --separator <sep> Word separator string (default: -)
17
+ --casing <casing> Casing style (default: lowercase)
18
+ ${CASINGS.join(" | ")}
19
+ --suffix <digits> Append N random digits
20
+ --count <n> Print N names, one per line (default: 1)
21
+ -h, --help Show this help
22
+ -v, --version Show version
23
+ `.trim();
24
+
25
+ function parseArgs(argv: string[]): { opts: GenerateOptions; count: number } {
26
+ const opts: GenerateOptions = {};
27
+ let count = 1;
28
+ let i = 0;
29
+
30
+ while (i < argv.length) {
31
+ const arg = argv[i]!;
32
+
33
+ if (arg === "-h" || arg === "--help") {
34
+ console.log(HELP);
35
+ process.exit(0);
36
+ }
37
+
38
+ if (arg === "-v" || arg === "--version") {
39
+ console.log("0.1.0");
40
+ process.exit(0);
41
+ }
42
+
43
+ const next = argv[i + 1];
44
+
45
+ if (arg === "--style") {
46
+ if (!next || !STYLES.includes(next as Style)) {
47
+ die(`--style must be one of: ${STYLES.join(", ")}`);
48
+ }
49
+ opts.style = next as Style;
50
+ i += 2;
51
+ } else if (arg === "--separator") {
52
+ if (next === undefined) die("--separator requires a value");
53
+ opts.separator = next;
54
+ i += 2;
55
+ } else if (arg === "--casing") {
56
+ if (!next || !CASINGS.includes(next as Casing)) {
57
+ die(`--casing must be one of: ${CASINGS.join(", ")}`);
58
+ }
59
+ opts.casing = next as Casing;
60
+ i += 2;
61
+ } else if (arg === "--suffix") {
62
+ const n = Number(next);
63
+ if (!next || !Number.isInteger(n) || n < 1) die("--suffix requires a positive integer");
64
+ opts.suffix = n;
65
+ i += 2;
66
+ } else if (arg === "--count") {
67
+ const n = Number(next);
68
+ if (!next || !Number.isInteger(n) || n < 1) die("--count requires a positive integer");
69
+ count = n;
70
+ i += 2;
71
+ } else {
72
+ die(`Unknown option: ${arg}`);
73
+ }
74
+ }
75
+
76
+ return { opts, count };
77
+ }
78
+
79
+ function die(msg: string): never {
80
+ console.error(`namejam: ${msg}\nRun 'namejam --help' for usage.`);
81
+ process.exit(1);
82
+ }
83
+
84
+ const { opts, count } = parseArgs(process.argv.slice(2));
85
+ for (let i = 0; i < count; i++) {
86
+ console.log(generateName(opts));
87
+ }
package/src/format.ts ADDED
@@ -0,0 +1,36 @@
1
+ import type { Casing } from "./types.ts";
2
+
3
+ function titleCase(word: string): string {
4
+ return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
5
+ }
6
+
7
+ export function applyFormat(
8
+ words: string[],
9
+ casing: Casing,
10
+ separator: string,
11
+ suffix: string,
12
+ ): string {
13
+ let result: string;
14
+
15
+ switch (casing) {
16
+ case "lowercase":
17
+ result = words.map((w) => w.toLowerCase()).join(separator);
18
+ break;
19
+ case "uppercase":
20
+ result = words.map((w) => w.toUpperCase()).join(separator);
21
+ break;
22
+ case "title":
23
+ result = words.map(titleCase).join(separator);
24
+ break;
25
+ case "pascal":
26
+ result = words.map(titleCase).join("");
27
+ break;
28
+ case "camel": {
29
+ const [first, ...rest] = words.map(titleCase);
30
+ result = (first ?? "").toLowerCase() + rest.join("");
31
+ break;
32
+ }
33
+ }
34
+
35
+ return result + suffix;
36
+ }
@@ -0,0 +1,56 @@
1
+ import { adjectives } from "./words/adjectives.ts";
2
+ import { nouns } from "./words/nouns.ts";
3
+ import { tech } from "./words/tech.ts";
4
+ import { verbs } from "./words/verbs.ts";
5
+ import { applyFormat } from "./format.ts";
6
+ import type { GenerateOptions, Style } from "./types.ts";
7
+
8
+ function pickUnique(arr: string[], n: number): string[] {
9
+ const copy = [...arr];
10
+ for (let i = 0; i < n; i++) {
11
+ const j = i + Math.floor(Math.random() * (copy.length - i));
12
+ [copy[i], copy[j]] = [copy[j]!, copy[i]!];
13
+ }
14
+ return copy.slice(0, n);
15
+ }
16
+
17
+ function buildWords(style: Style): string[] {
18
+ switch (style) {
19
+ case "adj-noun":
20
+ return [pickUnique(adjectives, 1)[0]!, pickUnique(nouns, 1)[0]!];
21
+ case "adj-adj-noun": {
22
+ const [adj1, adj2] = pickUnique(adjectives, 2);
23
+ return [adj1!, adj2!, pickUnique(nouns, 1)[0]!];
24
+ }
25
+ case "verb-noun":
26
+ return [pickUnique(verbs, 1)[0]!, pickUnique(nouns, 1)[0]!];
27
+ case "noun-noun":
28
+ return pickUnique(nouns, 2);
29
+ case "adj-tech":
30
+ return [pickUnique(adjectives, 1)[0]!, pickUnique(tech, 1)[0]!];
31
+ case "tech":
32
+ return [pickUnique(tech, 1)[0]!];
33
+ }
34
+ }
35
+
36
+ function buildSuffix(digits: number | undefined): string {
37
+ if (!digits) return "";
38
+ let s = "";
39
+ for (let i = 0; i < digits; i++) {
40
+ s += Math.floor(Math.random() * 10).toString();
41
+ }
42
+ return s;
43
+ }
44
+
45
+ export function generateName(options: GenerateOptions = {}): string {
46
+ const {
47
+ style = "adj-noun",
48
+ separator = "-",
49
+ casing = "lowercase",
50
+ suffix,
51
+ } = options;
52
+
53
+ const words = buildWords(style);
54
+ const suffixStr = buildSuffix(suffix);
55
+ return applyFormat(words, casing, separator, suffixStr);
56
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { generateName } from "./generate.ts";
2
+ export type { GenerateOptions, Style, Casing } from "./types.ts";
package/src/types.ts ADDED
@@ -0,0 +1,25 @@
1
+ export type Style =
2
+ | "adj-noun"
3
+ | "adj-adj-noun"
4
+ | "verb-noun"
5
+ | "noun-noun"
6
+ | "adj-tech"
7
+ | "tech";
8
+
9
+ export type Casing =
10
+ | "lowercase"
11
+ | "uppercase"
12
+ | "camel"
13
+ | "pascal"
14
+ | "title";
15
+
16
+ export interface GenerateOptions {
17
+ /** Word pattern to use. Default: "adj-noun" */
18
+ style?: Style;
19
+ /** String placed between words. Default: "-" */
20
+ separator?: string;
21
+ /** Casing applied to the result. Default: "lowercase" */
22
+ casing?: Casing;
23
+ /** Append N random digits for extra uniqueness. */
24
+ suffix?: number;
25
+ }
@@ -0,0 +1,82 @@
1
+ export const adjectives: string[] = [
2
+ "Accursed",
3
+ "Arcane",
4
+ "Befuddled",
5
+ "Bewildered",
6
+ "Blursed",
7
+ "Bogus",
8
+ "Caffeinated",
9
+ "Chaotic",
10
+ "Chunky",
11
+ "Cracked",
12
+ "Crunchy",
13
+ "Cryptic",
14
+ "Cursed",
15
+ "Damp",
16
+ "Deranged",
17
+ "Disheveled",
18
+ "Doomed",
19
+ "Elusive",
20
+ "Ethereal",
21
+ "Feral",
22
+ "Flummoxed",
23
+ "Flustered",
24
+ "Forbidden",
25
+ "Frantic",
26
+ "Furious",
27
+ "Glitchy",
28
+ "Gobsmacked",
29
+ "Goofy",
30
+ "Grumpy",
31
+ "Hapless",
32
+ "Haunted",
33
+ "Hollering",
34
+ "Invisible",
35
+ "Irate",
36
+ "Janky",
37
+ "Jittery",
38
+ "Klutzy",
39
+ "Lanky",
40
+ "Listless",
41
+ "Luminous",
42
+ "Lurking",
43
+ "Majestic",
44
+ "Maniacal",
45
+ "Manic",
46
+ "Mystical",
47
+ "Nefarious",
48
+ "Nervy",
49
+ "Notorious",
50
+ "Oblivious",
51
+ "Ominous",
52
+ "Ornery",
53
+ "Panicked",
54
+ "Peculiar",
55
+ "Phantom",
56
+ "Plucky",
57
+ "Prickly",
58
+ "Querulous",
59
+ "Rabid",
60
+ "Rambling",
61
+ "Reckless",
62
+ "Restless",
63
+ "Rogue",
64
+ "Scruffy",
65
+ "Smol",
66
+ "Sneaky",
67
+ "Snarky",
68
+ "Soggy",
69
+ "Spicy",
70
+ "Spooky",
71
+ "Suspicious",
72
+ "Tangled",
73
+ "Thunderous",
74
+ "Turbulent",
75
+ "Uncanny",
76
+ "Unhinged",
77
+ "Vexed",
78
+ "Volatile",
79
+ "Wacky",
80
+ "Wobbly",
81
+ "Zealous",
82
+ ];