@stryke/unique-id 0.3.31 → 0.3.33

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.
Files changed (110) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/_virtual/rolldown_runtime.cjs +1 -0
  3. package/dist/convert/src/neutral.cjs +1 -0
  4. package/dist/convert/src/neutral.mjs +1 -0
  5. package/dist/convert/src/parse-type-definition.cjs +1 -0
  6. package/dist/convert/src/parse-type-definition.mjs +1 -0
  7. package/dist/convert/src/string-to-utf8-array.cjs +1 -0
  8. package/dist/convert/src/string-to-utf8-array.mjs +2 -0
  9. package/dist/convert/src/string-to-utf8-array.mjs.map +1 -0
  10. package/dist/convert/src/utf8-array-to-string.cjs +1 -0
  11. package/dist/convert/src/utf8-array-to-string.mjs +2 -0
  12. package/dist/convert/src/utf8-array-to-string.mjs.map +1 -0
  13. package/dist/cuid.cjs +1 -1
  14. package/dist/cuid.d.cts +20 -2
  15. package/dist/cuid.d.cts.map +1 -0
  16. package/dist/cuid.d.mts +20 -2
  17. package/dist/cuid.d.mts.map +1 -0
  18. package/dist/cuid.mjs +2 -1
  19. package/dist/cuid.mjs.map +1 -0
  20. package/dist/fs/src/list-files.cjs +1 -0
  21. package/dist/fs/src/list-files.mjs +1 -0
  22. package/dist/hash/src/digest.cjs +1 -0
  23. package/dist/hash/src/digest.mjs +1 -0
  24. package/dist/hash/src/hash-files.cjs +1 -0
  25. package/dist/hash/src/hash-files.mjs +1 -0
  26. package/dist/hash/src/murmurhash.cjs +1 -0
  27. package/dist/hash/src/murmurhash.mjs +2 -0
  28. package/dist/hash/src/murmurhash.mjs.map +1 -0
  29. package/dist/hash/src/neutral.cjs +1 -0
  30. package/dist/hash/src/neutral.mjs +1 -0
  31. package/dist/hash/src/xx-hash.cjs +1 -0
  32. package/dist/hash/src/xx-hash.mjs +1 -0
  33. package/dist/index.cjs +1 -1
  34. package/dist/index.d.cts +5 -5
  35. package/dist/index.d.mts +5 -5
  36. package/dist/index.mjs +1 -1
  37. package/dist/nanoid-client.cjs +1 -1
  38. package/dist/nanoid-client.d.cts +11 -2
  39. package/dist/nanoid-client.d.cts.map +1 -0
  40. package/dist/nanoid-client.d.mts +11 -2
  41. package/dist/nanoid-client.d.mts.map +1 -0
  42. package/dist/nanoid-client.mjs +2 -1
  43. package/dist/nanoid-client.mjs.map +1 -0
  44. package/dist/random.cjs +1 -1
  45. package/dist/random.d.cts +33 -2
  46. package/dist/random.d.cts.map +1 -0
  47. package/dist/random.d.mts +33 -2
  48. package/dist/random.d.mts.map +1 -0
  49. package/dist/random.mjs +2 -1
  50. package/dist/random.mjs.map +1 -0
  51. package/dist/snowflake.cjs +1 -1
  52. package/dist/snowflake.d.cts +102 -2
  53. package/dist/snowflake.d.cts.map +1 -0
  54. package/dist/snowflake.d.mts +102 -2
  55. package/dist/snowflake.d.mts.map +1 -0
  56. package/dist/snowflake.mjs +2 -1
  57. package/dist/snowflake.mjs.map +1 -0
  58. package/dist/type-checks/src/index.cjs +1 -0
  59. package/dist/type-checks/src/index.mjs +1 -0
  60. package/dist/type-checks/src/is-buffer.cjs +1 -0
  61. package/dist/type-checks/src/is-buffer.mjs +2 -0
  62. package/dist/type-checks/src/is-buffer.mjs.map +1 -0
  63. package/dist/type-checks/src/is-collection.cjs +1 -0
  64. package/dist/type-checks/src/is-collection.mjs +1 -0
  65. package/dist/type-checks/src/type-detect.cjs +1 -0
  66. package/dist/type-checks/src/type-detect.mjs +2 -0
  67. package/dist/type-checks/src/type-detect.mjs.map +1 -0
  68. package/dist/uuid.cjs +1 -1
  69. package/dist/uuid.d.cts +22 -2
  70. package/dist/uuid.d.cts.map +1 -0
  71. package/dist/uuid.d.mts +22 -2
  72. package/dist/uuid.d.mts.map +1 -0
  73. package/dist/uuid.mjs +2 -1
  74. package/dist/uuid.mjs.map +1 -0
  75. package/package.json +3 -3
  76. package/dist/cuid-BuvbHUZ8.cjs +0 -1
  77. package/dist/cuid-CcPQdiR_.mjs +0 -2
  78. package/dist/cuid-CcPQdiR_.mjs.map +0 -1
  79. package/dist/cuid-DT9rtBzf.d.mts +0 -20
  80. package/dist/cuid-DT9rtBzf.d.mts.map +0 -1
  81. package/dist/cuid-gUcp5l6X.d.cts +0 -20
  82. package/dist/cuid-gUcp5l6X.d.cts.map +0 -1
  83. package/dist/nanoid-client-DxgQ8Vt2.cjs +0 -1
  84. package/dist/nanoid-client-bEHxSBYB.mjs +0 -2
  85. package/dist/nanoid-client-bEHxSBYB.mjs.map +0 -1
  86. package/dist/nanoid-client-mNAgNxsW.d.cts +0 -11
  87. package/dist/nanoid-client-mNAgNxsW.d.cts.map +0 -1
  88. package/dist/nanoid-client-nC1JFvZD.d.mts +0 -11
  89. package/dist/nanoid-client-nC1JFvZD.d.mts.map +0 -1
  90. package/dist/random-Bd2-oY2n.d.cts +0 -33
  91. package/dist/random-Bd2-oY2n.d.cts.map +0 -1
  92. package/dist/random-C4CrqJsp.cjs +0 -1
  93. package/dist/random-DTxCCJYh.d.mts +0 -33
  94. package/dist/random-DTxCCJYh.d.mts.map +0 -1
  95. package/dist/random-kTN0s0Jy.mjs +0 -2
  96. package/dist/random-kTN0s0Jy.mjs.map +0 -1
  97. package/dist/snowflake-B6ivA7bE.d.mts +0 -102
  98. package/dist/snowflake-B6ivA7bE.d.mts.map +0 -1
  99. package/dist/snowflake-BtoDXB99.mjs +0 -2
  100. package/dist/snowflake-BtoDXB99.mjs.map +0 -1
  101. package/dist/snowflake-CLDXd54w.cjs +0 -1
  102. package/dist/snowflake-DQmoRlnq.d.cts +0 -102
  103. package/dist/snowflake-DQmoRlnq.d.cts.map +0 -1
  104. package/dist/uuid-BnD3hGTH.cjs +0 -1
  105. package/dist/uuid-ByPTbUGJ.d.mts +0 -22
  106. package/dist/uuid-ByPTbUGJ.d.mts.map +0 -1
  107. package/dist/uuid-DCE9JeUQ.d.cts +0 -22
  108. package/dist/uuid-DCE9JeUQ.d.cts.map +0 -1
  109. package/dist/uuid-DSMliG_W.mjs +0 -2
  110. package/dist/uuid-DSMliG_W.mjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  # Changelog for Stryke - Unique ID
