@eliware/snowflake 1.1.3 → 1.1.5

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
@@ -14,6 +14,10 @@ A production-ready, BigInt-safe Snowflake ID generator for Node.js. IDs are retu
14
14
  - Range validation and timestamp-capacity checks.
15
15
  - Native ESM, TypeScript declarations, and no runtime dependencies.
16
16
 
17
+ ## Requirements
18
+
19
+ - Node.js 26 or newer
20
+
17
21
  ## Installation
18
22
 
19
23
  ```bash
@@ -50,14 +54,28 @@ For Kubernetes, assign each replica a stable `workerId` from configuration. `pro
50
54
 
51
55
  The exports `generate` and `snowflake` are ready-to-use default generators. `constants` exposes the bit layout and default epoch.
52
56
 
57
+ ## TypeScript
58
+
59
+ TypeScript declarations are included for all public exports and options.
60
+
61
+ ## Errors / Troubleshooting
62
+
63
+ Configuration values outside the supported ranges throw `RangeError`; a non-function clock throws `TypeError`; timestamps before the epoch or beyond Snowflake capacity throw `RangeError`. Configure unique `workerId` and `processId` values across distributed generators.
64
+
53
65
  ## Testing and linting
54
66
 
55
67
  ```bash
56
68
  npm test
57
69
  npm run test:gaps
58
70
  npm run lint
71
+ npm run typecheck
72
+ npm run pack
59
73
  ```
60
74
 
75
+ ## Security
76
+
77
+ Snowflake IDs are unique identifiers, not secrets. Do not use them as authentication tokens or assume they conceal timestamp and deployment information.
78
+
61
79
  ## License
62
80
 
63
81
  MIT © Eli Sterling, eliware.org
@@ -0,0 +1,10 @@
1
+ // ESM example: example.mjs
2
+ import generate, { createSnowflakeGenerator } from './index.mjs';
3
+
4
+ console.log('Default generate():', generate());
5
+
6
+ const genWorker1 = createSnowflakeGenerator({ workerId: 1 });
7
+ console.log('Worker 1 generate():', genWorker1());
8
+
9
+ // Exported generator can be used anywhere in your app to create unique IDs
10
+ export default generate;
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@eliware/snowflake",
3
3
  "type": "module",
4
- "version": "1.1.3",
4
+ "version": "1.1.5",
5
5
  "description": "A minimal Node.js Snowflake ID generator (Discord-compatible). Provides BigInt-safe generators with configurable epoch and worker ID.",
6
- "main": "index.mjs",
7
6
  "types": "index.d.ts",
8
7
  "files": [
9
8
  "index.mjs",
10
9
  "index.d.ts",
11
10
  "README.md",
12
- "LICENSE"
11
+ "LICENSE",
12
+ "examples"
13
13
  ],
14
14
  "exports": {
15
15
  ".": {
@@ -19,8 +19,10 @@
19
19
  },
20
20
  "scripts": {
21
21
  "test": "npx --node-options=\"--experimental-vm-modules --no-warnings\" jest --detectOpenHandles --silent --coverage",
22
- "test:gaps": "npm test -- --coverageReporters=text 2>&1 | awk '!/100%/'",
23
- "lint": "npx oxlint ."
22
+ "test:gaps": "npm test 2>&1 | grep '|' | grep -vF '| 100 | 100 | 100 | 100 |'",
23
+ "lint": "npx oxlint .",
24
+ "typecheck": "tsc --project tsconfig.json",
25
+ "pack": "npm pack --dry-run"
24
26
  },
25
27
  "repository": {
26
28
  "type": "git",
@@ -43,7 +45,8 @@
43
45
  },
44
46
  "homepage": "https://github.com/eliware/snowflake#readme",
45
47
  "devDependencies": {
46
- "jest": "^30.4.2"
48
+ "jest": "^30.4.2",
49
+ "typescript": "^7.0.2"
47
50
  },
48
51
  "jest": {
49
52
  "testEnvironment": "node",
@@ -51,8 +54,5 @@
51
54
  "**/?(*.)+(spec|test).[jt]s?(x)",
52
55
  "**/?(*.)+(spec|test).mjs"
53
56
  ]
54
- },
55
- "dependencies": {
56
- "@eliware/common": "^1.1.4"
57
57
  }
58
58
  }