@omnitron-dev/cuid 0.4.6 → 0.4.8
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 +19 -12
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,27 +1,34 @@
|
|
|
1
1
|
# @omnitron-dev/cuid
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Generate compact string identifiers from a timestamp, counter, fingerprint and hashed entropy.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Capabilities
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- A default 16-character identifier beginning with a lowercase letter.
|
|
8
|
+
- `isCuid` for format validation.
|
|
9
|
+
- `createOptimizedCuid` for a configured generator.
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```sh
|
|
10
14
|
pnpm add @omnitron-dev/cuid
|
|
11
15
|
```
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
```ts
|
|
18
|
+
import { cuid, isCuid, createOptimizedCuid } from '@omnitron-dev/cuid';
|
|
14
19
|
|
|
15
|
-
|
|
20
|
+
const id = cuid();
|
|
21
|
+
console.log(isCuid(id)); // true
|
|
22
|
+
const createLongId = createOptimizedCuid({ length: 32 });
|
|
23
|
+
console.log(createLongId());
|
|
24
|
+
```
|
|
16
25
|
|
|
17
|
-
|
|
26
|
+
The encoded hash does not preserve timestamp order. Entropy uses `Math.random`; use a cryptographic token generator for bearer credentials. Format validation does not prove uniqueness or origin; use a uniqueness constraint where your storage requires one.
|
|
18
27
|
|
|
19
|
-
|
|
20
|
-
import { cuid } from '@omnitron-dev/cuid';
|
|
28
|
+
## Documentation
|
|
21
29
|
|
|
22
|
-
|
|
23
|
-
```
|
|
30
|
+
[Public API](src/index.ts) · [Package exports](package.json) · [Omni](../../README.md)
|
|
24
31
|
|
|
25
32
|
## License
|
|
26
33
|
|
|
27
|
-
MIT
|
|
34
|
+
[MIT](../../LICENSE).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omnitron-dev/cuid",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.8",
|
|
4
4
|
"description": "CUID implementation",
|
|
5
5
|
"author": "LuxQuant",
|
|
6
6
|
"license": "MIT",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@noble/hashes": "2.4.0"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "1ae8568eebc2581e2cc2428bd3ca1cf570ed3f03",
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "../../scripts/build-package.sh -p ./tsconfig.json",
|
|
60
60
|
"typecheck": "tsc --noEmit -p tsconfig.typecheck.json",
|