human-ids 1.2.0 → 2.0.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 +7 -9
- package/dist/cjs/dictionaries/en.d.ts +6 -0
- package/dist/cjs/dictionaries/en.js +973 -0
- package/dist/cjs/dictionaries/es.d.ts +6 -0
- package/dist/cjs/dictionaries/es.js +973 -0
- package/dist/cjs/dictionaries/index.d.ts +18 -0
- package/dist/cjs/dictionaries/index.js +25 -0
- package/dist/{index.d.ts → cjs/index.d.ts} +6 -6
- package/dist/{index.js → cjs/index.js} +5 -13
- package/dist/esm/dictionaries/en.d.ts +6 -0
- package/dist/esm/dictionaries/en.js +970 -0
- package/dist/esm/dictionaries/es.d.ts +6 -0
- package/dist/esm/dictionaries/es.js +970 -0
- package/dist/esm/dictionaries/index.d.ts +18 -0
- package/dist/esm/dictionaries/index.js +22 -0
- package/dist/esm/index.d.ts +246 -0
- package/dist/esm/index.js +123 -0
- package/dist/esm/package.json +1 -0
- package/package.json +17 -4
- package/dist/dictionaries/en.d.ts +0 -3
- package/dist/dictionaries/en.js +0 -983
- package/dist/dictionaries/es.d.ts +0 -3
- package/dist/dictionaries/es.js +0 -986
- package/dist/dictionaries/index.d.ts +0 -45
- package/dist/dictionaries/index.js +0 -57
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dictionary management module for human-ids.
|
|
3
|
-
* Handles built-in dictionaries and caching of resolved word arrays.
|
|
4
|
-
* @module dictionaries
|
|
5
|
-
* @internal
|
|
6
|
-
*/
|
|
7
|
-
import type { Dictionary } from '../index';
|
|
8
|
-
/**
|
|
9
|
-
* Dictionary with word lists converted to arrays for efficient random selection.
|
|
10
|
-
* @internal
|
|
11
|
-
*/
|
|
12
|
-
export interface ResolvedDictionary {
|
|
13
|
-
/** Array of adjective words */
|
|
14
|
-
adjectives: string[];
|
|
15
|
-
/** Array of color words */
|
|
16
|
-
colors: string[];
|
|
17
|
-
/** Array of noun words */
|
|
18
|
-
nouns: string[];
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Built-in dictionaries indexed by language code.
|
|
22
|
-
* Currently supports 'en' (English) and 'es' (Spanish).
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```typescript
|
|
26
|
-
* import { dictionaries } from 'human-ids';
|
|
27
|
-
*
|
|
28
|
-
* // Access English adjectives
|
|
29
|
-
* const englishAdjectives = Object.keys(dictionaries.en.adjectives);
|
|
30
|
-
*
|
|
31
|
-
* // Check available languages
|
|
32
|
-
* const languages = Object.keys(dictionaries); // ['en', 'es']
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
declare const dictionaries: Record<string, Dictionary>;
|
|
36
|
-
/**
|
|
37
|
-
* Converts a Dictionary (with Record objects) to a ResolvedDictionary (with arrays).
|
|
38
|
-
* Results are cached for performance.
|
|
39
|
-
*
|
|
40
|
-
* @param dict - Dictionary to resolve
|
|
41
|
-
* @returns Dictionary with word lists as arrays
|
|
42
|
-
* @internal
|
|
43
|
-
*/
|
|
44
|
-
declare function resolveDictionary(dict: Dictionary): ResolvedDictionary;
|
|
45
|
-
export { dictionaries, resolveDictionary };
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Dictionary management module for human-ids.
|
|
4
|
-
* Handles built-in dictionaries and caching of resolved word arrays.
|
|
5
|
-
* @module dictionaries
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.dictionaries = void 0;
|
|
10
|
-
exports.resolveDictionary = resolveDictionary;
|
|
11
|
-
const en_1 = require("./en");
|
|
12
|
-
const es_1 = require("./es");
|
|
13
|
-
/**
|
|
14
|
-
* Built-in dictionaries indexed by language code.
|
|
15
|
-
* Currently supports 'en' (English) and 'es' (Spanish).
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```typescript
|
|
19
|
-
* import { dictionaries } from 'human-ids';
|
|
20
|
-
*
|
|
21
|
-
* // Access English adjectives
|
|
22
|
-
* const englishAdjectives = Object.keys(dictionaries.en.adjectives);
|
|
23
|
-
*
|
|
24
|
-
* // Check available languages
|
|
25
|
-
* const languages = Object.keys(dictionaries); // ['en', 'es']
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
const dictionaries = {
|
|
29
|
-
en: en_1.en,
|
|
30
|
-
es: es_1.es
|
|
31
|
-
};
|
|
32
|
-
exports.dictionaries = dictionaries;
|
|
33
|
-
/**
|
|
34
|
-
* Cache for resolved dictionaries to avoid repeated Object.values() calls.
|
|
35
|
-
* @internal
|
|
36
|
-
*/
|
|
37
|
-
const resolvedCache = new Map();
|
|
38
|
-
/**
|
|
39
|
-
* Converts a Dictionary (with Record objects) to a ResolvedDictionary (with arrays).
|
|
40
|
-
* Results are cached for performance.
|
|
41
|
-
*
|
|
42
|
-
* @param dict - Dictionary to resolve
|
|
43
|
-
* @returns Dictionary with word lists as arrays
|
|
44
|
-
* @internal
|
|
45
|
-
*/
|
|
46
|
-
function resolveDictionary(dict) {
|
|
47
|
-
let resolved = resolvedCache.get(dict);
|
|
48
|
-
if (!resolved) {
|
|
49
|
-
resolved = {
|
|
50
|
-
adjectives: Object.values(dict.adjectives),
|
|
51
|
-
colors: Object.values(dict.colors),
|
|
52
|
-
nouns: Object.values(dict.nouns),
|
|
53
|
-
};
|
|
54
|
-
resolvedCache.set(dict, resolved);
|
|
55
|
-
}
|
|
56
|
-
return resolved;
|
|
57
|
-
}
|