@stryke/hash 0.12.52 → 0.13.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.
Files changed (118) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/index.cjs +20 -19
  3. package/dist/index.d.cts +2 -7
  4. package/dist/index.d.mts +2 -7
  5. package/dist/index.mjs +2 -7
  6. package/dist/neutral-CDggl_ee.cjs +739 -0
  7. package/dist/neutral-D7D-RtyE.mjs +601 -0
  8. package/dist/neutral-D7D-RtyE.mjs.map +1 -0
  9. package/dist/neutral-DqpQs0yN.d.cts +162 -0
  10. package/dist/neutral-DqpQs0yN.d.cts.map +1 -0
  11. package/dist/neutral-DvfYl4mT.d.mts +162 -0
  12. package/dist/neutral-DvfYl4mT.d.mts.map +1 -0
  13. package/dist/neutral.cjs +20 -14
  14. package/dist/neutral.d.cts +2 -5
  15. package/dist/neutral.d.mts +2 -5
  16. package/dist/neutral.mjs +2 -5
  17. package/dist/node.cjs +659 -0
  18. package/dist/node.d.cts +172 -0
  19. package/dist/node.d.cts.map +1 -0
  20. package/dist/node.d.mts +172 -0
  21. package/dist/node.d.mts.map +1 -0
  22. package/dist/node.mjs +613 -0
  23. package/dist/node.mjs.map +1 -0
  24. package/package.json +41 -24
  25. package/dist/_virtual/rolldown_runtime.cjs +0 -29
  26. package/dist/convert/src/array-buffer-to-string.cjs +0 -19
  27. package/dist/convert/src/array-buffer-to-string.mjs +0 -19
  28. package/dist/convert/src/array-buffer-to-string.mjs.map +0 -1
  29. package/dist/convert/src/neutral.cjs +0 -5
  30. package/dist/convert/src/neutral.mjs +0 -7
  31. package/dist/convert/src/parse-type-definition.cjs +0 -1
  32. package/dist/convert/src/parse-type-definition.mjs +0 -3
  33. package/dist/convert/src/string-to-uint8-array.cjs +0 -14
  34. package/dist/convert/src/string-to-uint8-array.mjs +0 -14
  35. package/dist/convert/src/string-to-uint8-array.mjs.map +0 -1
  36. package/dist/convert/src/string-to-utf8-array.cjs +0 -5
  37. package/dist/convert/src/string-to-utf8-array.mjs +0 -6
  38. package/dist/convert/src/string-to-utf8-array.mjs.map +0 -1
  39. package/dist/convert/src/utf8-array-to-string.cjs +0 -5
  40. package/dist/convert/src/utf8-array-to-string.mjs +0 -6
  41. package/dist/convert/src/utf8-array-to-string.mjs.map +0 -1
  42. package/dist/digest.cjs +0 -56
  43. package/dist/digest.d.cts +0 -32
  44. package/dist/digest.d.cts.map +0 -1
  45. package/dist/digest.d.mts +0 -32
  46. package/dist/digest.d.mts.map +0 -1
  47. package/dist/digest.mjs +0 -54
  48. package/dist/digest.mjs.map +0 -1
  49. package/dist/etag.cjs +0 -53
  50. package/dist/etag.d.cts +0 -22
  51. package/dist/etag.d.cts.map +0 -1
  52. package/dist/etag.d.mts +0 -22
  53. package/dist/etag.d.mts.map +0 -1
  54. package/dist/etag.mjs +0 -52
  55. package/dist/etag.mjs.map +0 -1
  56. package/dist/fs/src/list-files.cjs +0 -36
  57. package/dist/fs/src/list-files.d.cts +0 -7
  58. package/dist/fs/src/list-files.d.cts.map +0 -1
  59. package/dist/fs/src/list-files.d.mts +0 -7
  60. package/dist/fs/src/list-files.d.mts.map +0 -1
  61. package/dist/fs/src/list-files.mjs +0 -35
  62. package/dist/fs/src/list-files.mjs.map +0 -1
  63. package/dist/fs/src/read-file.cjs +0 -16
  64. package/dist/fs/src/read-file.mjs +0 -16
  65. package/dist/fs/src/read-file.mjs.map +0 -1
  66. package/dist/hash-files.cjs +0 -41
  67. package/dist/hash-files.d.cts +0 -24
  68. package/dist/hash-files.d.cts.map +0 -1
  69. package/dist/hash-files.d.mts +0 -24
  70. package/dist/hash-files.d.mts.map +0 -1
  71. package/dist/hash-files.mjs +0 -41
  72. package/dist/hash-files.mjs.map +0 -1
  73. package/dist/md5.cjs +0 -17
  74. package/dist/md5.d.cts +0 -12
  75. package/dist/md5.d.cts.map +0 -1
  76. package/dist/md5.d.mts +0 -12
  77. package/dist/md5.d.mts.map +0 -1
  78. package/dist/md5.mjs +0 -17
  79. package/dist/md5.mjs.map +0 -1
  80. package/dist/murmurhash.cjs +0 -22
  81. package/dist/murmurhash.d.cts +0 -23
  82. package/dist/murmurhash.d.cts.map +0 -1
  83. package/dist/murmurhash.d.mts +0 -23
  84. package/dist/murmurhash.d.mts.map +0 -1
  85. package/dist/murmurhash.mjs +0 -22
  86. package/dist/murmurhash.mjs.map +0 -1
  87. package/dist/path/src/is-type.cjs +0 -28
  88. package/dist/path/src/is-type.mjs +0 -29
  89. package/dist/path/src/is-type.mjs.map +0 -1
  90. package/dist/path/src/join-paths.cjs +0 -122
  91. package/dist/path/src/join-paths.mjs +0 -123
  92. package/dist/path/src/join-paths.mjs.map +0 -1
  93. package/dist/path/src/regex.cjs +0 -12
  94. package/dist/path/src/regex.mjs +0 -9
  95. package/dist/path/src/regex.mjs.map +0 -1
  96. package/dist/path/src/slash.cjs +0 -15
  97. package/dist/path/src/slash.mjs +0 -15
  98. package/dist/path/src/slash.mjs.map +0 -1
  99. package/dist/type-checks/src/index.cjs +0 -4
  100. package/dist/type-checks/src/index.mjs +0 -6
  101. package/dist/type-checks/src/is-buffer.cjs +0 -12
  102. package/dist/type-checks/src/is-buffer.mjs +0 -12
  103. package/dist/type-checks/src/is-buffer.mjs.map +0 -1
  104. package/dist/type-checks/src/is-collection.cjs +0 -1
  105. package/dist/type-checks/src/is-collection.mjs +0 -3
  106. package/dist/type-checks/src/is-string.cjs +0 -12
  107. package/dist/type-checks/src/is-string.mjs +0 -12
  108. package/dist/type-checks/src/is-string.mjs.map +0 -1
  109. package/dist/type-checks/src/type-detect.cjs +0 -15
  110. package/dist/type-checks/src/type-detect.mjs +0 -17
  111. package/dist/type-checks/src/type-detect.mjs.map +0 -1
  112. package/dist/xx-hash.cjs +0 -25
  113. package/dist/xx-hash.d.cts +0 -7
  114. package/dist/xx-hash.d.cts.map +0 -1
  115. package/dist/xx-hash.d.mts +0 -7
  116. package/dist/xx-hash.d.mts.map +0 -1
  117. package/dist/xx-hash.mjs +0 -23
  118. package/dist/xx-hash.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"digest.mjs","names":["#algorithm","#chunks"],"sources":["../src/digest.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 {\n arrayBufferToString,\n stringToUint8Array\n} from \"@stryke/convert/neutral\";\n\nexport type AlgorithmIdentifier = \"SHA-256\" | \"SHA-384\" | \"SHA-512\";\n\n/**\n * Creates a new hash object for the specified algorithm.\n *\n * @param algorithm - The algorithm to use for the hash.\n * @returns A new hash object.\n */\nexport function createHasher(algorithm: AlgorithmIdentifier): Hasher {\n return new Hasher(algorithm);\n}\n\n/**\n * Creates a new hash object for the specified algorithm.\n *\n * @remarks\n * This function uses the Web Crypto API to create a hash of the input data.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest\n *\n * @param data - The data to hash.\n * @param algorithm - The algorithm to use for the hash.\n * @returns A hash string representation of the `data` parameter.\n */\nexport async function digest(\n data: string,\n algorithm: AlgorithmIdentifier = \"SHA-512\"\n): Promise<string> {\n const arrayBuffer = await globalThis.crypto.subtle.digest(\n algorithm,\n stringToUint8Array(data) as BufferSource\n );\n\n return arrayBufferToString(arrayBuffer);\n}\n\nexport const hash = digest;\n\nexport class Hasher {\n #chunks: Uint8Array[] = [];\n\n #algorithm: AlgorithmIdentifier;\n\n constructor(algorithm: AlgorithmIdentifier) {\n this.#algorithm = algorithm;\n }\n\n update(data: Uint8Array): void {\n this.#chunks.push(data);\n }\n\n async digest(): Promise<Uint8Array> {\n const data = new Uint8Array(\n this.#chunks.reduce((acc, chunk) => acc + chunk.length, 0)\n );\n let offset = 0;\n for (const chunk of this.#chunks) {\n data.set(chunk, offset);\n offset += chunk.length;\n }\n const arrayBuffer = await globalThis.crypto.subtle.digest(\n this.#algorithm,\n data\n );\n\n return new Uint8Array(arrayBuffer);\n }\n}\n"],"mappings":";;;;;;;;;;;AA+BA,SAAgB,aAAa,WAAwC;AACnE,QAAO,IAAI,OAAO,UAAU;;;;;;;;;;;;;;AAe9B,eAAsB,OACpB,MACA,YAAiC,WAChB;AAMjB,QAAO,oBALa,MAAM,WAAW,OAAO,OAAO,OACjD,WACA,mBAAmB,KAAK,CACzB,CAEsC;;AAGzC,MAAa,OAAO;AAEpB,IAAa,SAAb,MAAoB;CAClB,UAAwB,EAAE;CAE1B;CAEA,YAAY,WAAgC;AAC1C,QAAKA,YAAa;;CAGpB,OAAO,MAAwB;AAC7B,QAAKC,OAAQ,KAAK,KAAK;;CAGzB,MAAM,SAA8B;EAClC,MAAM,OAAO,IAAI,WACf,MAAKA,OAAQ,QAAQ,KAAK,UAAU,MAAM,MAAM,QAAQ,EAAE,CAC3D;EACD,IAAI,SAAS;AACb,OAAK,MAAM,SAAS,MAAKA,QAAS;AAChC,QAAK,IAAI,OAAO,OAAO;AACvB,aAAU,MAAM;;EAElB,MAAM,cAAc,MAAM,WAAW,OAAO,OAAO,OACjD,MAAKD,WACL,KACD;AAED,SAAO,IAAI,WAAW,YAAY"}
