@stryke/unique-id 0.3.31 → 0.3.32
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/CHANGELOG.md +6 -0
- package/dist/_virtual/rolldown_runtime.cjs +1 -0
- package/dist/convert/src/neutral.cjs +1 -0
- package/dist/convert/src/neutral.mjs +1 -0
- package/dist/convert/src/parse-type-definition.cjs +1 -0
- package/dist/convert/src/parse-type-definition.mjs +1 -0
- package/dist/convert/src/string-to-utf8-array.cjs +1 -0
- package/dist/convert/src/string-to-utf8-array.mjs +2 -0
- package/dist/convert/src/string-to-utf8-array.mjs.map +1 -0
- package/dist/convert/src/utf8-array-to-string.cjs +1 -0
- package/dist/convert/src/utf8-array-to-string.mjs +2 -0
- package/dist/convert/src/utf8-array-to-string.mjs.map +1 -0
- package/dist/cuid.cjs +1 -1
- package/dist/cuid.d.cts +20 -2
- package/dist/cuid.d.cts.map +1 -0
- package/dist/cuid.d.mts +20 -2
- package/dist/cuid.d.mts.map +1 -0
- package/dist/cuid.mjs +2 -1
- package/dist/cuid.mjs.map +1 -0
- package/dist/fs/src/list-files.cjs +1 -0
- package/dist/fs/src/list-files.mjs +1 -0
- package/dist/hash/src/digest.cjs +1 -0
- package/dist/hash/src/digest.mjs +1 -0
- package/dist/hash/src/hash-files.cjs +1 -0
- package/dist/hash/src/hash-files.mjs +1 -0
- package/dist/hash/src/murmurhash.cjs +1 -0
- package/dist/hash/src/murmurhash.mjs +2 -0
- package/dist/hash/src/murmurhash.mjs.map +1 -0
- package/dist/hash/src/neutral.cjs +1 -0
- package/dist/hash/src/neutral.mjs +1 -0
- package/dist/hash/src/xx-hash.cjs +1 -0
- package/dist/hash/src/xx-hash.mjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +1 -1
- package/dist/nanoid-client.cjs +1 -1
- package/dist/nanoid-client.d.cts +11 -2
- package/dist/nanoid-client.d.cts.map +1 -0
- package/dist/nanoid-client.d.mts +11 -2
- package/dist/nanoid-client.d.mts.map +1 -0
- package/dist/nanoid-client.mjs +2 -1
- package/dist/nanoid-client.mjs.map +1 -0
- package/dist/random.cjs +1 -1
- package/dist/random.d.cts +33 -2
- package/dist/random.d.cts.map +1 -0
- package/dist/random.d.mts +33 -2
- package/dist/random.d.mts.map +1 -0
- package/dist/random.mjs +2 -1
- package/dist/random.mjs.map +1 -0
- package/dist/snowflake.cjs +1 -1
- package/dist/snowflake.d.cts +102 -2
- package/dist/snowflake.d.cts.map +1 -0
- package/dist/snowflake.d.mts +102 -2
- package/dist/snowflake.d.mts.map +1 -0
- package/dist/snowflake.mjs +2 -1
- package/dist/snowflake.mjs.map +1 -0
- package/dist/type-checks/src/index.cjs +1 -0
- package/dist/type-checks/src/index.mjs +1 -0
- package/dist/type-checks/src/is-buffer.cjs +1 -0
- package/dist/type-checks/src/is-buffer.mjs +2 -0
- package/dist/type-checks/src/is-buffer.mjs.map +1 -0
- package/dist/type-checks/src/is-collection.cjs +1 -0
- package/dist/type-checks/src/is-collection.mjs +1 -0
- package/dist/type-checks/src/type-detect.cjs +1 -0
- package/dist/type-checks/src/type-detect.mjs +2 -0
- package/dist/type-checks/src/type-detect.mjs.map +1 -0
- package/dist/uuid.cjs +1 -1
- package/dist/uuid.d.cts +22 -2
- package/dist/uuid.d.cts.map +1 -0
- package/dist/uuid.d.mts +22 -2
- package/dist/uuid.d.mts.map +1 -0
- package/dist/uuid.mjs +2 -1
- package/dist/uuid.mjs.map +1 -0
- package/package.json +3 -3
- package/dist/cuid-BuvbHUZ8.cjs +0 -1
- package/dist/cuid-CcPQdiR_.mjs +0 -2
- package/dist/cuid-CcPQdiR_.mjs.map +0 -1
- package/dist/cuid-DT9rtBzf.d.mts +0 -20
- package/dist/cuid-DT9rtBzf.d.mts.map +0 -1
- package/dist/cuid-gUcp5l6X.d.cts +0 -20
- package/dist/cuid-gUcp5l6X.d.cts.map +0 -1
- package/dist/nanoid-client-DxgQ8Vt2.cjs +0 -1
- package/dist/nanoid-client-bEHxSBYB.mjs +0 -2
- package/dist/nanoid-client-bEHxSBYB.mjs.map +0 -1
- package/dist/nanoid-client-mNAgNxsW.d.cts +0 -11
- package/dist/nanoid-client-mNAgNxsW.d.cts.map +0 -1
- package/dist/nanoid-client-nC1JFvZD.d.mts +0 -11
- package/dist/nanoid-client-nC1JFvZD.d.mts.map +0 -1
- package/dist/random-Bd2-oY2n.d.cts +0 -33
- package/dist/random-Bd2-oY2n.d.cts.map +0 -1
- package/dist/random-C4CrqJsp.cjs +0 -1
- package/dist/random-DTxCCJYh.d.mts +0 -33
- package/dist/random-DTxCCJYh.d.mts.map +0 -1
- package/dist/random-kTN0s0Jy.mjs +0 -2
- package/dist/random-kTN0s0Jy.mjs.map +0 -1
- package/dist/snowflake-B6ivA7bE.d.mts +0 -102
- package/dist/snowflake-B6ivA7bE.d.mts.map +0 -1
- package/dist/snowflake-BtoDXB99.mjs +0 -2
- package/dist/snowflake-BtoDXB99.mjs.map +0 -1
- package/dist/snowflake-CLDXd54w.cjs +0 -1
- package/dist/snowflake-DQmoRlnq.d.cts +0 -102
- package/dist/snowflake-DQmoRlnq.d.cts.map +0 -1
- package/dist/uuid-BnD3hGTH.cjs +0 -1
- package/dist/uuid-ByPTbUGJ.d.mts +0 -22
- package/dist/uuid-ByPTbUGJ.d.mts.map +0 -1
- package/dist/uuid-DCE9JeUQ.d.cts +0 -22
- package/dist/uuid-DCE9JeUQ.d.cts.map +0 -1
- package/dist/uuid-DSMliG_W.mjs +0 -2
- package/dist/uuid-DSMliG_W.mjs.map +0 -1
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
//#region src/snowflake.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Options passed to the `generate` function to create a snowflake identifier.
|
|
4
|
-
*/
|
|
5
|
-
interface SnowflakeGeneratorOptions {
|
|
6
|
-
/**
|
|
7
|
-
* The id of the shard running this generator.
|
|
8
|
-
*
|
|
9
|
-
* @defaultValue 1
|
|
10
|
-
*/
|
|
11
|
-
shardId?: number;
|
|
12
|
-
/**
|
|
13
|
-
* The epoch to use for the snowflake.
|
|
14
|
-
*
|
|
15
|
-
* @remarks
|
|
16
|
-
* This is the time in milliseconds since 1 January 1970 00:00:00 UTC.
|
|
17
|
-
*
|
|
18
|
-
* @defaultValue 1420070400000 (Date.UTC(1970, 0, 1).valueOf())
|
|
19
|
-
*/
|
|
20
|
-
epoch?: number;
|
|
21
|
-
/**
|
|
22
|
-
* The current timestamp to use for the snowflake.
|
|
23
|
-
*
|
|
24
|
-
* @defaultValue Date.now()
|
|
25
|
-
*/
|
|
26
|
-
timestamp?: number | Date;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Resolvable value types for a valid Snowflake:
|
|
30
|
-
* string
|
|
31
|
-
* number
|
|
32
|
-
* bigint
|
|
33
|
-
*/
|
|
34
|
-
type SnowflakeResolvable = string;
|
|
35
|
-
/**
|
|
36
|
-
* A deconstructed snowflake and the details around it's creation.
|
|
37
|
-
*/
|
|
38
|
-
interface DeconstructedSnowflake {
|
|
39
|
-
/**
|
|
40
|
-
* Snowflake deconstructed from
|
|
41
|
-
*/
|
|
42
|
-
snowflake: SnowflakeResolvable;
|
|
43
|
-
/**
|
|
44
|
-
* The timestamp the snowflake was generated
|
|
45
|
-
*/
|
|
46
|
-
timestamp: number;
|
|
47
|
-
/**
|
|
48
|
-
* The shard_id used when generating
|
|
49
|
-
*/
|
|
50
|
-
shard_id: number;
|
|
51
|
-
/**
|
|
52
|
-
* The increment of this snowflake
|
|
53
|
-
*/
|
|
54
|
-
sequence: number;
|
|
55
|
-
/**
|
|
56
|
-
* The 64Bit snowflake binary string
|
|
57
|
-
*/
|
|
58
|
-
binary: string;
|
|
59
|
-
}
|
|
60
|
-
declare const DEFAULT_SHARD_ID = 1;
|
|
61
|
-
declare const DEFAULT_EPOCH: number;
|
|
62
|
-
/**
|
|
63
|
-
* Generate a snowflake identifier.
|
|
64
|
-
*
|
|
65
|
-
* @remarks
|
|
66
|
-
* Snowflakes are 64-bit unsigned integers that are roughly time-ordered.
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* ```typescript
|
|
70
|
-
*
|
|
71
|
-
* // Generate a snowflake with the default options
|
|
72
|
-
* const id1 = snowflake();
|
|
73
|
-
*
|
|
74
|
-
* // Generate a snowflake with a custom shard id
|
|
75
|
-
* const id2 = snowflake({ shardId: 2 });
|
|
76
|
-
*
|
|
77
|
-
* // Generate a snowflake with a custom shard id and timestamp
|
|
78
|
-
* const id3 = snowflake({ shardId: 3, timestamp: new Date("2021-01-01") });
|
|
79
|
-
*
|
|
80
|
-
* ```
|
|
81
|
-
*
|
|
82
|
-
* @param options - The options to use when generating the snowflake
|
|
83
|
-
* @returns A snowflake
|
|
84
|
-
*/
|
|
85
|
-
declare function snowflake(options?: SnowflakeGeneratorOptions): string;
|
|
86
|
-
/**
|
|
87
|
-
* Deconstruct a snowflake to its values using the `epoch`.
|
|
88
|
-
*
|
|
89
|
-
* @param snowflake - Snowflake to deconstruct
|
|
90
|
-
* @returns Either the DeconstructedSnowflake object
|
|
91
|
-
*/
|
|
92
|
-
declare function deconstructSnowflake(snowflake: SnowflakeResolvable): DeconstructedSnowflake;
|
|
93
|
-
/**
|
|
94
|
-
* Check if a snowflake string Id is valid.
|
|
95
|
-
*
|
|
96
|
-
* @param snowflake - Snowflake to check
|
|
97
|
-
* @returns Whether the snowflake is valid
|
|
98
|
-
*/
|
|
99
|
-
declare function isValidSnowflake(snowflake: string): boolean;
|
|
100
|
-
//#endregion
|
|
101
|
-
export { SnowflakeResolvable as a, snowflake as c, SnowflakeGeneratorOptions as i, DEFAULT_SHARD_ID as n, deconstructSnowflake as o, DeconstructedSnowflake as r, isValidSnowflake as s, DEFAULT_EPOCH as t };
|
|
102
|
-
//# sourceMappingURL=snowflake-DQmoRlnq.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"snowflake-DQmoRlnq.d.cts","names":[],"sources":["../src/snowflake.ts"],"sourcesContent":[],"mappings":";;AAqBA;AAgCA;AAKiB,UArCA,yBAAA,CAyCJ;EAuBA;AACb;AAqEA;AA0BA;AAoBA;;;;;;;;;;;;;;;;uBA7JuB;;;;;;;;KASX,mBAAA;;;;UAKK,sBAAA;;;;aAIJ;;;;;;;;;;;;;;;;;;cAuBA,gBAAA;cACA;;;;;;;;;;;;;;;;;;;;;;;;iBAqEG,SAAA,WAAmB;;;;;;;iBA0BnB,oBAAA,YACH,sBACV;;;;;;;iBAkBa,gBAAA"}
|
package/dist/uuid-BnD3hGTH.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
let e=256;const t=[];let n;for(;e--;)t[e]=(e+256).toString(16).slice(1);function r(){let r=0,i,a=``;if(!n||e+16>256){for(n=Array.from({length:r=256});r--;)n[r]=Math.trunc(256*Math.random());r=e=0}for(;r<16;r++)i=n[e+r],r===6?a+=t[i&15|64]:r===8?a+=t[i&63|128]:a+=t[i],r&1&&r>1&&r<11&&(a+=`-`);return e++,a}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return r}});
|
package/dist/uuid-ByPTbUGJ.d.mts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
//#region src/uuid.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* A utility function that returns a [UUID (Universally Unique Identifier)](https://www.cockroachlabs.com/blog/what-is-a-uuid/) string.
|
|
4
|
-
*
|
|
5
|
-
* @remarks
|
|
6
|
-
* This function generates a random UUID (Universally Unique Identifier) using a cryptographically secure pseudo-random number generator.
|
|
7
|
-
*
|
|
8
|
-
* This implementation was based on https://github.com/lukeed/uuid.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* // Generate a UUID string
|
|
13
|
-
* const id = uuid();
|
|
14
|
-
* // => "f47ac10b-58cc-4372-a567-0e02b2c3d479"
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* @returns A UUID unique identifier.
|
|
18
|
-
*/
|
|
19
|
-
declare function uuid(): string;
|
|
20
|
-
//#endregion
|
|
21
|
-
export { uuid as t };
|
|
22
|
-
//# sourceMappingURL=uuid-ByPTbUGJ.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uuid-ByPTbUGJ.d.mts","names":[],"sources":["../src/uuid.ts"],"sourcesContent":[],"mappings":";;AA2CA;;;;;;;;;;;;;;;;iBAAgB,IAAA,CAAA"}
|
package/dist/uuid-DCE9JeUQ.d.cts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
//#region src/uuid.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* A utility function that returns a [UUID (Universally Unique Identifier)](https://www.cockroachlabs.com/blog/what-is-a-uuid/) string.
|
|
4
|
-
*
|
|
5
|
-
* @remarks
|
|
6
|
-
* This function generates a random UUID (Universally Unique Identifier) using a cryptographically secure pseudo-random number generator.
|
|
7
|
-
*
|
|
8
|
-
* This implementation was based on https://github.com/lukeed/uuid.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* // Generate a UUID string
|
|
13
|
-
* const id = uuid();
|
|
14
|
-
* // => "f47ac10b-58cc-4372-a567-0e02b2c3d479"
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* @returns A UUID unique identifier.
|
|
18
|
-
*/
|
|
19
|
-
declare function uuid(): string;
|
|
20
|
-
//#endregion
|
|
21
|
-
export { uuid as t };
|
|
22
|
-
//# sourceMappingURL=uuid-DCE9JeUQ.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uuid-DCE9JeUQ.d.cts","names":[],"sources":["../src/uuid.ts"],"sourcesContent":[],"mappings":";;AA2CA;;;;;;;;;;;;;;;;iBAAgB,IAAA,CAAA"}
|
package/dist/uuid-DSMliG_W.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
let e=256;const t=[];let n;for(;e--;)t[e]=(e+256).toString(16).slice(1);function r(){let r=0,i,a=``;if(!n||e+16>256){for(n=Array.from({length:r=256});r--;)n[r]=Math.trunc(256*Math.random());r=e=0}for(;r<16;r++)i=n[e+r],r===6?a+=t[i&15|64]:r===8?a+=t[i&63|128]:a+=t[i],r&1&&r>1&&r<11&&(a+=`-`);return e++,a}export{r as t};
|
|
2
|
-
//# sourceMappingURL=uuid-DSMliG_W.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uuid-DSMliG_W.mjs","names":["buffer!: number[]","num!: number"],"sources":["../src/uuid.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nlet index = 256;\nconst hex = [] as string[];\nlet buffer!: number[];\n\nwhile (index--) {\n hex[index] = (index + 256).toString(16).slice(1);\n}\n\n/**\n * A utility function that returns a [UUID (Universally Unique Identifier)](https://www.cockroachlabs.com/blog/what-is-a-uuid/) string.\n *\n * @remarks\n * This function generates a random UUID (Universally Unique Identifier) using a cryptographically secure pseudo-random number generator.\n *\n * This implementation was based on https://github.com/lukeed/uuid.\n *\n * @example\n * ```typescript\n * // Generate a UUID string\n * const id = uuid();\n * // => \"f47ac10b-58cc-4372-a567-0e02b2c3d479\"\n * ```\n *\n * @returns A UUID unique identifier.\n */\nexport function uuid() {\n let i = 0;\n let num!: number;\n let out = \"\";\n\n if (!buffer || index + 16 > 256) {\n buffer = Array.from({ length: (i = 256) });\n while (i--) {\n buffer[i] = Math.trunc(256 * Math.random());\n }\n // eslint-disable-next-line no-multi-assign\n i = index = 0;\n }\n\n for (; i < 16; i++) {\n num = buffer[index + i]!;\n if (i === 6) {\n out += hex[(num & 15) | 64];\n } else if (i === 8) {\n out += hex[(num & 63) | 128];\n } else {\n out += hex[num];\n }\n\n if (i & 1 && i > 1 && i < 11) {\n out += \"-\";\n }\n }\n\n index++;\n return out;\n}\n"],"mappings":"AAkBA,IAAI,EAAQ,IACZ,MAAM,EAAM,EAAE,CACd,IAAIA,EAEJ,KAAO,KACL,EAAI,IAAU,EAAQ,KAAK,SAAS,GAAG,CAAC,MAAM,EAAE,CAoBlD,SAAgB,GAAO,CACrB,IAAI,EAAI,EACJC,EACA,EAAM,GAEV,GAAI,CAAC,GAAU,EAAQ,GAAK,IAAK,CAE/B,IADA,EAAS,MAAM,KAAK,CAAE,OAAS,EAAI,IAAM,CAAC,CACnC,KACL,EAAO,GAAK,KAAK,MAAM,IAAM,KAAK,QAAQ,CAAC,CAG7C,EAAI,EAAQ,EAGd,KAAO,EAAI,GAAI,IACb,EAAM,EAAO,EAAQ,GACjB,IAAM,EACR,GAAO,EAAK,EAAM,GAAM,IACf,IAAM,EACf,GAAO,EAAK,EAAM,GAAM,KAExB,GAAO,EAAI,GAGT,EAAI,GAAK,EAAI,GAAK,EAAI,KACxB,GAAO,KAKX,MADA,KACO"}
|