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 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: { cool: 'cool', awesome: 'awesome' },
128
- colors: { red: 'red', blue: 'blue' },
129
- nouns: { rocket: 'rocket', star: 'star' }
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
@@ -0,0 +1,6 @@
1
+ declare const words: {
2
+ adjectives: string[];
3
+ colors: string[];
4
+ nouns: string[];
5
+ };
6
+ export { words as en };