4
4
 
5
+ ## [0.3.32](https://github.com/storm-software/stryke/releases/tag/unique-id%400.3.32) (12/17/2025)
6
+
7
+ ### Updated Dependencies
8
+
9
+ - Updated **hash** to **v0.12.27**
10
+
11
+ ## [0.3.31](https://github.com/storm-software/stryke/releases/tag/unique-id%400.3.31) (12/08/2025)
12
+
13
+ ### Updated Dependencies
14
+
15
+ - Updated **hash** to **v0.12.26**
16
+
5
17
  ## [0.3.30](https://github.com/storm-software/stryke/releases/tag/unique-id%400.3.30) (12/08/2025)
6
18
 
7
19
  ### Updated Dependencies
@@ -0,0 +1 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
@@ -0,0 +1 @@
1
+ require(`./parse-type-definition.cjs`),require(`./string-to-utf8-array.cjs`),require(`./utf8-array-to-string.cjs`);
@@ -0,0 +1 @@
1
+ import"./parse-type-definition.mjs";import"./string-to-utf8-array.mjs";import"./utf8-array-to-string.mjs";export{};
@@ -0,0 +1 @@
1
+ require(`../../type-checks/src/index.cjs`);
@@ -0,0 +1 @@
1
+ import"../../type-checks/src/index.mjs";export{};
@@ -0,0 +1 @@
1
+ const e=new TextEncoder;
@@ -0,0 +1,2 @@
1
+ new TextEncoder;export{};
2
+ //# sourceMappingURL=string-to-utf8-array.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string-to-utf8-array.mjs","names":[],"sources":["../../../../convert/src/string-to-utf8-array.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\nconst encoder = new TextEncoder();\n\n/**\n * Convert a string to a utf-8 array\n *\n * @param input - The string to convert\n * @returns The converted utf-8 array\n */\nexport function stringToUtf8Array(input: string): Uint8Array {\n return encoder.encode(input);\n}\n"],"mappings":"AAkBgB,IAAI"}
@@ -0,0 +1 @@
1
+ const e=new TextDecoder;
@@ -0,0 +1,2 @@
1
+ new TextDecoder;export{};
2
+ //# sourceMappingURL=utf8-array-to-string.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utf8-array-to-string.mjs","names":[],"sources":["../../../../convert/src/utf8-array-to-string.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\nconst decoder = new TextDecoder();\n\n/**\n * Convert a utf-8 array to string\n *\n * @param input - Utf-8 Array\n * @returns The converted string\n */\nexport function utf8ArrayToString(\n input: NodeJS.ArrayBufferView | ArrayBuffer\n): string {\n return decoder.decode(input);\n}\n"],"mappings":"AAkBgB,IAAI"}
package/dist/cuid.cjs CHANGED
@@ -1 +1 @@
1
- const e=require(`./cuid-BuvbHUZ8.cjs`);require(`./random-C4CrqJsp.cjs`),exports.cuid=e.t;
1
+ const e=require(`./hash/src/murmurhash.cjs`);require(`./hash/src/neutral.cjs`);const t=require(`./random.cjs`),n=476782367,r=36,i=Math.floor(Math.random()*476782367)+1;function a(e=4,t=Math.random){let n=``;for(;n.length<e;)n+=Math.floor(t()*36).toString(36);return n}function o(t){let n=(t?.globalObj??typeof globalThis>`u`)&&typeof globalThis>`u`?{}:globalThis,r=Object.keys(n).toString();return e.murmurhash(r.length>0?r+a(36,Math.random):a(36,Math.random)).slice(0,36)}function s(){let n=Date.now().toString(36),r=i.toString(36),s=e.murmurhash(`${n+a(36,Math.random)+r+o()}`);return`${t.randomLetter()+s.slice(1,Math.min(s.length-1,36))}`}exports.cuid=s;
package/dist/cuid.d.cts CHANGED
@@ -1,2 +1,20 @@
1
- import { n as cuid, t as FingerprintOptions } from "./cuid-gUcp5l6X.cjs";
2
- export { FingerprintOptions, cuid };
1
+ //#region src/cuid.d.ts
2
+ interface FingerprintOptions {
3
+ globalObj?: any;
4
+ }
5
+ /**
6
+ * Generate a random CUID
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ *
11
+ * // Generate a random CUID
12
+ * const id = cuid();
13
+ * ```
14
+ *
15
+ * @returns A random CUID string
16
+ */
17
+ declare function cuid(): string;
18
+ //#endregion
19
+ export { FingerprintOptions, cuid };
20
+ //# sourceMappingURL=cuid.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cuid.d.cts","names":[],"sources":["../src/cuid.ts"],"sourcesContent":[],"mappings":";UA6DiB,kBAAA;EAAA,SAAA,CAAA,EAAA,GAAA;AA0CjB;;;;;;;;;;;;;iBAAgB,IAAA,CAAA"}
package/dist/cuid.d.mts CHANGED
@@ -1,2 +1,20 @@
1
- import { n as cuid, t as FingerprintOptions } from "./cuid-DT9rtBzf.mjs";
2
- export { FingerprintOptions, cuid };
1
+ //#region src/cuid.d.ts
2
+ interface FingerprintOptions {
3
+ globalObj?: any;
4
+ }
5
+ /**
6
+ * Generate a random CUID
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ *
11
+ * // Generate a random CUID
12
+ * const id = cuid();
13
+ * ```
14
+ *
15
+ * @returns A random CUID string
16
+ */
17
+ declare function cuid(): string;
18
+ //#endregion
19
+ export { FingerprintOptions, cuid };
20
+ //# sourceMappingURL=cuid.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cuid.d.mts","names":[],"sources":["../src/cuid.ts"],"sourcesContent":[],"mappings":";UA6DiB,kBAAA;EAAA,SAAA,CAAA,EAAA,GAAA;AA0CjB;;;;;;;;;;;;;iBAAgB,IAAA,CAAA"}
package/dist/cuid.mjs CHANGED
@@ -1 +1,2 @@
1
- import{t as e}from"./cuid-CcPQdiR_.mjs";import"./random-kTN0s0Jy.mjs";export{e as cuid};
1
+ import{murmurhash as e}from"./hash/src/murmurhash.mjs";import"./hash/src/neutral.mjs";import{randomLetter as t}from"./random.mjs";const n=Math.floor(Math.random()*476782367)+1;function r(e=4,t=Math.random){let n=``;for(;n.length<e;)n+=Math.floor(t()*36).toString(36);return n}function i(t){let n=(t?.globalObj??typeof globalThis>`u`)&&typeof globalThis>`u`?{}:globalThis,i=Object.keys(n).toString();return e(i.length>0?i+r(36,Math.random):r(36,Math.random)).slice(0,36)}function a(){let a=Date.now().toString(36),o=n.toString(36),s=e(`${a+r(36,Math.random)+o+i()}`);return`${t()+s.slice(1,Math.min(s.length-1,36))}`}export{a as cuid};
2
+ //# sourceMappingURL=cuid.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cuid.mjs","names":[],"sources":["../src/cuid.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\nimport { murmurhash } from \"@stryke/hash/neutral\";\nimport { randomLetter } from \"./random\";\n\n/**\n * ~22k hosts before 50% chance of initial counter collision with a remaining counter range of 9.0e+15 in JavaScript.\n */\nconst INITIAL_COUNT_MAX = 476_782_367;\n\n/**\n * The length of the CUID fingerprint.\n */\nconst CUID_LARGE_LENGTH = 36;\n\n/**\n * The sequence of the current running generator.\n *\n * @defaultValue 1\n */\nconst sequence = 1;\n\n/**\n * The counter used to help prevent collisions.\n */\nconst counter = Math.floor(Math.random() * INITIAL_COUNT_MAX) + sequence;\n\n/**\n * Generate a random letter\n *\n * @param length - The length of the random string to generate\n * @param random - The random number generator\n * @returns A random letter\n */\nfunction createEntropy(length = 4, random = Math.random) {\n let entropy = \"\";\n\n while (entropy.length < length) {\n entropy += Math.floor(random() * CUID_LARGE_LENGTH).toString(\n CUID_LARGE_LENGTH\n );\n }\n return entropy;\n}\n\nexport interface FingerprintOptions {\n globalObj?: any;\n}\n\n/**\n * This is a fingerprint of the host environment. It is used to help prevent collisions when generating ids in a distributed system.\n *\n * @remarks\n * If no global object is available, you can pass in your own, or fall back on a random string.\n *\n * @param options - Options\n * @returns The environment's Fingerprint\n */\nfunction fingerprint(options?: FingerprintOptions): string {\n const globalObj =\n (options?.globalObj ?? typeof globalThis === \"undefined\")\n ? typeof globalThis === \"undefined\"\n ? {}\n : globalThis\n : globalThis;\n\n const globals = Object.keys(globalObj).toString();\n const sourceString =\n globals.length > 0\n ? globals + createEntropy(CUID_LARGE_LENGTH, Math.random)\n : createEntropy(CUID_LARGE_LENGTH, Math.random);\n\n return murmurhash(sourceString).slice(0, Math.max(0, CUID_LARGE_LENGTH));\n}\n\n/**\n * Generate a random CUID\n *\n * @example\n * ```typescript\n *\n * // Generate a random CUID\n * const id = cuid();\n * ```\n *\n * @returns A random CUID string\n */\nexport function cuid(): string {\n // If we're lucky, the `.toString(36)` calls may reduce hashing rounds\n // by shortening the input to the hash function a little.\n const time = Date.now().toString(CUID_LARGE_LENGTH);\n const count = counter.toString(CUID_LARGE_LENGTH);\n\n // The salt should be long enough to be globally unique across the full\n // length of the hash. For simplicity, we use the same length as the\n // intended id output.\n const salt = createEntropy(CUID_LARGE_LENGTH, Math.random);\n\n const hashed = murmurhash(`${time + salt + count + fingerprint()}`);\n\n return `${\n randomLetter() +\n hashed.slice(1, Math.min(hashed.length - 1, CUID_LARGE_LENGTH))\n }`;\n}\n"],"mappings":"kIAwBA,MAiBM,EAAU,KAAK,MAAM,KAAK,QAAQ,CAAG,UAAkB,CAL5C,EAcjB,SAAS,EAAc,EAAS,EAAG,EAAS,KAAK,OAAQ,CACvD,IAAI,EAAU,GAEd,KAAO,EAAQ,OAAS,GACtB,GAAW,KAAK,MAAM,GAAQ,CAAG,GAAkB,CAAC,SAClD,GACD,CAEH,OAAO,EAgBT,SAAS,EAAY,EAAsC,CACzD,IAAM,GACH,GAAS,WAAa,OAAO,WAAe,MACzC,OAAO,WAAe,IACpB,EAAE,CACF,WAGF,EAAU,OAAO,KAAK,EAAU,CAAC,UAAU,CAMjD,OAAO,EAJL,EAAQ,OAAS,EACb,EAAU,EAAc,GAAmB,KAAK,OAAO,CACvD,EAAc,GAAmB,KAAK,OAAO,CAEpB,CAAC,MAAM,EAAG,GAA+B,CAe1E,SAAgB,GAAe,CAG7B,IAAM,EAAO,KAAK,KAAK,CAAC,SAAS,GAAkB,CAC7C,EAAQ,EAAQ,SAAS,GAAkB,CAO3C,EAAS,EAAW,GAAG,EAFhB,EAAc,GAAmB,KAAK,OAAO,CAEf,EAAQ,GAAa,GAAG,CAEnE,MAAO,GACL,GAAc,CACd,EAAO,MAAM,EAAG,KAAK,IAAI,EAAO,OAAS,EAAG,GAAkB,CAAC"}
@@ -0,0 +1 @@
1
+ const e=require(`../../_virtual/rolldown_runtime.cjs`);require(`../../type-checks/src/index.cjs`),require(`defu`),require(`glob`);
@@ -0,0 +1 @@
1
+ import"../../type-checks/src/index.mjs";import"defu";import"glob";export{};
@@ -0,0 +1 @@
1
+ require(`../../convert/src/neutral.cjs`);
@@ -0,0 +1 @@
1
+ import"../../convert/src/neutral.mjs";export{};
@@ -0,0 +1 @@
1
+ require(`../../fs/src/list-files.cjs`),require(`./murmurhash.cjs`);
@@ -0,0 +1 @@
1
+ import"../../fs/src/list-files.mjs";import"./murmurhash.mjs";export{};
@@ -0,0 +1 @@
1
+ const e=require(`../../_virtual/rolldown_runtime.cjs`);let t=require(`ohash`);function n(e,n){let r=(0,t.hash)(e),i=n?.maxLength??32;return r.length>i?r.slice(0,i):r}exports.murmurhash=n;
@@ -0,0 +1,2 @@
1
+ import{hash as e}from"ohash";function t(t,n){let r=e(t),i=n?.maxLength??32;return r.length>i?r.slice(0,i):r}export{t as murmurhash};
2
+ //# sourceMappingURL=murmurhash.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"murmurhash.mjs","names":["ohash"],"sources":["../../../../hash/src/murmurhash.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\nimport { hash as ohash } from \"ohash\";\n\nexport interface HashOptions {\n /**\n * The maximum length of the hash\n *\n * @defaultValue 32\n */\n maxLength?: number;\n}\n\n/**\n * Use a [MurmurHash3](https://en.wikipedia.org/wiki/MurmurHash) based algorithm to hash any JS value into a string.\n *\n * @see https://github.com/ohash/ohash\n * @see https://en.wikipedia.org/wiki/MurmurHash\n *\n * @param content - The value to hash\n * @param options - Hashing options\n * @returns A hashed string value\n */\nexport function murmurhash(content: any, options?: HashOptions): string {\n const result = ohash(content);\n const maxLength = options?.maxLength ?? 32;\n\n return result.length > maxLength ? result.slice(0, maxLength) : result;\n}\n"],"mappings":"6BAuCA,SAAgB,EAAW,EAAc,EAA+B,CACtE,IAAM,EAASA,EAAM,EAAQ,CACvB,EAAY,GAAS,WAAa,GAExC,OAAO,EAAO,OAAS,EAAY,EAAO,MAAM,EAAG,EAAU,CAAG"}
@@ -0,0 +1 @@
1
+ require(`./digest.cjs`);const e=require(`./murmurhash.cjs`);require(`./hash-files.cjs`),require(`./xx-hash.cjs`);
@@ -0,0 +1 @@
1
+ import"./digest.mjs";import{murmurhash as e}from"./murmurhash.mjs";import"./hash-files.mjs";import"./xx-hash.mjs";export{};
@@ -0,0 +1 @@
1
+ require(`js-xxhash`);
@@ -0,0 +1 @@
1
+ import"js-xxhash";export{};
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- const e=require(`./cuid-BuvbHUZ8.cjs`),t=require(`./random-C4CrqJsp.cjs`),n=require(`./nanoid-client-DxgQ8Vt2.cjs`),r=require(`./snowflake-CLDXd54w.cjs`),i=require(`./uuid-BnD3hGTH.cjs`);exports.DEFAULT_EPOCH=r.t,exports.DEFAULT_SHARD_ID=r.n,exports.cuid=e.t,exports.deconstructSnowflake=r.r,exports.getNonCryptoRandomValues=t.t,exports.isValidSnowflake=r.i,exports.nanoid=n.t,exports.randomCharacters=t.n,exports.randomInteger=t.r,exports.randomLetter=t.i,exports.snowflake=r.a,exports.uuid=i.t;
1
+ const e=require(`./random.cjs`),t=require(`./cuid.cjs`),n=require(`./nanoid-client.cjs`),r=require(`./snowflake.cjs`),i=require(`./uuid.cjs`);exports.DEFAULT_EPOCH=r.DEFAULT_EPOCH,exports.DEFAULT_SHARD_ID=r.DEFAULT_SHARD_ID,exports.cuid=t.cuid,exports.deconstructSnowflake=r.deconstructSnowflake,exports.getNonCryptoRandomValues=e.getNonCryptoRandomValues,exports.isValidSnowflake=r.isValidSnowflake,exports.nanoid=n.nanoid,exports.randomCharacters=e.randomCharacters,exports.randomInteger=e.randomInteger,exports.randomLetter=e.randomLetter,exports.snowflake=r.snowflake,exports.uuid=i.uuid;
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import { n as cuid, t as FingerprintOptions } from "./cuid-gUcp5l6X.cjs";
2
- import { t as nanoid } from "./nanoid-client-mNAgNxsW.cjs";
3
- import { i as randomLetter, n as randomCharacters, r as randomInteger, t as getNonCryptoRandomValues } from "./random-Bd2-oY2n.cjs";
4
- import { a as SnowflakeResolvable, c as snowflake, i as SnowflakeGeneratorOptions, n as DEFAULT_SHARD_ID, o as deconstructSnowflake, r as DeconstructedSnowflake, s as isValidSnowflake, t as DEFAULT_EPOCH } from "./snowflake-DQmoRlnq.cjs";
5
- import { t as uuid } from "./uuid-DCE9JeUQ.cjs";
1
+ import { FingerprintOptions, cuid } from "./cuid.cjs";
2
+ import { nanoid } from "./nanoid-client.cjs";
3
+ import { getNonCryptoRandomValues, randomCharacters, randomInteger, randomLetter } from "./random.cjs";
4
+ import { DEFAULT_EPOCH, DEFAULT_SHARD_ID, DeconstructedSnowflake, SnowflakeGeneratorOptions, SnowflakeResolvable, deconstructSnowflake, isValidSnowflake, snowflake } from "./snowflake.cjs";
5
+ import { uuid } from "./uuid.cjs";
6
6
  export { DEFAULT_EPOCH, DEFAULT_SHARD_ID, DeconstructedSnowflake, FingerprintOptions, SnowflakeGeneratorOptions, SnowflakeResolvable, cuid, deconstructSnowflake, getNonCryptoRandomValues, isValidSnowflake, nanoid, randomCharacters, randomInteger, randomLetter, snowflake, uuid };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { n as cuid, t as FingerprintOptions } from "./cuid-DT9rtBzf.mjs";
