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
package/README.md
CHANGED
|
@@ -11,6 +11,7 @@ A zero-dependency TypeScript library that generates human-readable IDs by combin
|
|
|
11
11
|
- **Multi-language**: Built-in support for English and Spanish with proper word ordering
|
|
12
12
|
- **Highly unique**: ~209 billion possible combinations per language
|
|
13
13
|
- **Zero dependencies**: Lightweight and secure
|
|
14
|
+
- **ESM + CJS**: Ships both ES Module and CommonJS builds with a full `exports` map
|
|
14
15
|
- **TypeScript**: Full type definitions with JSDoc documentation
|
|
15
16
|
- **Customizable**: Configure separators, components, number ranges, and even provide custom dictionaries
|
|
16
17
|
|
|
@@ -23,7 +24,7 @@ npm install human-ids
|
|
|
23
24
|
## Quick Start
|
|
24
25
|
|
|
25
26
|
```javascript
|
|
26
|
-
import generateId from 'human-ids';
|
|
27
|
+
import { generateId } from 'human-ids';
|
|
27
28
|
|
|
28
29
|
// Generate a random ID
|
|
29
30
|
const id = generateId();
|
|
@@ -49,7 +50,7 @@ radiant-coral-serenity-2671 estrella-jade-luminoso-8156
|
|
|
49
50
|
### Basic Usage
|
|
50
51
|
|
|
51
52
|
```javascript
|
|
52
|
-
import generateId from 'human-ids';
|
|
53
|
+
import { generateId } from 'human-ids';
|
|
53
54
|
|
|
54
55
|
// Default: English, all components enabled
|
|
55
56
|
const id = generateId();
|
|
@@ -124,9 +125,9 @@ generateId({ randomOrder: true });
|
|
|
124
125
|
```javascript
|
|
125
126
|
generateId({
|
|
126
127
|
dictionary: {
|
|
127
|
-
adjectives:
|
|
128
|
-
colors:
|
|
129
|
-
nouns:
|
|
128
|
+
adjectives: ['cool', 'awesome'],
|
|
129
|
+
colors: ['red', 'blue'],
|
|
130
|
+
nouns: ['rocket', 'star']
|
|
130
131
|
}
|
|
131
132
|
});
|
|
132
133
|
// => "cool-red-rocket-5678"
|
|
@@ -135,10 +136,6 @@ generateId({
|
|
|
135
136
|
## CommonJS Support
|
|
136
137
|
|
|
137
138
|
```javascript
|
|
138
|
-
// Default import
|
|
139
|
-
const generateId = require('human-ids');
|
|
140
|
-
|
|
141
|
-
// Named imports
|
|
142
139
|
const { generateId, dictionaries } = require('human-ids');
|
|
143
140
|
```
|
|
144
141
|
|
|
@@ -196,6 +193,7 @@ import { dictionaries } from 'human-ids';
|
|
|
196
193
|
|
|
197
194
|
console.log(Object.keys(dictionaries)); // ['en', 'es']
|
|
198
195
|
console.log(Object.keys(dictionaries.en)); // ['adjectives', 'colors', 'nouns']
|
|
196
|
+
console.log(dictionaries.en.adjectives[0]); // 'silly'
|
|
199
197
|
```
|
|
200
198
|
|
|
201
199
|
## Contributing
|