@wry-smile/lexid 0.0.0-stage → 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.
@@ -0,0 +1,246 @@
1
+ import { C as categories, E as animals, O as adjectives, S as colors, T as architecture, _ as gemstones, a as space, b as domains, c as nouns, f as modifiers, i as technologies, l as nature, o as seasons, p as materials, s as plants, t as weather, u as mythology, v as flowers, w as birds, y as elements } from "./dictionaries-DqOja3dc.mjs";
2
+ import { random } from "./random.mjs";
3
+ //#region src/patterns/five-segment.ts
4
+ const fiveSegmentPatterns = /* @__PURE__ */ Object.freeze([
5
+ /* @__PURE__ */ Object.freeze([
6
+ adjectives,
7
+ colors,
8
+ nature,
9
+ animals
10
+ ]),
11
+ /* @__PURE__ */ Object.freeze([
12
+ adjectives,
13
+ colors,
14
+ nature,
15
+ birds
16
+ ]),
17
+ /* @__PURE__ */ Object.freeze([
18
+ adjectives,
19
+ colors,
20
+ materials,
21
+ nouns
22
+ ]),
23
+ /* @__PURE__ */ Object.freeze([
24
+ adjectives,
25
+ colors,
26
+ space,
27
+ nouns
28
+ ]),
29
+ /* @__PURE__ */ Object.freeze([
30
+ adjectives,
31
+ materials,
32
+ architecture,
33
+ modifiers
34
+ ]),
35
+ /* @__PURE__ */ Object.freeze([
36
+ adjectives,
37
+ seasons,
38
+ colors,
39
+ birds
40
+ ]),
41
+ /* @__PURE__ */ Object.freeze([
42
+ adjectives,
43
+ colors,
44
+ technologies,
45
+ domains
46
+ ]),
47
+ /* @__PURE__ */ Object.freeze([
48
+ adjectives,
49
+ categories,
50
+ domains,
51
+ modifiers
52
+ ]),
53
+ /* @__PURE__ */ Object.freeze([
54
+ adjectives,
55
+ technologies,
56
+ domains,
57
+ modifiers
58
+ ]),
59
+ /* @__PURE__ */ Object.freeze([
60
+ adjectives,
61
+ seasons,
62
+ nature,
63
+ animals
64
+ ]),
65
+ /* @__PURE__ */ Object.freeze([
66
+ adjectives,
67
+ seasons,
68
+ nature,
69
+ birds
70
+ ]),
71
+ /* @__PURE__ */ Object.freeze([
72
+ adjectives,
73
+ weather,
74
+ nature,
75
+ nouns
76
+ ]),
77
+ /* @__PURE__ */ Object.freeze([
78
+ adjectives,
79
+ space,
80
+ technologies,
81
+ domains
82
+ ]),
83
+ /* @__PURE__ */ Object.freeze([
84
+ adjectives,
85
+ nature,
86
+ animals,
87
+ modifiers
88
+ ]),
89
+ /* @__PURE__ */ Object.freeze([
90
+ adjectives,
91
+ colors,
92
+ mythology,
93
+ modifiers
94
+ ])
95
+ ]);
96
+ //#endregion
97
+ //#region src/patterns/four-segment.ts
98
+ const fourSegmentPatterns = /* @__PURE__ */ Object.freeze([
99
+ /* @__PURE__ */ Object.freeze([
100
+ adjectives,
101
+ colors,
102
+ animals
103
+ ]),
104
+ /* @__PURE__ */ Object.freeze([
105
+ adjectives,
106
+ colors,
107
+ birds
108
+ ]),
109
+ /* @__PURE__ */ Object.freeze([
110
+ adjectives,
111
+ colors,
112
+ flowers
113
+ ]),
114
+ /* @__PURE__ */ Object.freeze([
115
+ adjectives,
116
+ colors,
117
+ plants
118
+ ]),
119
+ /* @__PURE__ */ Object.freeze([
120
+ adjectives,
121
+ nature,
122
+ animals
123
+ ]),
124
+ /* @__PURE__ */ Object.freeze([
125
+ adjectives,
126
+ nature,
127
+ nouns
128
+ ]),
129
+ /* @__PURE__ */ Object.freeze([
130
+ adjectives,
131
+ elements,
132
+ animals
133
+ ]),
134
+ /* @__PURE__ */ Object.freeze([
135
+ adjectives,
136
+ elements,
137
+ nouns
138
+ ]),
139
+ /* @__PURE__ */ Object.freeze([
140
+ adjectives,
141
+ technologies,
142
+ domains
143
+ ]),
144
+ /* @__PURE__ */ Object.freeze([
145
+ adjectives,
146
+ categories,
147
+ domains
148
+ ]),
149
+ /* @__PURE__ */ Object.freeze([
150
+ adjectives,
151
+ domains,
152
+ modifiers
153
+ ]),
154
+ /* @__PURE__ */ Object.freeze([
155
+ adjectives,
156
+ materials,
157
+ nouns
158
+ ]),
159
+ /* @__PURE__ */ Object.freeze([
160
+ adjectives,
161
+ space,
162
+ nouns
163
+ ]),
164
+ /* @__PURE__ */ Object.freeze([
165
+ adjectives,
166
+ weather,
167
+ nouns
168
+ ]),
169
+ /* @__PURE__ */ Object.freeze([
170
+ adjectives,
171
+ seasons,
172
+ animals
173
+ ]),
174
+ /* @__PURE__ */ Object.freeze([
175
+ adjectives,
176
+ weather,
177
+ birds
178
+ ]),
179
+ /* @__PURE__ */ Object.freeze([
180
+ adjectives,
181
+ gemstones,
182
+ nouns
183
+ ]),
184
+ /* @__PURE__ */ Object.freeze([
185
+ adjectives,
186
+ mythology,
187
+ nouns
188
+ ]),
189
+ /* @__PURE__ */ Object.freeze([
190
+ adjectives,
191
+ colors,
192
+ architecture
193
+ ]),
194
+ /* @__PURE__ */ Object.freeze([
195
+ colors,
196
+ nature,
197
+ animals
198
+ ]),
199
+ /* @__PURE__ */ Object.freeze([
200
+ colors,
201
+ materials,
202
+ nouns
203
+ ]),
204
+ /* @__PURE__ */ Object.freeze([
205
+ colors,
206
+ space,
207
+ nouns
208
+ ]),
209
+ /* @__PURE__ */ Object.freeze([
210
+ seasons,
211
+ nature,
212
+ animals
213
+ ]),
214
+ /* @__PURE__ */ Object.freeze([
215
+ technologies,
216
+ domains,
217
+ modifiers
218
+ ])
219
+ ]);
220
+ //#endregion
221
+ //#region src/patterns/pick-pattern.ts
222
+ function pickPattern(patterns) {
223
+ if (!Array.isArray(patterns)) throw new TypeError("patterns must be an array");
224
+ const valid = [];
225
+ for (let index = 0; index < patterns.length; index++) {
226
+ if (!Object.hasOwn(patterns, index)) continue;
227
+ const pattern = patterns[index];
228
+ if (!Array.isArray(pattern) || pattern.length === 0) continue;
229
+ let usable = true;
230
+ for (let i = 0; i < pattern.length; i++) {
231
+ const dictionary = pattern[i];
232
+ if (!Object.hasOwn(pattern, i) || !Array.isArray(dictionary) || dictionary.length === 0) {
233
+ usable = false;
234
+ break;
235
+ }
236
+ }
237
+ if (usable) valid.push(pattern);
238
+ }
239
+ if (valid.length === 0) throw new RangeError("patterns contains no nonempty template with nonempty dictionaries");
240
+ return random.pick(valid);
241
+ }
242
+ //#endregion
243
+ //#region src/patterns/index.ts
244
+ const defaultPatterns = /* @__PURE__ */ Object.freeze([...fourSegmentPatterns, ...fiveSegmentPatterns]);
245
+ //#endregion
246
+ export { fiveSegmentPatterns as i, pickPattern as n, fourSegmentPatterns as r, defaultPatterns as t };
@@ -0,0 +1,269 @@
1
+ const require_dictionaries = require("./dictionaries-DwfVfnJX.cjs");
2
+ const require_random = require("./random.cjs");
3
+ //#region src/patterns/five-segment.ts
4
+ const fiveSegmentPatterns = /* @__PURE__ */ Object.freeze([
5
+ /* @__PURE__ */ Object.freeze([
6
+ require_dictionaries.adjectives,
7
+ require_dictionaries.colors,
8
+ require_dictionaries.nature,
9
+ require_dictionaries.animals
10
+ ]),
11
+ /* @__PURE__ */ Object.freeze([
12
+ require_dictionaries.adjectives,
13
+ require_dictionaries.colors,
14
+ require_dictionaries.nature,
15
+ require_dictionaries.birds
16
+ ]),
17
+ /* @__PURE__ */ Object.freeze([
18
+ require_dictionaries.adjectives,
19
+ require_dictionaries.colors,
20
+ require_dictionaries.materials,
21
+ require_dictionaries.nouns
22
+ ]),
23
+ /* @__PURE__ */ Object.freeze([
24
+ require_dictionaries.adjectives,
25
+ require_dictionaries.colors,
26
+ require_dictionaries.space,
27
+ require_dictionaries.nouns
28
+ ]),
29
+ /* @__PURE__ */ Object.freeze([
30
+ require_dictionaries.adjectives,
31
+ require_dictionaries.materials,
32
+ require_dictionaries.architecture,
33
+ require_dictionaries.modifiers
34
+ ]),
35
+ /* @__PURE__ */ Object.freeze([
36
+ require_dictionaries.adjectives,
37
+ require_dictionaries.seasons,
38
+ require_dictionaries.colors,
39
+ require_dictionaries.birds
40
+ ]),
41
+ /* @__PURE__ */ Object.freeze([
42
+ require_dictionaries.adjectives,
43
+ require_dictionaries.colors,
44
+ require_dictionaries.technologies,
45
+ require_dictionaries.domains
46
+ ]),
47
+ /* @__PURE__ */ Object.freeze([
48
+ require_dictionaries.adjectives,
49
+ require_dictionaries.categories,
50
+ require_dictionaries.domains,
51
+ require_dictionaries.modifiers
52
+ ]),
53
+ /* @__PURE__ */ Object.freeze([
54
+ require_dictionaries.adjectives,
55
+ require_dictionaries.technologies,
56
+ require_dictionaries.domains,
57
+ require_dictionaries.modifiers
58
+ ]),
59
+ /* @__PURE__ */ Object.freeze([
60
+ require_dictionaries.adjectives,
61
+ require_dictionaries.seasons,
62
+ require_dictionaries.nature,
63
+ require_dictionaries.animals
64
+ ]),
65
+ /* @__PURE__ */ Object.freeze([
66
+ require_dictionaries.adjectives,
67
+ require_dictionaries.seasons,
68
+ require_dictionaries.nature,
69
+ require_dictionaries.birds
70
+ ]),
71
+ /* @__PURE__ */ Object.freeze([
72
+ require_dictionaries.adjectives,
73
+ require_dictionaries.weather,
74
+ require_dictionaries.nature,
75
+ require_dictionaries.nouns
76
+ ]),
77
+ /* @__PURE__ */ Object.freeze([
78
+ require_dictionaries.adjectives,
79
+ require_dictionaries.space,
80
+ require_dictionaries.technologies,
81
+ require_dictionaries.domains
82
+ ]),
83
+ /* @__PURE__ */ Object.freeze([
84
+ require_dictionaries.adjectives,
85
+ require_dictionaries.nature,
86
+ require_dictionaries.animals,
87
+ require_dictionaries.modifiers
88
+ ]),
89
+ /* @__PURE__ */ Object.freeze([
90
+ require_dictionaries.adjectives,
91
+ require_dictionaries.colors,
92
+ require_dictionaries.mythology,
93
+ require_dictionaries.modifiers
94
+ ])
95
+ ]);
96
+ //#endregion
97
+ //#region src/patterns/four-segment.ts
98
+ const fourSegmentPatterns = /* @__PURE__ */ Object.freeze([
99
+ /* @__PURE__ */ Object.freeze([
100
+ require_dictionaries.adjectives,
101
+ require_dictionaries.colors,
102
+ require_dictionaries.animals
103
+ ]),
104
+ /* @__PURE__ */ Object.freeze([
105
+ require_dictionaries.adjectives,
106
+ require_dictionaries.colors,
107
+ require_dictionaries.birds
108
+ ]),
109
+ /* @__PURE__ */ Object.freeze([
110
+ require_dictionaries.adjectives,
111
+ require_dictionaries.colors,
112
+ require_dictionaries.flowers
113
+ ]),
114
+ /* @__PURE__ */ Object.freeze([
115
+ require_dictionaries.adjectives,
116
+ require_dictionaries.colors,
117
+ require_dictionaries.plants
118
+ ]),
119
+ /* @__PURE__ */ Object.freeze([
120
+ require_dictionaries.adjectives,
121
+ require_dictionaries.nature,
122
+ require_dictionaries.animals
123
+ ]),
124
+ /* @__PURE__ */ Object.freeze([
125
+ require_dictionaries.adjectives,
126
+ require_dictionaries.nature,
127
+ require_dictionaries.nouns
128
+ ]),
129
+ /* @__PURE__ */ Object.freeze([
130
+ require_dictionaries.adjectives,
131
+ require_dictionaries.elements,
132
+ require_dictionaries.animals
133
+ ]),
134
+ /* @__PURE__ */ Object.freeze([
135
+ require_dictionaries.adjectives,
136
+ require_dictionaries.elements,
137
+ require_dictionaries.nouns
138
+ ]),
139
+ /* @__PURE__ */ Object.freeze([
140
+ require_dictionaries.adjectives,
141
+ require_dictionaries.technologies,
142
+ require_dictionaries.domains
143
+ ]),
144
+ /* @__PURE__ */ Object.freeze([
145
+ require_dictionaries.adjectives,
146
+ require_dictionaries.categories,
147
+ require_dictionaries.domains
148
+ ]),
149
+ /* @__PURE__ */ Object.freeze([
150
+ require_dictionaries.adjectives,
151
+ require_dictionaries.domains,
152
+ require_dictionaries.modifiers
153
+ ]),
154
+ /* @__PURE__ */ Object.freeze([
155
+ require_dictionaries.adjectives,
156
+ require_dictionaries.materials,
157
+ require_dictionaries.nouns
158
+ ]),
159
+ /* @__PURE__ */ Object.freeze([
160
+ require_dictionaries.adjectives,
161
+ require_dictionaries.space,
162
+ require_dictionaries.nouns
163
+ ]),
164
+ /* @__PURE__ */ Object.freeze([
165
+ require_dictionaries.adjectives,
166
+ require_dictionaries.weather,
167
+ require_dictionaries.nouns
168
+ ]),
169
+ /* @__PURE__ */ Object.freeze([
170
+ require_dictionaries.adjectives,
171
+ require_dictionaries.seasons,
172
+ require_dictionaries.animals
173
+ ]),
174
+ /* @__PURE__ */ Object.freeze([
175
+ require_dictionaries.adjectives,
176
+ require_dictionaries.weather,
177
+ require_dictionaries.birds
178
+ ]),
179
+ /* @__PURE__ */ Object.freeze([
180
+ require_dictionaries.adjectives,
181
+ require_dictionaries.gemstones,
182
+ require_dictionaries.nouns
183
+ ]),
184
+ /* @__PURE__ */ Object.freeze([
185
+ require_dictionaries.adjectives,
186
+ require_dictionaries.mythology,
187
+ require_dictionaries.nouns
188
+ ]),
189
+ /* @__PURE__ */ Object.freeze([
190
+ require_dictionaries.adjectives,
191
+ require_dictionaries.colors,
192
+ require_dictionaries.architecture
193
+ ]),
194
+ /* @__PURE__ */ Object.freeze([
195
+ require_dictionaries.colors,
196
+ require_dictionaries.nature,
197
+ require_dictionaries.animals
198
+ ]),
199
+ /* @__PURE__ */ Object.freeze([
200
+ require_dictionaries.colors,
201
+ require_dictionaries.materials,
202
+ require_dictionaries.nouns
203
+ ]),
204
+ /* @__PURE__ */ Object.freeze([
205
+ require_dictionaries.colors,
206
+ require_dictionaries.space,
207
+ require_dictionaries.nouns
208
+ ]),
209
+ /* @__PURE__ */ Object.freeze([
210
+ require_dictionaries.seasons,
211
+ require_dictionaries.nature,
212
+ require_dictionaries.animals
213
+ ]),
214
+ /* @__PURE__ */ Object.freeze([
215
+ require_dictionaries.technologies,
216
+ require_dictionaries.domains,
217
+ require_dictionaries.modifiers
218
+ ])
219
+ ]);
220
+ //#endregion
221
+ //#region src/patterns/pick-pattern.ts
222
+ function pickPattern(patterns) {
223
+ if (!Array.isArray(patterns)) throw new TypeError("patterns must be an array");
224
+ const valid = [];
225
+ for (let index = 0; index < patterns.length; index++) {
226
+ if (!Object.hasOwn(patterns, index)) continue;
227
+ const pattern = patterns[index];
228
+ if (!Array.isArray(pattern) || pattern.length === 0) continue;
229
+ let usable = true;
230
+ for (let i = 0; i < pattern.length; i++) {
231
+ const dictionary = pattern[i];
232
+ if (!Object.hasOwn(pattern, i) || !Array.isArray(dictionary) || dictionary.length === 0) {
233
+ usable = false;
234
+ break;
235
+ }
236
+ }
237
+ if (usable) valid.push(pattern);
238
+ }
239
+ if (valid.length === 0) throw new RangeError("patterns contains no nonempty template with nonempty dictionaries");
240
+ return require_random.random.pick(valid);
241
+ }
242
+ //#endregion
243
+ //#region src/patterns/index.ts
244
+ const defaultPatterns = /* @__PURE__ */ Object.freeze([...fourSegmentPatterns, ...fiveSegmentPatterns]);
245
+ //#endregion
246
+ Object.defineProperty(exports, "defaultPatterns", {
247
+ enumerable: true,
248
+ get: function() {
249
+ return defaultPatterns;
250
+ }
251
+ });
252
+ Object.defineProperty(exports, "fiveSegmentPatterns", {
253
+ enumerable: true,
254
+ get: function() {
255
+ return fiveSegmentPatterns;
256
+ }
257
+ });
258
+ Object.defineProperty(exports, "fourSegmentPatterns", {
259
+ enumerable: true,
260
+ get: function() {
261
+ return fourSegmentPatterns;
262
+ }
263
+ });
264
+ Object.defineProperty(exports, "pickPattern", {
265
+ enumerable: true,
266
+ get: function() {
267
+ return pickPattern;
268
+ }
269
+ });
@@ -0,0 +1,6 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_patterns = require("./patterns-QE6RAPxp.cjs");
3
+ exports.defaultPatterns = require_patterns.defaultPatterns;
4
+ exports.fiveSegmentPatterns = require_patterns.fiveSegmentPatterns;
5
+ exports.fourSegmentPatterns = require_patterns.fourSegmentPatterns;
6
+ exports.pickPattern = require_patterns.pickPattern;
@@ -0,0 +1,2 @@
1
+ import { i as fiveSegmentPatterns, n as pickPattern, r as fourSegmentPatterns, t as defaultPatterns } from "./index-D0Yd4QNB.cjs";
2
+ export { defaultPatterns, fiveSegmentPatterns, fourSegmentPatterns, pickPattern };
@@ -0,0 +1,2 @@
1
+ import { i as fiveSegmentPatterns, n as pickPattern, r as fourSegmentPatterns, t as defaultPatterns } from "./index-Bd4TyP0I.mjs";
2
+ export { defaultPatterns, fiveSegmentPatterns, fourSegmentPatterns, pickPattern };
@@ -0,0 +1,2 @@
1
+ import { i as fiveSegmentPatterns, n as pickPattern, r as fourSegmentPatterns, t as defaultPatterns } from "./patterns-DUQti-VI.mjs";
2
+ export { defaultPatterns, fiveSegmentPatterns, fourSegmentPatterns, pickPattern };
@@ -0,0 +1,43 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/random.ts
3
+ const letters = "abcdefghijklmnopqrstuvwxyz";
4
+ const digits = "0123456789";
5
+ const wordRange = 2 ** 32;
6
+ const sampleRange = 2 ** 48;
7
+ function int(max) {
8
+ if (!Number.isSafeInteger(max) || max <= 0 || max >= sampleRange) throw new RangeError("max must be a positive integer less than 2^48");
9
+ const crypto = globalThis.crypto;
10
+ if (typeof crypto?.getRandomValues !== "function") throw new Error("LexID requires crypto.getRandomValues for secure randomness");
11
+ const words = new Uint32Array(2);
12
+ const limit = sampleRange - sampleRange % max;
13
+ let sample;
14
+ do {
15
+ crypto.getRandomValues(words);
16
+ sample = (words[0] & 65535) * wordRange + words[1];
17
+ } while (sample >= limit);
18
+ return sample % max;
19
+ }
20
+ function pick(items) {
21
+ if (!Array.isArray(items) || items.length === 0) throw new TypeError("items must be a nonempty array");
22
+ for (let index = 0; index < items.length; index++) if (!Object.hasOwn(items, index)) throw new TypeError(`items[${index}] must not be a hole`);
23
+ return items[int(items.length)];
24
+ }
25
+ function string(alphabet, length) {
26
+ if (typeof alphabet !== "string" || alphabet.length === 0) throw new TypeError("alphabet must be a nonempty string");
27
+ if (!Number.isSafeInteger(length) || length < 0) throw new RangeError("length must be a nonnegative safe integer");
28
+ const characters = [...new Set(alphabet)];
29
+ let result = "";
30
+ for (let index = 0; index < length; index++) result += characters[int(characters.length)];
31
+ return result;
32
+ }
33
+ const random = /* @__PURE__ */ Object.freeze({
34
+ int,
35
+ pick,
36
+ string,
37
+ numeric: (length) => string(digits, length),
38
+ alphabetic: (length) => string(letters, length),
39
+ alphanumeric: (length) => string(letters + digits, length),
40
+ hexadecimal: (length) => string(digits + "abcdef", length)
41
+ });
42
+ //#endregion
43
+ exports.random = random;
@@ -0,0 +1,6 @@
1
+ import { o as RandomUtils } from "./types-CHH8wNDe.cjs";
2
+
3
+ //#region src/random.d.ts
4
+ declare const random: RandomUtils;
5
+ //#endregion
6
+ export { random };
@@ -0,0 +1,6 @@
1
+ import { o as RandomUtils } from "./types-BMRtYBrz.mjs";
2
+
3
+ //#region src/random.d.ts
4
+ declare const random: RandomUtils;
5
+ //#endregion
6
+ export { random };
@@ -0,0 +1,42 @@
1
+ //#region src/random.ts
2
+ const letters = "abcdefghijklmnopqrstuvwxyz";
3
+ const digits = "0123456789";
4
+ const wordRange = 2 ** 32;
5
+ const sampleRange = 2 ** 48;
6
+ function int(max) {
7
+ if (!Number.isSafeInteger(max) || max <= 0 || max >= sampleRange) throw new RangeError("max must be a positive integer less than 2^48");
8
+ const crypto = globalThis.crypto;
9
+ if (typeof crypto?.getRandomValues !== "function") throw new Error("LexID requires crypto.getRandomValues for secure randomness");
10
+ const words = new Uint32Array(2);
11
+ const limit = sampleRange - sampleRange % max;
12
+ let sample;
13
+ do {
14
+ crypto.getRandomValues(words);
15
+ sample = (words[0] & 65535) * wordRange + words[1];
16
+ } while (sample >= limit);
17
+ return sample % max;
18
+ }
19
+ function pick(items) {
20
+ if (!Array.isArray(items) || items.length === 0) throw new TypeError("items must be a nonempty array");
21
+ for (let index = 0; index < items.length; index++) if (!Object.hasOwn(items, index)) throw new TypeError(`items[${index}] must not be a hole`);
22
+ return items[int(items.length)];
23
+ }
24
+ function string(alphabet, length) {
25
+ if (typeof alphabet !== "string" || alphabet.length === 0) throw new TypeError("alphabet must be a nonempty string");
26
+ if (!Number.isSafeInteger(length) || length < 0) throw new RangeError("length must be a nonnegative safe integer");
27
+ const characters = [...new Set(alphabet)];
28
+ let result = "";
29
+ for (let index = 0; index < length; index++) result += characters[int(characters.length)];
30
+ return result;
31
+ }
32
+ const random = /* @__PURE__ */ Object.freeze({
33
+ int,
34
+ pick,
35
+ string,
36
+ numeric: (length) => string(digits, length),
37
+ alphabetic: (length) => string(letters, length),
38
+ alphanumeric: (length) => string(letters + digits, length),
39
+ hexadecimal: (length) => string(digits + "abcdef", length)
40
+ });
41
+ //#endregion
42
+ export { random };
@@ -0,0 +1,35 @@
1
+ //#region src/types.d.ts
2
+ type Dictionary = readonly string[];
3
+ type Segments = readonly Dictionary[];
4
+ type Pattern = Segments;
5
+ type Patterns = readonly Pattern[];
6
+ interface RandomUtils {
7
+ int(max: number): number;
8
+ pick<T>(items: readonly T[]): T;
9
+ string(alphabet: string, length: number): string;
10
+ numeric(length: number): string;
11
+ alphabetic(length: number): string;
12
+ alphanumeric(length: number): string;
13
+ hexadecimal(length: number): string;
14
+ }
15
+ interface SuffixContext {
16
+ readonly words: readonly string[];
17
+ readonly random: RandomUtils;
18
+ }
19
+ type SuffixGenerator = (context: SuffixContext) => string;
20
+ interface LexidOptions {
21
+ /** Ordered word dictionaries. Defaults to a randomly selected built-in pattern. */
22
+ segments?: Segments;
23
+ /** Separator between all segments. Defaults to '-'. */
24
+ separator?: string;
25
+ /** Receives the selected words. Defaults to six lowercase alphanumeric characters. */
26
+ suffix?: SuffixGenerator;
27
+ /** Maximum length including separators and suffix. Defaults to 63. */
28
+ maxLength?: number;
29
+ }
30
+ interface LexidValidateOptions {
31
+ separator?: string;
32
+ maxLength?: number;
33
+ }
34
+ //#endregion
35
+ export { Patterns as a, SuffixContext as c, Pattern as i, SuffixGenerator as l, LexidOptions as n, RandomUtils as o, LexidValidateOptions as r, Segments as s, Dictionary as t };
@@ -0,0 +1,35 @@
1
+ //#region src/types.d.ts
2
+ type Dictionary = readonly string[];
3
+ type Segments = readonly Dictionary[];
4
+ type Pattern = Segments;
5
+ type Patterns = readonly Pattern[];
6
+ interface RandomUtils {
7
+ int(max: number): number;
8
+ pick<T>(items: readonly T[]): T;
9
+ string(alphabet: string, length: number): string;
10
+ numeric(length: number): string;
11
+ alphabetic(length: number): string;
12
+ alphanumeric(length: number): string;
13
+ hexadecimal(length: number): string;
14
+ }
15
+ interface SuffixContext {
16
+ readonly words: readonly string[];
17
+ readonly random: RandomUtils;
18
+ }
19
+ type SuffixGenerator = (context: SuffixContext) => string;
20
+ interface LexidOptions {
21
+ /** Ordered word dictionaries. Defaults to a randomly selected built-in pattern. */
22
+ segments?: Segments;
23
+ /** Separator between all segments. Defaults to '-'. */
24
+ separator?: string;
25
+ /** Receives the selected words. Defaults to six lowercase alphanumeric characters. */
26
+ suffix?: SuffixGenerator;
27
+ /** Maximum length including separators and suffix. Defaults to 63. */
28
+ maxLength?: number;
29
+ }
30
+ interface LexidValidateOptions {
31
+ separator?: string;
32
+ maxLength?: number;
33
+ }
34
+ //#endregion
35
+ export { Patterns as a, SuffixContext as c, Pattern as i, SuffixGenerator as l, LexidOptions as n, RandomUtils as o, LexidValidateOptions as r, Segments as s, Dictionary as t };