2
- import { t as nanoid } from "./nanoid-client-nC1JFvZD.mjs";
3
- import { i as randomLetter, n as randomCharacters, r as randomInteger, t as getNonCryptoRandomValues } from "./random-DTxCCJYh.mjs";
4
- import { a as SnowflakeResolvable, c as snowflake, i as SnowflakeGeneratorOptions, n as DEFAULT_SHARD_ID, o as deconstructSnowflake, r as DeconstructedSnowflake, s as isValidSnowflake, t as DEFAULT_EPOCH } from "./snowflake-B6ivA7bE.mjs";
5
- import { t as uuid } from "./uuid-ByPTbUGJ.mjs";
1
+ import { FingerprintOptions, cuid } from "./cuid.mjs";
2
+ import { nanoid } from "./nanoid-client.mjs";
3
+ import { getNonCryptoRandomValues, randomCharacters, randomInteger, randomLetter } from "./random.mjs";
4
+ import { DEFAULT_EPOCH, DEFAULT_SHARD_ID, DeconstructedSnowflake, SnowflakeGeneratorOptions, SnowflakeResolvable, deconstructSnowflake, isValidSnowflake, snowflake } from "./snowflake.mjs";
5
+ import { uuid } from "./uuid.mjs";
6
6
  export { DEFAULT_EPOCH, DEFAULT_SHARD_ID, DeconstructedSnowflake, FingerprintOptions, SnowflakeGeneratorOptions, SnowflakeResolvable, cuid, deconstructSnowflake, getNonCryptoRandomValues, isValidSnowflake, nanoid, randomCharacters, randomInteger, randomLetter, snowflake, uuid };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{t as e}from"./cuid-CcPQdiR_.mjs";import{i as t,n,r,t as i}from"./random-kTN0s0Jy.mjs";import{t as a}from"./nanoid-client-bEHxSBYB.mjs";import{a as o,i as s,n as c,r as l,t as u}from"./snowflake-BtoDXB99.mjs";import{t as d}from"./uuid-DSMliG_W.mjs";export{u as DEFAULT_EPOCH,c as DEFAULT_SHARD_ID,e as cuid,l as deconstructSnowflake,i as getNonCryptoRandomValues,s as isValidSnowflake,a as nanoid,n as randomCharacters,r as randomInteger,t as randomLetter,o as snowflake,d as uuid};