package/dist/etag.cjs DELETED
@@ -1,53 +0,0 @@
1
-
2
- //#region src/etag.ts
3
- /**
4
- * FNV-1a Hash implementation
5
- *
6
- * Ported from https://github.com/tjwebb/fnv-plus/blob/master/index.js
7
- *
8
- * @remarks
9
- * Simplified, optimized and add modified for 52 bit, which provides a larger hash space
10
- * and still making use of Javascript's 53-bit integer space.
11
- */
12
- const fnv1a52 = (str) => {
13
- const len = str.length;
14
- let i = 0;
15
- let t0 = 0;
16
- let v0 = 8997;
17
- let t1 = 0;
18
- let v1 = 33826;
19
- let t2 = 0;
20
- let v2 = 40164;
21
- let t3 = 0;
22
- let v3 = 52210;
23
- while (i < len) {
24
- v0 ^= str.charCodeAt(i++);
25
- t0 = v0 * 435;
26
- t1 = v1 * 435;
27
- t2 = v2 * 435;
28
- t3 = v3 * 435;
29
- t2 += v0 << 8;
30
- t3 += v1 << 8;
31
- t1 += t0 >>> 16;
32
- v0 = t0 & 65535;
33
- t2 += t1 >>> 16;
34
- v1 = t1 & 65535;
35
- v3 = t3 + (t2 >>> 16) & 65535;
36
- v2 = t2 & 65535;
37
- }
38
- return (v3 & 15) * 281474976710656 + v2 * 4294967296 + v1 * 65536 + (v0 ^ v3 >> 4);
39
- };
40
- /**
41
- * Generates an ETag for the given payload.
42
- *
43
- * @param payload - The payload to generate an ETag for.
44
- * @param weak - Whether to generate a weak ETag.
45
- * @returns The generated ETag.
46
- */
47
- const generateETag = (payload, weak = false) => {
48
- return `${(weak ? "W/\"" : "\"") + fnv1a52(payload).toString(36) + payload.length.toString(36)}"`;
49
- };
50
-
51
- //#endregion
52
- exports.fnv1a52 = fnv1a52;
53
- exports.generateETag = generateETag;
package/dist/etag.d.cts DELETED
@@ -1,22 +0,0 @@
1
- //#region src/etag.d.ts
2
- /**
3
- * FNV-1a Hash implementation
4
- *
5
- * Ported from https://github.com/tjwebb/fnv-plus/blob/master/index.js
6
- *
7
- * @remarks
8
- * Simplified, optimized and add modified for 52 bit, which provides a larger hash space
9
- * and still making use of Javascript's 53-bit integer space.
10
- */
11
- declare const fnv1a52: (str: string) => number;
12
- /**
13
- * Generates an ETag for the given payload.
14
- *
15
- * @param payload - The payload to generate an ETag for.
16
- * @param weak - Whether to generate a weak ETag.
17
- * @returns The generated ETag.
18
- */
19
- declare const generateETag: (payload: string, weak?: boolean) => string;
20
- //#endregion
21
- export { fnv1a52, generateETag };
22
- //# sourceMappingURL=etag.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"etag.d.cts","names":[],"sources":["../src/etag.ts"],"sourcesContent":[],"mappings":";;AA2BA;AA2CA;;;;;;;cA3Ca;;;;;;;;cA2CA"}
package/dist/etag.d.mts DELETED
@@ -1,22 +0,0 @@
1
- //#region src/etag.d.ts
2
- /**
3
- * FNV-1a Hash implementation
4
- *
5
- * Ported from https://github.com/tjwebb/fnv-plus/blob/master/index.js
6
- *
7
- * @remarks
8
- * Simplified, optimized and add modified for 52 bit, which provides a larger hash space
9
- * and still making use of Javascript's 53-bit integer space.
10
- */
11
- declare const fnv1a52: (str: string) => number;
12
- /**
13
- * Generates an ETag for the given payload.
14
- *
15
- * @param payload - The payload to generate an ETag for.
16
- * @param weak - Whether to generate a weak ETag.
17
- * @returns The generated ETag.
18
- */
19
- declare const generateETag: (payload: string, weak?: boolean) => string;
20
- //#endregion
21
- export { fnv1a52, generateETag };
22
- //# sourceMappingURL=etag.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"etag.d.mts","names":[],"sources":["../src/etag.ts"],"sourcesContent":[],"mappings":";;AA2BA;AA2CA;;;;;;;cA3Ca;;;;;;;;cA2CA"}
package/dist/etag.mjs DELETED
@@ -1,52 +0,0 @@
1
- //#region src/etag.ts
2
- /**
3
- * FNV-1a Hash implementation
4
- *
5
- * Ported from https://github.com/tjwebb/fnv-plus/blob/master/index.js
6
- *
7
- * @remarks
8
- * Simplified, optimized and add modified for 52 bit, which provides a larger hash space
9
- * and still making use of Javascript's 53-bit integer space.
10
- */
11
- const fnv1a52 = (str) => {
12
- const len = str.length;
13
- let i = 0;
14
- let t0 = 0;
15
- let v0 = 8997;
16
- let t1 = 0;
17
- let v1 = 33826;
18
- let t2 = 0;
19
- let v2 = 40164;
20
- let t3 = 0;
21
- let v3 = 52210;
22
- while (i < len) {
23
- v0 ^= str.charCodeAt(i++);
24
- t0 = v0 * 435;
25
- t1 = v1 * 435;
26
- t2 = v2 * 435;
27
- t3 = v3 * 435;
28
- t2 += v0 << 8;
29
- t3 += v1 << 8;
30
- t1 += t0 >>> 16;
31
- v0 = t0 & 65535;
32
- t2 += t1 >>> 16;
33
- v1 = t1 & 65535;
34
- v3 = t3 + (t2 >>> 16) & 65535;
35
- v2 = t2 & 65535;
36
- }
37
- return (v3 & 15) * 281474976710656 + v2 * 4294967296 + v1 * 65536 + (v0 ^ v3 >> 4);
38
- };
39
- /**
40
- * Generates an ETag for the given payload.
41
- *
42
- * @param payload - The payload to generate an ETag for.
43
- * @param weak - Whether to generate a weak ETag.
44
- * @returns The generated ETag.
45
- */
46
- const generateETag = (payload, weak = false) => {
47
- return `${(weak ? "W/\"" : "\"") + fnv1a52(payload).toString(36) + payload.length.toString(36)}"`;
48
- };
49
-
50
- //#endregion
51
- export { fnv1a52, generateETag };
52
- //# sourceMappingURL=etag.mjs.map
package/dist/etag.mjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"etag.mjs","names":[],"sources":["../src/etag.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\n/**\n * FNV-1a Hash implementation\n *\n * Ported from https://github.com/tjwebb/fnv-plus/blob/master/index.js\n *\n * @remarks\n * Simplified, optimized and add modified for 52 bit, which provides a larger hash space\n * and still making use of Javascript's 53-bit integer space.\n */\nexport const fnv1a52 = (str: string) => {\n const len = str.length;\n let i = 0;\n let t0 = 0;\n let v0 = 0x2325;\n let t1 = 0;\n let v1 = 0x8422;\n let t2 = 0;\n let v2 = 0x9ce4;\n let t3 = 0;\n let v3 = 0xcbf2;\n\n while (i < len) {\n v0 ^= str.charCodeAt(i++);\n t0 = v0 * 435;\n t1 = v1 * 435;\n t2 = v2 * 435;\n t3 = v3 * 435;\n t2 += v0 << 8;\n t3 += v1 << 8;\n t1 += t0 >>> 16;\n v0 = t0 & 65535;\n t2 += t1 >>> 16;\n v1 = t1 & 65535;\n v3 = (t3 + (t2 >>> 16)) & 65535;\n v2 = t2 & 65535;\n }\n\n return (\n (v3 & 15) * 281474976710656 +\n v2 * 4294967296 +\n v1 * 65536 +\n (v0 ^ (v3 >> 4))\n );\n};\n\n/**\n * Generates an ETag for the given payload.\n *\n * @param payload - The payload to generate an ETag for.\n * @param weak - Whether to generate a weak ETag.\n * @returns The generated ETag.\n */\nexport const generateETag = (payload: string, weak = false) => {\n const prefix = weak ? 'W/\"' : '\"';\n\n return `${prefix + fnv1a52(payload).toString(36) + payload.length.toString(36)}\"`;\n};\n"],"mappings":";;;;;;;;;;AA2BA,MAAa,WAAW,QAAgB;CACtC,MAAM,MAAM,IAAI;CAChB,IAAI,IAAI;CACR,IAAI,KAAK;CACT,IAAI,KAAK;CACT,IAAI,KAAK;CACT,IAAI,KAAK;CACT,IAAI,KAAK;CACT,IAAI,KAAK;CACT,IAAI,KAAK;CACT,IAAI,KAAK;AAET,QAAO,IAAI,KAAK;AACd,QAAM,IAAI,WAAW,IAAI;AACzB,OAAK,KAAK;AACV,OAAK,KAAK;AACV,OAAK,KAAK;AACV,OAAK,KAAK;AACV,QAAM,MAAM;AACZ,QAAM,MAAM;AACZ,QAAM,OAAO;AACb,OAAK,KAAK;AACV,QAAM,OAAO;AACb,OAAK,KAAK;AACV,OAAM,MAAM,OAAO,MAAO;AAC1B,OAAK,KAAK;;AAGZ,SACG,KAAK,MAAM,kBACZ,KAAK,aACL,KAAK,SACJ,KAAM,MAAM;;;;;;;;;AAWjB,MAAa,gBAAgB,SAAiB,OAAO,UAAU;AAG7D,QAAO,IAFQ,OAAO,SAAQ,QAEX,QAAQ,QAAQ,CAAC,SAAS,GAAG,GAAG,QAAQ,OAAO,SAAS,GAAG,CAAC"}
@@ -1,36 +0,0 @@
1
- const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
- const require_is_string = require('../../type-checks/src/is-string.cjs');
3
- require('../../type-checks/src/index.cjs');
4
- const require_join_paths = require('../../path/src/join-paths.cjs');
5
- let defu = require("defu");
6
- defu = require_rolldown_runtime.__toESM(defu);
7
- let glob = require("glob");
8
-
9
- //#region ../fs/src/list-files.ts
10
- const DEFAULT_OPTIONS = { dot: true };
11
- /**
12
- * A files and directories listing helper function
13
- *
14
- * @param filesGlob - A glob pattern to match files
15
- * @returns A list of file paths
16
- */
17
- async function list(filesGlob, options) {
18
- return (0, glob.glob)(require_is_string.isString(filesGlob) ? filesGlob.includes("*") ? filesGlob : require_join_paths.joinPaths(filesGlob, "**/*") : filesGlob.input ? require_join_paths.joinPaths(filesGlob.input, filesGlob.glob) : filesGlob.glob, (0, defu.default)(require_is_string.isString(filesGlob) ? {} : {
19
- dot: filesGlob.dot,
20
- ignore: filesGlob.ignore
21
- }, options ?? {}, DEFAULT_OPTIONS));
22
- }
23
- /**
24
- * A file listing helper function
25
- *
26
- * @param filesGlob - A glob pattern to match files
27
- * @returns A list of file paths
28
- */
29
- async function listFiles(filesGlob, options) {
30
- const result = (await list(filesGlob, (0, defu.default)({ withFileTypes: true }, options ?? {}))).filter((ret) => ret.isFile());
31
- if (!options?.withFileTypes) return result.map((file) => file.fullpath());
32
- return result;
33
- }
34
-
35
- //#endregion
36
- exports.listFiles = listFiles;
@@ -1,7 +0,0 @@
1
- import { GlobOptions } from "glob";
2
-
3
- //#region ../fs/src/list-files.d.ts
4
- type ListOptions = GlobOptions;
5
- //#endregion
6
- export { ListOptions };
7
- //# sourceMappingURL=list-files.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"list-files.d.cts","names":[],"sources":["../../../../fs/src/list-files.ts"],"sourcesContent":[],"mappings":";;;KAyBY,WAAA,GAAc"}
@@ -1,7 +0,0 @@
1
- import { GlobOptions } from "glob";
2
-
3
- //#region ../fs/src/list-files.d.ts
4
- type ListOptions = GlobOptions;
5
- //#endregion
6
- export { ListOptions };
7
- //# sourceMappingURL=list-files.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"list-files.d.mts","names":[],"sources":["../../../../fs/src/list-files.ts"],"sourcesContent":[],"mappings":";;;KAyBY,WAAA,GAAc"}
@@ -1,35 +0,0 @@
1
- import { isString } from "../../type-checks/src/is-string.mjs";
2
- import "../../type-checks/src/index.mjs";
3
- import { joinPaths } from "../../path/src/join-paths.mjs";
4
- import defu from "defu";
5
- import { glob } from "glob";
6
-
7
- //#region ../fs/src/list-files.ts
8
- const DEFAULT_OPTIONS = { dot: true };
9
- /**
10
- * A files and directories listing helper function
11
- *
12
- * @param filesGlob - A glob pattern to match files
13
- * @returns A list of file paths
14
- */
15
- async function list(filesGlob, options) {
16
- return glob(isString(filesGlob) ? filesGlob.includes("*") ? filesGlob : joinPaths(filesGlob, "**/*") : filesGlob.input ? joinPaths(filesGlob.input, filesGlob.glob) : filesGlob.glob, defu(isString(filesGlob) ? {} : {
17
- dot: filesGlob.dot,
18
- ignore: filesGlob.ignore
19
- }, options ?? {}, DEFAULT_OPTIONS));
20
- }
21
- /**
22
- * A file listing helper function
23
- *
24
- * @param filesGlob - A glob pattern to match files
25
- * @returns A list of file paths
26
- */
27
- async function listFiles(filesGlob, options) {
28
- const result = (await list(filesGlob, defu({ withFileTypes: true }, options ?? {}))).filter((ret) => ret.isFile());
29
- if (!options?.withFileTypes) return result.map((file) => file.fullpath());
30
- return result;
31
- }
32
-
33
- //#endregion
34
- export { listFiles };
35
- //# sourceMappingURL=list-files.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"list-files.mjs","names":["DEFAULT_OPTIONS: ListOptions"],"sources":["../../../../fs/src/list-files.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 { joinPaths } from \"@stryke/path\";\nimport { isString } from \"@stryke/type-checks\";\nimport type { AssetGlob } from \"@stryke/types/file\";\nimport defu from \"defu\";\nimport type { GlobOptions, GlobOptionsWithFileTypesTrue, Path } from \"glob\";\nimport { glob } from \"glob\";\n\nexport type ListOptions = GlobOptions;\nexport type InferListReturnType<TOptions extends GlobOptions> =\n TOptions[\"withFileTypes\"] extends true ? Path[] : string[];\n\nconst DEFAULT_OPTIONS: ListOptions = {\n dot: true\n};\n\n/**\n * A files and directories listing helper function\n *\n * @param filesGlob - A glob pattern to match files\n * @returns A list of file paths\n */\nexport async function list<TOptions extends ListOptions>(\n filesGlob: string | Omit<AssetGlob, \"output\">,\n options?: TOptions\n): Promise<InferListReturnType<TOptions>> {\n return glob(\n isString(filesGlob)\n ? filesGlob.includes(\"*\")\n ? filesGlob\n : joinPaths(filesGlob, \"**/*\")\n : filesGlob.input\n ? joinPaths(filesGlob.input, filesGlob.glob)\n : filesGlob.glob,\n defu(\n isString(filesGlob)\n ? {}\n : { dot: filesGlob.dot, ignore: filesGlob.ignore },\n options ?? {},\n DEFAULT_OPTIONS\n )\n ) as Promise<InferListReturnType<TOptions>>;\n}\n\n/**\n * A synchronous files and directories listing helper function\n *\n * @param filesGlob - A glob pattern to match files\n * @returns A list of file paths\n */\nexport function listSync<TOptions extends ListOptions>(\n filesGlob: string | Omit<AssetGlob, \"output\">,\n options?: TOptions\n): InferListReturnType<TOptions> {\n return glob.sync(\n isString(filesGlob)\n ? filesGlob.includes(\"*\")\n ? filesGlob\n : joinPaths(filesGlob, \"**/*\")\n : filesGlob.input\n ? joinPaths(filesGlob.input, filesGlob.glob)\n : filesGlob.glob,\n defu(\n isString(filesGlob)\n ? {}\n : { dot: filesGlob.dot, ignore: filesGlob.ignore },\n options ?? {},\n DEFAULT_OPTIONS\n )\n ) as InferListReturnType<TOptions>;\n}\n\n/**\n * A file listing helper function\n *\n * @param filesGlob - A glob pattern to match files\n * @returns A list of file paths\n */\nexport async function listFiles<TOptions extends ListOptions>(\n filesGlob: string | Omit<AssetGlob, \"output\">,\n options?: TOptions\n) {\n const result = (\n await list(\n filesGlob,\n defu(\n { withFileTypes: true },\n options ?? {}\n ) as GlobOptionsWithFileTypesTrue\n )\n ).filter(ret => ret.isFile());\n if (!options?.withFileTypes) {\n return result.map(file => file.fullpath()) as InferListReturnType<TOptions>;\n }\n\n return result as InferListReturnType<TOptions>;\n}\n\n/**\n * A synchronous file listing helper function\n *\n * @param filesGlob - A glob pattern to match files\n * @returns A list of file paths\n */\nexport function listFilesSync<TOptions extends ListOptions>(\n filesGlob: string | Omit<AssetGlob, \"output\">,\n options?: TOptions\n) {\n const result = listSync(\n filesGlob,\n defu({ withFileTypes: true }, options ?? {}) as GlobOptionsWithFileTypesTrue\n ).filter(ret => ret.isFile());\n if (!options?.withFileTypes) {\n return result.map(file => file.fullpath()) as InferListReturnType<TOptions>;\n }\n\n return result as InferListReturnType<TOptions>;\n}\n\n/**\n * A directories listing helper function\n *\n * @param filesGlob - A glob pattern to match files\n * @returns A list of file paths\n */\nexport async function listDirectories<TOptions extends ListOptions>(\n filesGlob: string | Omit<AssetGlob, \"output\">,\n options?: TOptions\n) {\n const result = (\n await list(\n filesGlob,\n defu(\n { withFileTypes: true },\n options ?? {}\n ) as GlobOptionsWithFileTypesTrue\n )\n ).filter(ret => ret.isDirectory());\n if (!options?.withFileTypes) {\n return result.map(file => file.fullpath()) as InferListReturnType<TOptions>;\n }\n\n return result as InferListReturnType<TOptions>;\n}\n\n/**\n * A synchronous directories listing helper function\n *\n * @param filesGlob - A glob pattern to match files\n * @returns A list of file paths\n */\nexport function listDirectoriesSync<TOptions extends ListOptions>(\n filesGlob: string | Omit<AssetGlob, \"output\">,\n options?: TOptions\n) {\n const result = listSync(\n filesGlob,\n defu({ withFileTypes: true }, options ?? {}) as GlobOptionsWithFileTypesTrue\n ).filter(ret => ret.isDirectory());\n if (!options?.withFileTypes) {\n return result.map(file => file.fullpath()) as InferListReturnType<TOptions>;\n }\n\n return result as InferListReturnType<TOptions>;\n}\n"],"mappings":";;;;;;;AA6BA,MAAMA,kBAA+B,EACnC,KAAK,MACN;;;;;;;AAQD,eAAsB,KACpB,WACA,SACwC;AACxC,QAAO,KACL,SAAS,UAAU,GACf,UAAU,SAAS,IAAI,GACrB,YACA,UAAU,WAAW,OAAO,GAC9B,UAAU,QACR,UAAU,UAAU,OAAO,UAAU,KAAK,GAC1C,UAAU,MAChB,KACE,SAAS,UAAU,GACf,EAAE,GACF;EAAE,KAAK,UAAU;EAAK,QAAQ,UAAU;EAAQ,EACpD,WAAW,EAAE,EACb,gBACD,CACF;;;;;;;;AAqCH,eAAsB,UACpB,WACA,SACA;CACA,MAAM,UACJ,MAAM,KACJ,WACA,KACE,EAAE,eAAe,MAAM,EACvB,WAAW,EAAE,CACd,CACF,EACD,QAAO,QAAO,IAAI,QAAQ,CAAC;AAC7B,KAAI,CAAC,SAAS,cACZ,QAAO,OAAO,KAAI,SAAQ,KAAK,UAAU,CAAC;AAG5C,QAAO"}
@@ -1,16 +0,0 @@
1
- const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
- let node_fs_promises = require("node:fs/promises");
3
-
4
- //#region ../fs/src/read-file.ts
5
- /**
6
- * Read the given content to the given file path
7
- *
8
- * @param filePath - The file path to read to
9
- */
10
- const readFile = async (filePath) => {
11
- if (!filePath) throw new Error("No file path provided to read data");
12
- return (0, node_fs_promises.readFile)(filePath, { encoding: "utf8" });
13
- };
14
-
15
- //#endregion
16
- exports.readFile = readFile;
@@ -1,16 +0,0 @@
1
- import { readFile } from "node:fs/promises";
2
-
3
- //#region ../fs/src/read-file.ts
4
- /**
5
- * Read the given content to the given file path
6
- *
7
- * @param filePath - The file path to read to
8
- */
9
- const readFile$1 = async (filePath) => {
10
- if (!filePath) throw new Error("No file path provided to read data");
11
- return readFile(filePath, { encoding: "utf8" });
12
- };
13
-
14
- //#endregion
15
- export { readFile$1 as readFile };
16
- //# sourceMappingURL=read-file.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"read-file.mjs","names":["readFile","readFileFs"],"sources":["../../../../fs/src/read-file.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 { existsSync, readFileSync as readFileSyncFs } from \"node:fs\";\nimport { readFile as readFileFs } from \"node:fs/promises\";\n\n/**\n * Read the given content to the given file path\n *\n * @param filePath - The file path to write to\n */\nexport const readFileSync = (filePath: string): string => {\n if (!filePath) {\n throw new Error(\"No file path provided to read data\");\n }\n\n return readFileSyncFs(filePath, { encoding: \"utf8\" });\n};\n\n/**\n * Read the given content to the given file path\n *\n * @param filePath - The file path to read to\n */\nexport const readFile = async (filePath: string): Promise<string> => {\n if (!filePath) {\n throw new Error(\"No file path provided to read data\");\n }\n\n return readFileFs(filePath, { encoding: \"utf8\" });\n};\n\n/**\n * Reads a file if it exists, otherwise returns an empty string.\n *\n * @param path - The path to the file to read.\n * @returns The content of the file if it exists, otherwise an empty string.\n */\nexport function readFileIfExistingSync(path: string) {\n return existsSync(path) ? readFileSync(path) : \"\";\n}\n\n/**\n * Reads a file if it exists, otherwise returns an empty string.\n *\n * @param path - The path to the file to read.\n * @returns The content of the file if it exists, otherwise an empty string.\n */\nexport async function readFileIfExisting(path: string) {\n return existsSync(path) ? readFile(path) : \"\";\n}\n"],"mappings":";;;;;;;;AAuCA,MAAaA,aAAW,OAAO,aAAsC;AACnE,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,qCAAqC;AAGvD,QAAOC,SAAW,UAAU,EAAE,UAAU,QAAQ,CAAC"}
@@ -1,41 +0,0 @@
1
- const require_list_files = require('./fs/src/list-files.cjs');
2
- const require_read_file = require('./fs/src/read-file.cjs');
3
- const require_murmurhash = require('./murmurhash.cjs');
4
-
5
- //#region src/hash-files.ts
6
- /**
7
- * Hash a list of file paths into a string based on the file content
8
- *
9
- * @param files - The list of file paths to hash
10
- * @param options - Hashing options
11
- * @returns A hashed string value
12
- */
13
- async function hashFiles(files, options) {
14
- const result = {};
15
- await Promise.all(files.map(async (file) => {
16
- result[file] = await require_read_file.readFile(file);
17
- }));
18
- return require_murmurhash.murmurhash(result, options);
19
- }
20
- /**
21
- * Hash a folder path into a string based on the file content
22
- *
23
- * @param directoryPath - The folder path to hash
24
- * @param options - Hashing options. By default, the `node_modules`, `.git`, `.nx`, `.cache`, and `tmp` folders is ignored.
25
- * @returns A hashed string value
26
- */
27
- async function hashDirectory(directoryPath, options = {}) {
28
- options.ignore = options.ignore ?? [
29
- "**/node_modules/**",
30
- "**/.git/**",
31
- "**/.nx/**",
32
- "**/.cache/**",
33
- "**/.storm/**",
34
- "**/tmp/**"
35
- ];
36
- return hashFiles(await require_list_files.listFiles(directoryPath, options), options);
37
- }
38
-
39
- //#endregion
40
- exports.hashDirectory = hashDirectory;
41
- exports.hashFiles = hashFiles;
@@ -1,24 +0,0 @@
1
- import { ListOptions } from "./fs/src/list-files.cjs";
2
- import { HashOptions } from "./murmurhash.cjs";
3
-
4
- //#region src/hash-files.d.ts
5
-
6
- /**
7
- * Hash a list of file paths into a string based on the file content
8
- *
9
- * @param files - The list of file paths to hash
10
- * @param options - Hashing options
11
- * @returns A hashed string value
12
- */
13
- declare function hashFiles(files: string[], options?: HashOptions): Promise<string>;
14
- /**
15
- * Hash a folder path into a string based on the file content
16
- *
17
- * @param directoryPath - The folder path to hash
18
- * @param options - Hashing options. By default, the `node_modules`, `.git`, `.nx`, `.cache`, and `tmp` folders is ignored.
19
- * @returns A hashed string value
20
- */
21
- declare function hashDirectory(directoryPath: string, options?: HashOptions & ListOptions): Promise<string>;
22
- //#endregion
23
- export { hashDirectory, hashFiles };
24
- //# sourceMappingURL=hash-files.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hash-files.d.cts","names":[],"sources":["../src/hash-files.ts"],"sourcesContent":[],"mappings":";;;;;;;AA+BA;AAqBA;;;;AAGU,iBAxBY,SAAA,CAwBZ,KAAA,EAAA,MAAA,EAAA,EAAA,OAAA,CAAA,EAtBE,WAsBF,CAAA,EArBP,OAqBO,CAAA,MAAA,CAAA;;;;;;;;iBAHY,aAAA,kCAEX,cAAc,cACtB"}
@@ -1,24 +0,0 @@
1
- import { ListOptions } from "./fs/src/list-files.mjs";
2
- import { HashOptions } from "./murmurhash.mjs";
3
-
4
- //#region src/hash-files.d.ts
5
-
6
- /**
7
- * Hash a list of file paths into a string based on the file content
8
- *
9
- * @param files - The list of file paths to hash
10
- * @param options - Hashing options
11
- * @returns A hashed string value
12
- */
13
- declare function hashFiles(files: string[], options?: HashOptions): Promise<string>;
14
- /**
15
- * Hash a folder path into a string based on the file content
16
- *
17
- * @param directoryPath - The folder path to hash
18
- * @param options - Hashing options. By default, the `node_modules`, `.git`, `.nx`, `.cache`, and `tmp` folders is ignored.
19
- * @returns A hashed string value
20
- */
21
- declare function hashDirectory(directoryPath: string, options?: HashOptions & ListOptions): Promise<string>;
22
- //#endregion
23
- export { hashDirectory, hashFiles };
24
- //# sourceMappingURL=hash-files.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hash-files.d.mts","names":[],"sources":["../src/hash-files.ts"],"sourcesContent":[],"mappings":";;;;;;;AA+BA;AAqBA;;;;AAGU,iBAxBY,SAAA,CAwBZ,KAAA,EAAA,MAAA,EAAA,EAAA,OAAA,CAAA,EAtBE,WAsBF,CAAA,EArBP,OAqBO,CAAA,MAAA,CAAA;;;;;;;;iBAHY,aAAA,kCAEX,cAAc,cACtB"}
@@ -1,41 +0,0 @@
1
- import { listFiles } from "./fs/src/list-files.mjs";
2
- import { readFile } from "./fs/src/read-file.mjs";
3
- import { murmurhash } from "./murmurhash.mjs";
4
-
5
- //#region src/hash-files.ts
6
- /**
7
- * Hash a list of file paths into a string based on the file content
8
- *
9
- * @param files - The list of file paths to hash
10
- * @param options - Hashing options
11
- * @returns A hashed string value
12
- */
13
- async function hashFiles(files, options) {
14
- const result = {};
15
- await Promise.all(files.map(async (file) => {
16
- result[file] = await readFile(file);
17
- }));
18
- return murmurhash(result, options);
19
- }
20
- /**
21
- * Hash a folder path into a string based on the file content
22
- *
23
- * @param directoryPath - The folder path to hash
24
- * @param options - Hashing options. By default, the `node_modules`, `.git`, `.nx`, `.cache`, and `tmp` folders is ignored.
25
- * @returns A hashed string value
26
- */
27
- async function hashDirectory(directoryPath, options = {}) {
28
- options.ignore = options.ignore ?? [
29
- "**/node_modules/**",
30
- "**/.git/**",
31
- "**/.nx/**",
32
- "**/.cache/**",
33
- "**/.storm/**",
34
- "**/tmp/**"
35
- ];
36
- return hashFiles(await listFiles(directoryPath, options), options);
37
- }
38
-
39
- //#endregion
40
- export { hashDirectory, hashFiles };
41
- //# sourceMappingURL=hash-files.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hash-files.mjs","names":[],"sources":["../src/hash-files.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 type { ListOptions } from \"@stryke/fs/list-files\";\nimport { listFiles } from \"@stryke/fs/list-files\";\nimport { readFile } from \"@stryke/fs/read-file\";\nimport type { HashOptions } from \"./murmurhash\";\nimport { murmurhash } from \"./murmurhash\";\n\n/**\n * Hash a list of file paths into a string based on the file content\n *\n * @param files - The list of file paths to hash\n * @param options - Hashing options\n * @returns A hashed string value\n */\nexport async function hashFiles(\n files: string[],\n options?: HashOptions\n): Promise<string> {\n const result = {} as Record<string, string>;\n await Promise.all(\n files.map(async file => {\n result[file] = await readFile(file);\n })\n );\n\n return murmurhash(result, options);\n}\n\n/**\n * Hash a folder path into a string based on the file content\n *\n * @param directoryPath - The folder path to hash\n * @param options - Hashing options. By default, the `node_modules`, `.git`, `.nx`, `.cache`, and `tmp` folders is ignored.\n * @returns A hashed string value\n */\nexport async function hashDirectory(\n directoryPath: string,\n options: HashOptions & ListOptions = {}\n): Promise<string> {\n options.ignore = options.ignore ?? [\n \"**/node_modules/**\",\n \"**/.git/**\",\n \"**/.nx/**\",\n \"**/.cache/**\",\n \"**/.storm/**\",\n \"**/tmp/**\"\n ];\n\n return hashFiles(await listFiles(directoryPath, options), options);\n}\n"],"mappings":";;;;;;;;;;;;AA+BA,eAAsB,UACpB,OACA,SACiB;CACjB,MAAM,SAAS,EAAE;AACjB,OAAM,QAAQ,IACZ,MAAM,IAAI,OAAM,SAAQ;AACtB,SAAO,QAAQ,MAAM,SAAS,KAAK;GACnC,CACH;AAED,QAAO,WAAW,QAAQ,QAAQ;;;;;;;;;AAUpC,eAAsB,cACpB,eACA,UAAqC,EAAE,EACtB;AACjB,SAAQ,SAAS,QAAQ,UAAU;EACjC;EACA;EACA;EACA;EACA;EACA;EACD;AAED,QAAO,UAAU,MAAM,UAAU,eAAe,QAAQ,EAAE,QAAQ"}
package/dist/md5.cjs DELETED
@@ -1,17 +0,0 @@
1
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
- let node_crypto = require("node:crypto");
3
-
4
- //#region src/md5.ts
5
- /**
6
- * Generate an MD5 hash of the provided content.
7
- *
8
- * @param content - The content to hash.
9
- * @param length - The length of the hash to return.
10
- * @returns The generated MD5 hash.
11
- */
12
- function md5(content, length = 32) {
13
- return (0, node_crypto.createHash)("md5").update(content).digest("hex").slice(0, length);
14
- }
15
-
16
- //#endregion
17
- exports.md5 = md5;
package/dist/md5.d.cts DELETED
@@ -1,12 +0,0 @@
1
- //#region src/md5.d.ts
2
- /**
3
- * Generate an MD5 hash of the provided content.
4
- *
5
- * @param content - The content to hash.
6
- * @param length - The length of the hash to return.
7
- * @returns The generated MD5 hash.
8
- */
9
- declare function md5(content: string, length?: number): string;
10
- //#endregion
11
- export { md5 };
12
- //# sourceMappingURL=md5.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"md5.d.cts","names":[],"sources":["../src/md5.ts"],"sourcesContent":[],"mappings":";;AA2BA;;;;;;iBAAgB,GAAA"}
package/dist/md5.d.mts DELETED
@@ -1,12 +0,0 @@
1
- //#region src/md5.d.ts
2
- /**
3
- * Generate an MD5 hash of the provided content.
4
- *
5
- * @param content - The content to hash.
6
- * @param length - The length of the hash to return.
7
- * @returns The generated MD5 hash.
8
- */
9
- declare function md5(content: string, length?: number): string;
10
- //#endregion
11
- export { md5 };
12
- //# sourceMappingURL=md5.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"md5.d.mts","names":[],"sources":["../src/md5.ts"],"sourcesContent":[],"mappings":";;AA2BA;;;;;;iBAAgB,GAAA"}
package/dist/md5.mjs DELETED
@@ -1,17 +0,0 @@
1
- import { createHash } from "node:crypto";
2
-
3
- //#region src/md5.ts
4
- /**
5
- * Generate an MD5 hash of the provided content.
6
- *
7
- * @param content - The content to hash.
8
- * @param length - The length of the hash to return.
9
- * @returns The generated MD5 hash.
10
- */
11
- function md5(content, length = 32) {
12
- return createHash("md5").update(content).digest("hex").slice(0, length);
13
- }
14
-
15
- //#endregion
16
- export { md5 };
17
- //# sourceMappingURL=md5.mjs.map
package/dist/md5.mjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"md5.mjs","names":[],"sources":["../src/md5.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 { createHash } from \"node:crypto\";\n\n/**\n * Generate an MD5 hash of the provided content.\n *\n * @param content - The content to hash.\n * @param length - The length of the hash to return.\n * @returns The generated MD5 hash.\n */\nexport function md5(content: string, length = 32) {\n return createHash(\"md5\").update(content).digest(\"hex\").slice(0, length);\n}\n"],"mappings":";;;;;;;;;;AA2BA,SAAgB,IAAI,SAAiB,SAAS,IAAI;AAChD,QAAO,WAAW,MAAM,CAAC,OAAO,QAAQ,CAAC,OAAO,MAAM,CAAC,MAAM,GAAG,OAAO"}
@@ -1,22 +0,0 @@
1
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
- let ohash = require("ohash");
3
-
4
- //#region src/murmurhash.ts
5
- /**
6
- * Use a [MurmurHash3](https://en.wikipedia.org/wiki/MurmurHash) based algorithm to hash any JS value into a string.
7
- *
8
- * @see https://github.com/ohash/ohash
9
- * @see https://en.wikipedia.org/wiki/MurmurHash
10
- *
11
- * @param content - The value to hash
12
- * @param options - Hashing options
13
- * @returns A hashed string value
14
- */
15
- function murmurhash(content, options) {
16
- const result = (0, ohash.hash)(content);
17
- const maxLength = options?.maxLength ?? 32;
18
- return result.length > maxLength ? result.slice(0, maxLength) : result;
19
- }
20
-
21
- //#endregion
22
- exports.murmurhash = murmurhash;
@@ -1,23 +0,0 @@
1
- //#region src/murmurhash.d.ts
2
- interface HashOptions {
3
- /**
4
- * The maximum length of the hash
5
- *
6
- * @defaultValue 32
7
- */
8
- maxLength?: number;
9
- }
10
- /**
11
- * Use a [MurmurHash3](https://en.wikipedia.org/wiki/MurmurHash) based algorithm to hash any JS value into a string.
12
- *
13
- * @see https://github.com/ohash/ohash
14
- * @see https://en.wikipedia.org/wiki/MurmurHash
15
- *
16
- * @param content - The value to hash
17
- * @param options - Hashing options
18
- * @returns A hashed string value
19
- */
20
- declare function murmurhash(content: any, options?: HashOptions): string;
21
- //#endregion
22
- export { HashOptions, murmurhash };
23
- //# sourceMappingURL=murmurhash.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"murmurhash.d.cts","names":[],"sources":["../src/murmurhash.ts"],"sourcesContent":[],"mappings":";UAoBiB,WAAA;EAAA;AAmBjB;;;;;;;;;;;;;;;;iBAAgB,UAAA,yBAAmC"}
@@ -1,23 +0,0 @@
1
- //#region src/murmurhash.d.ts
2
- interface HashOptions {
3
- /**
4
- * The maximum length of the hash
5
- *
6
- * @defaultValue 32
7
- */
8
- maxLength?: number;
9
- }
10
- /**
11
- * Use a [MurmurHash3](https://en.wikipedia.org/wiki/MurmurHash) based algorithm to hash any JS value into a string.
12
- *
13
- * @see https://github.com/ohash/ohash
14
- * @see https://en.wikipedia.org/wiki/MurmurHash
15
- *
16
- * @param content - The value to hash
17
- * @param options - Hashing options
18
- * @returns A hashed string value
19
- */
20
- declare function murmurhash(content: any, options?: HashOptions): string;
21
- //#endregion
22
- export { HashOptions, murmurhash };
23
- //# sourceMappingURL=murmurhash.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"murmurhash.d.mts","names":[],"sources":["../src/murmurhash.ts"],"sourcesContent":[],"mappings":";UAoBiB,WAAA;EAAA;AAmBjB;;;;;;;;;;;;;;;;iBAAgB,UAAA,yBAAmC"}