1
+ import{getNonCryptoRandomValues as e,randomCharacters as t,randomInteger as n,randomLetter as r}from"./random.mjs";import{cuid as i}from"./cuid.mjs";import{nanoid as a}from"./nanoid-client.mjs";import{DEFAULT_EPOCH as o,DEFAULT_SHARD_ID as s,deconstructSnowflake as c,isValidSnowflake as l,snowflake as u}from"./snowflake.mjs";import{uuid as d}from"./uuid.mjs";export{o as DEFAULT_EPOCH,s as DEFAULT_SHARD_ID,i as cuid,c as deconstructSnowflake,e as getNonCryptoRandomValues,l as isValidSnowflake,a as nanoid,t as randomCharacters,n as randomInteger,r as randomLetter,u as snowflake,d as uuid};
@@ -1 +1 @@
1
- require(`./random-C4CrqJsp.cjs`);const e=require(`./nanoid-client-DxgQ8Vt2.cjs`);exports.nanoid=e.t;
1
+ const e=require(`./random.cjs`);function t(t=21){return e.getNonCryptoRandomValues(new Uint8Array(t)).reduce((e,t)=>(t&=63,t<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+=`-`:e+=`_`,e),``)}exports.nanoid=t;
@@ -1,2 +1,11 @@
1
- import { t as nanoid } from "./nanoid-client-mNAgNxsW.cjs";
2
- export { nanoid };
1
+ //#region src/nanoid-client.d.ts
2
+ /**
3
+ * A wrapper around the [nanoid](https://github.com/ai/nanoid) package with some modifications.
4
+ *
5
+ * @param size - The size of the string to generate
6
+ * @returns A unique identifier following the nanoid format
7
+ */
8
+ declare function nanoid(size?: number): string;
9
+ //#endregion
10
+ export { nanoid };
11
+ //# sourceMappingURL=nanoid-client.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nanoid-client.d.cts","names":[],"sources":["../src/nanoid-client.ts"],"sourcesContent":[],"mappings":";;AAgCA;;;;;iBAAgB,MAAA"}
@@ -1,2 +1,11 @@
1
- import { t as nanoid } from "./nanoid-client-nC1JFvZD.mjs";
2
- export { nanoid };
1
+ //#region src/nanoid-client.d.ts
2
+ /**
3
+ * A wrapper around the [nanoid](https://github.com/ai/nanoid) package with some modifications.
4
+ *
5
+ * @param size - The size of the string to generate
6
+ * @returns A unique identifier following the nanoid format
7
+ */
8
+ declare function nanoid(size?: number): string;
9
+ //#endregion
10
+ export { nanoid };
11
+ //# sourceMappingURL=nanoid-client.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nanoid-client.d.mts","names":[],"sources":["../src/nanoid-client.ts"],"sourcesContent":[],"mappings":";;AAgCA;;;;;iBAAgB,MAAA"}
@@ -1 +1,2 @@
1
- import"./random-kTN0s0Jy.mjs";import{t as e}from"./nanoid-client-bEHxSBYB.mjs";export{e as nanoid};
1
+ import{getNonCryptoRandomValues as e}from"./random.mjs";function t(t=21){return e(new Uint8Array(t)).reduce((e,t)=>(t&=63,t<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+=`-`:e+=`_`,e),``)}export{t as nanoid};
2
+ //# sourceMappingURL=nanoid-client.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nanoid-client.mjs","names":[],"sources":["../src/nanoid-client.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\nimport { getNonCryptoRandomValues } from \"./random\";\n\n// This is taken from https://github.com/ai/nanoid/blob/main/index.browser.js We\n// copy this because we want to use `--platform=neutral` which doesn't work with\n// the npm package.\n// Also we changed the random number generator to use Math.random() for compat\n// with React Native.\n\n/**\n * A wrapper around the [nanoid](https://github.com/ai/nanoid) package with some modifications.\n *\n * @param size - The size of the string to generate\n * @returns A unique identifier following the nanoid format\n */\nexport function nanoid(size = 21): string {\n // Use our custom getRandomValues function to fill a Uint8Array with random values.\n const randomBytes = getNonCryptoRandomValues(new Uint8Array(size));\n\n return randomBytes.reduce((id, byte) => {\n // It is incorrect to use bytes exceeding the alphabet size.\n // The following mask reduces the random byte in the 0-255 value\n // range to the 0-63 value range. Therefore, adding hacks, such\n // as empty string fallback or magic numbers, is unnecessary because\n // the bitmask trims bytes down to the alphabet size.\n byte &= 63;\n if (byte < 36) {\n // `0-9a-z`\n id += byte.toString(36);\n } else if (byte < 62) {\n // `A-Z`\n id += (byte - 26).toString(36).toUpperCase();\n } else if (byte > 62) {\n id += \"-\";\n } else {\n id += \"_\";\n }\n return id;\n }, \"\");\n}\n"],"mappings":"wDAgCA,SAAgB,EAAO,EAAO,GAAY,CAIxC,OAFoB,EAAyB,IAAI,WAAW,EAAK,CAAC,CAE/C,QAAQ,EAAI,KAM7B,GAAQ,GACJ,EAAO,GAET,GAAM,EAAK,SAAS,GAAG,CACd,EAAO,GAEhB,IAAO,EAAO,IAAI,SAAS,GAAG,CAAC,aAAa,CACnC,EAAO,GAChB,GAAM,IAEN,GAAM,IAED,GACN,GAAG"}
package/dist/random.cjs CHANGED
@@ -1 +1 @@
1
- const e=require(`./random-C4CrqJsp.cjs`);exports.getNonCryptoRandomValues=e.t,exports.randomCharacters=e.n,exports.randomInteger=e.r,exports.randomLetter=e.i;
1
+ const e=Array.from({length:26},(e,t)=>String.fromCodePoint(t+97)),t=(e,t=0)=>Math.floor(Math.random()*(e-t+1)+t),n=(t=Math.random)=>e[Math.floor(t()*e.length)];function r(e){if(e===null)throw TypeError(`array cannot be null`);for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*256);return e}function i(e){let t=``,n=0;for(;n<e;)t+=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`.charAt(Math.floor(Math.random()*62)),n+=1;return t}exports.getNonCryptoRandomValues=r,exports.randomCharacters=i,exports.randomInteger=t,exports.randomLetter=n;
package/dist/random.d.cts CHANGED
@@ -1,2 +1,33 @@
1
- import { i as randomLetter, n as randomCharacters, r as randomInteger, t as getNonCryptoRandomValues } from "./random-Bd2-oY2n.cjs";
2
- export { getNonCryptoRandomValues, randomCharacters, randomInteger, randomLetter };
1
+ //#region src/random.d.ts
2
+ /**
3
+ * Generate a random integer
4
+ *
5
+ * @param maximum - The maximum value (inclusive)
6
+ * @param minimum - The minimum value (inclusive)
7
+ * @returns A random integer
8
+ */
9
+ declare const randomInteger: (maximum: number, minimum?: number) => number;
10
+ /**
11
+ * Generate a random letter
12
+ *
13
+ * @param random - The random number generator
14
+ * @returns A random letter
15
+ */
16
+ declare const randomLetter: (random?: () => number) => string | undefined;
17
+ /**
18
+ * Generate a random string
19
+ *
20
+ * @param array - The array to fill with random values
21
+ * @returns The array filled with random values
22
+ */
23
+ declare function getNonCryptoRandomValues(array: Uint8Array): Uint8Array<ArrayBufferLike>;
24
+ /**
25
+ * Generate a series of random characters
26
+ *
27
+ * @param length - The length of the random characters
28
+ * @returns A series of random characters
29
+ */
30
+ declare function randomCharacters(length: number): string;
31
+ //#endregion
32
+ export { getNonCryptoRandomValues, randomCharacters, randomInteger, randomLetter };
33
+ //# sourceMappingURL=random.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"random.d.cts","names":[],"sources":["../src/random.ts"],"sourcesContent":[],"mappings":";;AA6BA;AASA;AASA;;;;AAA0D,cAlB7C,aAkB6C,EAAA,CAAA,OAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAAA,MAAA,EAAA,GAAA,MAAA;AAmB1D;;;;;;cA5Ba;;;;;;;iBASG,wBAAA,QAAgC,aAAU,WAAA;;;;;;;iBAmB1C,gBAAA"}
package/dist/random.d.mts CHANGED
@@ -1,2 +1,33 @@
1
- import { i as randomLetter, n as randomCharacters, r as randomInteger, t as getNonCryptoRandomValues } from "./random-DTxCCJYh.mjs";
2
- export { getNonCryptoRandomValues, randomCharacters, randomInteger, randomLetter };
1
+ //#region src/random.d.ts
2
+ /**
3
+ * Generate a random integer
4
+ *
5
+ * @param maximum - The maximum value (inclusive)
6
+ * @param minimum - The minimum value (inclusive)
7
+ * @returns A random integer
8
+ */
9
+ declare const randomInteger: (maximum: number, minimum?: number) => number;
10
+ /**
11
+ * Generate a random letter
12
+ *
13
+ * @param random - The random number generator
14
+ * @returns A random letter
15
+ */
16
+ declare const randomLetter: (random?: () => number) => string | undefined;
17
+ /**
18
+ * Generate a random string
19
+ *
20
+ * @param array - The array to fill with random values
21
+ * @returns The array filled with random values
22
+ */
23
+ declare function getNonCryptoRandomValues(array: Uint8Array): Uint8Array<ArrayBufferLike>;
24
+ /**
25
+ * Generate a series of random characters
26
+ *
27
+ * @param length - The length of the random characters
28
+ * @returns A series of random characters
29
+ */
30
+ declare function randomCharacters(length: number): string;
31
+ //#endregion
32
+ export { getNonCryptoRandomValues, randomCharacters, randomInteger, randomLetter };
33
+ //# sourceMappingURL=random.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"random.d.mts","names":[],"sources":["../src/random.ts"],"sourcesContent":[],"mappings":";;AA6BA;AASA;AASA;;;;AAA0D,cAlB7C,aAkB6C,EAAA,CAAA,OAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAAA,MAAA,EAAA,GAAA,MAAA;AAmB1D;;;;;;cA5Ba;;;;;;;iBASG,wBAAA,QAAgC,aAAU,WAAA;;;;;;;iBAmB1C,gBAAA"}
package/dist/random.mjs CHANGED
@@ -1 +1,2 @@
1
- import{i as e,n as t,r as n,t as r}from"./random-kTN0s0Jy.mjs";export{r as getNonCryptoRandomValues,t as randomCharacters,n as randomInteger,e as randomLetter};
1
+ const e=Array.from({length:26},(e,t)=>String.fromCodePoint(t+97)),t=(e,t=0)=>Math.floor(Math.random()*(e-t+1)+t),n=(t=Math.random)=>e[Math.floor(t()*e.length)];function r(e){if(e===null)throw TypeError(`array cannot be null`);for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*256);return e}function i(e){let t=``,n=0;for(;n<e;)t+=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`.charAt(Math.floor(Math.random()*62)),n+=1;return t}export{r as getNonCryptoRandomValues,i as randomCharacters,t as randomInteger,n as randomLetter};
2
+ //# sourceMappingURL=random.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"random.mjs","names":[],"sources":["../src/random.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\nconst alphabet = Array.from({ length: 26 }, (_x, i) =>\n String.fromCodePoint(i + 97)\n);\n\n/**\n * Generate a random integer\n *\n * @param maximum - The maximum value (inclusive)\n * @param minimum - The minimum value (inclusive)\n * @returns A random integer\n */\nexport const randomInteger = (maximum: number, minimum = 0) =>\n Math.floor(Math.random() * (maximum - minimum + 1) + minimum);\n\n/**\n * Generate a random letter\n *\n * @param random - The random number generator\n * @returns A random letter\n */\nexport const randomLetter = (random: () => number = Math.random) =>\n alphabet[Math.floor(random() * alphabet.length)];\n\n/**\n * Generate a random string\n *\n * @param array - The array to fill with random values\n * @returns The array filled with random values\n */\nexport function getNonCryptoRandomValues(array: Uint8Array) {\n if (array === null) {\n throw new TypeError(\"array cannot be null\");\n }\n\n // Fill the array with random values\n for (let i = 0; i < array.length; i++) {\n array[i] = Math.floor(Math.random() * 256); // Random byte (0-255)\n }\n\n return array;\n}\n\n/**\n * Generate a series of random characters\n *\n * @param length - The length of the random characters\n * @returns A series of random characters\n */\nexport function randomCharacters(length: number) {\n let result = \"\";\n const characters =\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\n const charactersLength = characters.length;\n let counter = 0;\n while (counter < length) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength));\n counter += 1;\n }\n return result;\n}\n"],"mappings":"AAkBA,MAAM,EAAW,MAAM,KAAK,CAAE,OAAQ,GAAI,EAAG,EAAI,IAC/C,OAAO,cAAc,EAAI,GAAG,CAC7B,CASY,GAAiB,EAAiB,EAAU,IACvD,KAAK,MAAM,KAAK,QAAQ,EAAI,EAAU,EAAU,GAAK,EAAQ,CAQlD,GAAgB,EAAuB,KAAK,SACvD,EAAS,KAAK,MAAM,GAAQ,CAAG,EAAS,OAAO,EAQjD,SAAgB,EAAyB,EAAmB,CAC1D,GAAI,IAAU,KACZ,MAAU,UAAU,uBAAuB,CAI7C,IAAK,IAAI,EAAI,EAAG,EAAI,EAAM,OAAQ,IAChC,EAAM,GAAK,KAAK,MAAM,KAAK,QAAQ,CAAG,IAAI,CAG5C,OAAO,EAST,SAAgB,EAAiB,EAAgB,CAC/C,IAAI,EAAS,GAIT,EAAU,EACd,KAAO,EAAU,GACf,GAAU,iEAAW,OAAO,KAAK,MAAM,KAAK,QAAQ,CAAG,GAAiB,CAAC,CACzE,GAAW,EAEb,OAAO"}
@@ -1 +1 @@
1
- const e=require(`./snowflake-CLDXd54w.cjs`);exports.DEFAULT_EPOCH=e.t,exports.DEFAULT_SHARD_ID=e.n,exports.deconstructSnowflake=e.r,exports.isValidSnowflake=e.i,exports.snowflake=e.a;
1
+ const e=1,t=Date.UTC(1970,0,1).valueOf();let n=1;function r(e){let t=BigInt(e).toString(2);return t.length<64?`0000000000000000000000000000000000000000000000000000000000000000`.slice(0,Math.max(0,64-t.length))+t:t}function i(e,t,n){return Number.parseInt(n?r(e).slice(t,t+n):r(e).slice(Math.max(0,t)),2)}function a(e={}){let{shardId:r,epoch:i,timestamp:a}=e??{},o=BigInt(a?a instanceof Date?a.valueOf():new Date(a).valueOf():Date.now())-BigInt(i??t)<<BigInt(22);return o|=BigInt((r??1)%1024)<<BigInt(12),o|=BigInt(n++%4096),o.toString()}function o(e){let t=r(e);return{snowflake:e,timestamp:i(e,1,41),shard_id:i(e,42,10),sequence:i(e,52),binary:t}}function s(e){if(!/^\d{19}$/.test(e))return!1;try{return o(e),!0}catch{return!1}}exports.DEFAULT_EPOCH=t,exports.DEFAULT_SHARD_ID=1,exports.deconstructSnowflake=o,exports.isValidSnowflake=s,exports.snowflake=a;
@@ -1,2 +1,102 @@
1
- import { a as SnowflakeResolvable, c as snowflake, i as SnowflakeGeneratorOptions, n as DEFAULT_SHARD_ID, o as deconstructSnowflake, r as DeconstructedSnowflake, s as isValidSnowflake, t as DEFAULT_EPOCH } from "./snowflake-DQmoRlnq.cjs";
2
- export { DEFAULT_EPOCH, DEFAULT_SHARD_ID, DeconstructedSnowflake, SnowflakeGeneratorOptions, SnowflakeResolvable, deconstructSnowflake, isValidSnowflake, snowflake };
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 { DEFAULT_EPOCH, DEFAULT_SHARD_ID, DeconstructedSnowflake, SnowflakeGeneratorOptions, SnowflakeResolvable, deconstructSnowflake, isValidSnowflake, snowflake };
102
+ //# sourceMappingURL=snowflake.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snowflake.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"}
@@ -1,2 +1,102 @@
1
- import { a as SnowflakeResolvable, c as snowflake, i as SnowflakeGeneratorOptions, n as DEFAULT_SHARD_ID, o as deconstructSnowflake, r as DeconstructedSnowflake, s as isValidSnowflake, t as DEFAULT_EPOCH } from "./snowflake-B6ivA7bE.mjs";
2
- export { DEFAULT_EPOCH, DEFAULT_SHARD_ID, DeconstructedSnowflake, SnowflakeGeneratorOptions, SnowflakeResolvable, deconstructSnowflake, isValidSnowflake, snowflake };
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 { DEFAULT_EPOCH, DEFAULT_SHARD_ID, DeconstructedSnowflake, SnowflakeGeneratorOptions, SnowflakeResolvable, deconstructSnowflake, isValidSnowflake, snowflake };
102
+ //# sourceMappingURL=snowflake.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snowflake.d.mts","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"}