@stryke/hash 0.12.38 → 0.12.39
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 +29 -1
- package/dist/convert/src/array-buffer-to-string.cjs +19 -1
- package/dist/convert/src/array-buffer-to-string.mjs +18 -1
- package/dist/convert/src/array-buffer-to-string.mjs.map +1 -1
- package/dist/convert/src/neutral.cjs +5 -1
- package/dist/convert/src/neutral.mjs +7 -1
- package/dist/convert/src/parse-type-definition.cjs +1 -1
- package/dist/convert/src/parse-type-definition.mjs +3 -1
- package/dist/convert/src/string-to-uint8-array.cjs +14 -1
- package/dist/convert/src/string-to-uint8-array.mjs +13 -1
- package/dist/convert/src/string-to-uint8-array.mjs.map +1 -1
- package/dist/convert/src/string-to-utf8-array.cjs +5 -1
- package/dist/convert/src/string-to-utf8-array.mjs +5 -1
- package/dist/convert/src/string-to-utf8-array.mjs.map +1 -1
- package/dist/convert/src/utf8-array-to-string.cjs +5 -1
- package/dist/convert/src/utf8-array-to-string.mjs +5 -1
- package/dist/convert/src/utf8-array-to-string.mjs.map +1 -1
- package/dist/digest.cjs +56 -1
- package/dist/digest.mjs +53 -1
- package/dist/digest.mjs.map +1 -1
- package/dist/etag.cjs +53 -1
- package/dist/etag.mjs +51 -1
- package/dist/etag.mjs.map +1 -1
- package/dist/fs/src/list-files.cjs +36 -1
- package/dist/fs/src/list-files.mjs +34 -1
- package/dist/fs/src/list-files.mjs.map +1 -1
- package/dist/fs/src/read-file.cjs +16 -1
- package/dist/fs/src/read-file.mjs +15 -1
- package/dist/fs/src/read-file.mjs.map +1 -1
- package/dist/hash-files.cjs +41 -1
- package/dist/hash-files.mjs +40 -1
- package/dist/hash-files.mjs.map +1 -1
- package/dist/index.cjs +20 -1
- package/dist/index.mjs +8 -1
- package/dist/md5.cjs +17 -1
- package/dist/md5.mjs +16 -1
- package/dist/md5.mjs.map +1 -1
- package/dist/murmurhash.cjs +22 -1
- package/dist/murmurhash.mjs +21 -1
- package/dist/murmurhash.mjs.map +1 -1
- package/dist/neutral.cjs +15 -1
- package/dist/neutral.mjs +6 -1
- package/dist/path/src/is-type.cjs +28 -1
- package/dist/path/src/is-type.mjs +28 -1
- package/dist/path/src/is-type.mjs.map +1 -1
- package/dist/path/src/join-paths.cjs +106 -1
- package/dist/path/src/join-paths.mjs +106 -1
- package/dist/path/src/join-paths.mjs.map +1 -1
- package/dist/path/src/regex.cjs +12 -1
- package/dist/path/src/regex.mjs +8 -1
- package/dist/path/src/regex.mjs.map +1 -1
- package/dist/path/src/slash.cjs +15 -1
- package/dist/path/src/slash.mjs +14 -1
- package/dist/path/src/slash.mjs.map +1 -1
- package/dist/type-checks/src/index.cjs +4 -1
- package/dist/type-checks/src/index.mjs +6 -1
- package/dist/type-checks/src/is-buffer.cjs +12 -1
- package/dist/type-checks/src/is-buffer.mjs +11 -1
- package/dist/type-checks/src/is-buffer.mjs.map +1 -1
- package/dist/type-checks/src/is-collection.cjs +1 -1
- package/dist/type-checks/src/is-collection.mjs +3 -1
- package/dist/type-checks/src/is-string.cjs +12 -1
- package/dist/type-checks/src/is-string.mjs +11 -1
- package/dist/type-checks/src/is-string.mjs.map +1 -1
- package/dist/type-checks/src/type-detect.cjs +15 -1
- package/dist/type-checks/src/type-detect.mjs +16 -1
- package/dist/type-checks/src/type-detect.mjs.map +1 -1
- package/dist/xx-hash.cjs +25 -1
- package/dist/xx-hash.mjs +22 -1
- package/dist/xx-hash.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog for Stryke - Hash
|
|
4
4
|
|
|
5
|
+
## [0.12.38](https://github.com/storm-software/stryke/releases/tag/hash%400.12.38) (01/16/2026)
|
|
6
|
+
|
|
7
|
+
### Updated Dependencies
|
|
8
|
+
|
|
9
|
+
- Updated **fs** to **v0.33.32**
|
|
10
|
+
|
|
5
11
|
## [0.12.37](https://github.com/storm-software/stryke/releases/tag/hash%400.12.37) (01/16/2026)
|
|
6
12
|
|
|
7
13
|
### Updated Dependencies
|
|
@@ -1 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
|
@@ -1 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region ../convert/src/array-buffer-to-string.ts
|
|
3
|
+
/**
|
|
4
|
+
* Convert an ArrayBuffer or Uint8Array to a string
|
|
5
|
+
*
|
|
6
|
+
* @param buffer - The ArrayBuffer or Uint8Array to convert
|
|
7
|
+
* @returns The converted string
|
|
8
|
+
*/
|
|
9
|
+
function arrayBufferToString(buffer) {
|
|
10
|
+
const bytes = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
|
11
|
+
const len = bytes.byteLength;
|
|
12
|
+
if (len < 65535) return String.fromCharCode.apply(null, bytes);
|
|
13
|
+
let binary = "";
|
|
14
|
+
for (let i = 0; i < len; i++) binary += String.fromCharCode(bytes[i]);
|
|
15
|
+
return binary;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.arrayBufferToString = arrayBufferToString;
|
|
@@ -1,2 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
//#region ../convert/src/array-buffer-to-string.ts
|
|
2
|
+
/**
|
|
3
|
+
* Convert an ArrayBuffer or Uint8Array to a string
|
|
4
|
+
*
|
|
5
|
+
* @param buffer - The ArrayBuffer or Uint8Array to convert
|
|
6
|
+
* @returns The converted string
|
|
7
|
+
*/
|
|
8
|
+
function arrayBufferToString(buffer) {
|
|
9
|
+
const bytes = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
|
10
|
+
const len = bytes.byteLength;
|
|
11
|
+
if (len < 65535) return String.fromCharCode.apply(null, bytes);
|
|
12
|
+
let binary = "";
|
|
13
|
+
for (let i = 0; i < len; i++) binary += String.fromCharCode(bytes[i]);
|
|
14
|
+
return binary;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { arrayBufferToString };
|
|
2
19
|
//# sourceMappingURL=array-buffer-to-string.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-buffer-to-string.mjs","names":[],"sources":["../../../../convert/src/array-buffer-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\n/**\n * Convert an ArrayBuffer or Uint8Array to a string\n *\n * @param buffer - The ArrayBuffer or Uint8Array to convert\n * @returns The converted string\n */\nexport function arrayBufferToString(\n buffer: ArrayBuffer | ArrayBufferLike | Uint8Array\n): string {\n const bytes =\n buffer instanceof Uint8Array\n ? buffer\n : new Uint8Array(buffer as ArrayBufferLike);\n const len = bytes.byteLength;\n if (len < 65535) {\n return String.fromCharCode.apply(null, bytes as unknown as number[]);\n }\n let binary = \"\";\n for (let i = 0; i < len; i++) {\n binary += String.fromCharCode(bytes[i]!);\n }\n return binary;\n}\n"],"mappings":"AAwBA,SAAgB,
|
|
1
|
+
{"version":3,"file":"array-buffer-to-string.mjs","names":[],"sources":["../../../../convert/src/array-buffer-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\n/**\n * Convert an ArrayBuffer or Uint8Array to a string\n *\n * @param buffer - The ArrayBuffer or Uint8Array to convert\n * @returns The converted string\n */\nexport function arrayBufferToString(\n buffer: ArrayBuffer | ArrayBufferLike | Uint8Array\n): string {\n const bytes =\n buffer instanceof Uint8Array\n ? buffer\n : new Uint8Array(buffer as ArrayBufferLike);\n const len = bytes.byteLength;\n if (len < 65535) {\n return String.fromCharCode.apply(null, bytes as unknown as number[]);\n }\n let binary = \"\";\n for (let i = 0; i < len; i++) {\n binary += String.fromCharCode(bytes[i]!);\n }\n return binary;\n}\n"],"mappings":";;;;;;;AAwBA,SAAgB,oBACd,QACQ;CACR,MAAM,QACJ,kBAAkB,aACd,SACA,IAAI,WAAW,OAA0B;CAC/C,MAAM,MAAM,MAAM;AAClB,KAAI,MAAM,MACR,QAAO,OAAO,aAAa,MAAM,MAAM,MAA6B;CAEtE,IAAI,SAAS;AACb,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,IACvB,WAAU,OAAO,aAAa,MAAM,GAAI;AAE1C,QAAO"}
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_array_buffer_to_string = require('./array-buffer-to-string.cjs');
|
|
2
|
+
require('./parse-type-definition.cjs');
|
|
3
|
+
const require_string_to_uint8_array = require('./string-to-uint8-array.cjs');
|
|
4
|
+
require('./string-to-utf8-array.cjs');
|
|
5
|
+
require('./utf8-array-to-string.cjs');
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
import{arrayBufferToString
|
|
1
|
+
import { arrayBufferToString } from "./array-buffer-to-string.mjs";
|
|
2
|
+
import "./parse-type-definition.mjs";
|
|
3
|
+
import { stringToUint8Array } from "./string-to-uint8-array.mjs";
|
|
4
|
+
import "./string-to-utf8-array.mjs";
|
|
5
|
+
import "./utf8-array-to-string.mjs";
|
|
6
|
+
|
|
7
|
+
export { };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(
|
|
1
|
+
require('../../type-checks/src/index.cjs');
|
|
@@ -1 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region ../convert/src/string-to-uint8-array.ts
|
|
3
|
+
/**
|
|
4
|
+
* Convert a string to Uint8Array
|
|
5
|
+
*
|
|
6
|
+
* @param text - The text to convert
|
|
7
|
+
* @returns The converted Uint8Array
|
|
8
|
+
*/
|
|
9
|
+
function stringToUint8Array(text) {
|
|
10
|
+
return Uint8Array.from([...encodeURIComponent(text)].map((letter) => letter.codePointAt(0)));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
exports.stringToUint8Array = stringToUint8Array;
|
|
@@ -1,2 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
//#region ../convert/src/string-to-uint8-array.ts
|
|
2
|
+
/**
|
|
3
|
+
* Convert a string to Uint8Array
|
|
4
|
+
*
|
|
5
|
+
* @param text - The text to convert
|
|
6
|
+
* @returns The converted Uint8Array
|
|
7
|
+
*/
|
|
8
|
+
function stringToUint8Array(text) {
|
|
9
|
+
return Uint8Array.from([...encodeURIComponent(text)].map((letter) => letter.codePointAt(0)));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { stringToUint8Array };
|
|
2
14
|
//# sourceMappingURL=string-to-uint8-array.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string-to-uint8-array.mjs","names":[],"sources":["../../../../convert/src/string-to-uint8-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\n/**\n * Convert a string to Uint8Array\n *\n * @param text - The text to convert\n * @returns The converted Uint8Array\n */\nexport function stringToUint8Array(text: string): Uint8Array {\n return Uint8Array.from(\n [...encodeURIComponent(text)].map(letter => letter.codePointAt(0)!)\n );\n}\n\n/**\n * Convert a binary string to Uint8Array\n *\n * @param binary - The binary string to convert\n * @returns The converted Uint8Array\n */\nexport function binaryStringToUint8Array(binary: string): Uint8Array {\n const len = binary.length;\n const arr = new Uint8Array(len);\n for (let i = 0; i < len; i++) {\n arr[i] = binary.charCodeAt(i);\n }\n return arr;\n}\n\n/**\n * Convert a base64 string to a Uint8Array\n *\n * @param data - The base64 string to convert\n * @returns The converted Uint8Array\n */\nexport function base64StringToUint8Array(data: string): Uint8Array {\n return stringToUint8Array(atob(data));\n}\n"],"mappings":"AAwBA,SAAgB,
|
|
1
|
+
{"version":3,"file":"string-to-uint8-array.mjs","names":[],"sources":["../../../../convert/src/string-to-uint8-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\n/**\n * Convert a string to Uint8Array\n *\n * @param text - The text to convert\n * @returns The converted Uint8Array\n */\nexport function stringToUint8Array(text: string): Uint8Array {\n return Uint8Array.from(\n [...encodeURIComponent(text)].map(letter => letter.codePointAt(0)!)\n );\n}\n\n/**\n * Convert a binary string to Uint8Array\n *\n * @param binary - The binary string to convert\n * @returns The converted Uint8Array\n */\nexport function binaryStringToUint8Array(binary: string): Uint8Array {\n const len = binary.length;\n const arr = new Uint8Array(len);\n for (let i = 0; i < len; i++) {\n arr[i] = binary.charCodeAt(i);\n }\n return arr;\n}\n\n/**\n * Convert a base64 string to a Uint8Array\n *\n * @param data - The base64 string to convert\n * @returns The converted Uint8Array\n */\nexport function base64StringToUint8Array(data: string): Uint8Array {\n return stringToUint8Array(atob(data));\n}\n"],"mappings":";;;;;;;AAwBA,SAAgB,mBAAmB,MAA0B;AAC3D,QAAO,WAAW,KAChB,CAAC,GAAG,mBAAmB,KAAK,CAAC,CAAC,KAAI,WAAU,OAAO,YAAY,EAAE,CAAE,CACpE"}
|
|
@@ -1 +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":"
|
|
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":";AAkBA,MAAM,UAAU,IAAI,aAAa"}
|
|
@@ -1 +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":"
|
|
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":";AAkBA,MAAM,UAAU,IAAI,aAAa"}
|
package/dist/digest.cjs
CHANGED
|
@@ -1 +1,56 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_array_buffer_to_string = require('./convert/src/array-buffer-to-string.cjs');
|
|
2
|
+
const require_string_to_uint8_array = require('./convert/src/string-to-uint8-array.cjs');
|
|
3
|
+
require('./convert/src/neutral.cjs');
|
|
4
|
+
|
|
5
|
+
//#region src/digest.ts
|
|
6
|
+
/**
|
|
7
|
+
* Creates a new hash object for the specified algorithm.
|
|
8
|
+
*
|
|
9
|
+
* @param algorithm - The algorithm to use for the hash.
|
|
10
|
+
* @returns A new hash object.
|
|
11
|
+
*/
|
|
12
|
+
function createHasher(algorithm) {
|
|
13
|
+
return new Hasher(algorithm);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new hash object for the specified algorithm.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* This function uses the Web Crypto API to create a hash of the input data.
|
|
20
|
+
*
|
|
21
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
|
|
22
|
+
*
|
|
23
|
+
* @param data - The data to hash.
|
|
24
|
+
* @param algorithm - The algorithm to use for the hash.
|
|
25
|
+
* @returns A hash string representation of the `data` parameter.
|
|
26
|
+
*/
|
|
27
|
+
async function digest(data, algorithm = "SHA-512") {
|
|
28
|
+
return require_array_buffer_to_string.arrayBufferToString(await globalThis.crypto.subtle.digest(algorithm, require_string_to_uint8_array.stringToUint8Array(data)));
|
|
29
|
+
}
|
|
30
|
+
const hash = digest;
|
|
31
|
+
var Hasher = class {
|
|
32
|
+
#chunks = [];
|
|
33
|
+
#algorithm;
|
|
34
|
+
constructor(algorithm) {
|
|
35
|
+
this.#algorithm = algorithm;
|
|
36
|
+
}
|
|
37
|
+
update(data) {
|
|
38
|
+
this.#chunks.push(data);
|
|
39
|
+
}
|
|
40
|
+
async digest() {
|
|
41
|
+
const data = new Uint8Array(this.#chunks.reduce((acc, chunk) => acc + chunk.length, 0));
|
|
42
|
+
let offset = 0;
|
|
43
|
+
for (const chunk of this.#chunks) {
|
|
44
|
+
data.set(chunk, offset);
|
|
45
|
+
offset += chunk.length;
|
|
46
|
+
}
|
|
47
|
+
const arrayBuffer = await globalThis.crypto.subtle.digest(this.#algorithm, data);
|
|
48
|
+
return new Uint8Array(arrayBuffer);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
exports.Hasher = Hasher;
|
|
54
|
+
exports.createHasher = createHasher;
|
|
55
|
+
exports.digest = digest;
|
|
56
|
+
exports.hash = hash;
|
package/dist/digest.mjs
CHANGED
|
@@ -1,2 +1,54 @@
|
|
|
1
|
-
import{arrayBufferToString
|
|
1
|
+
import { arrayBufferToString } from "./convert/src/array-buffer-to-string.mjs";
|
|
2
|
+
import { stringToUint8Array } from "./convert/src/string-to-uint8-array.mjs";
|
|
3
|
+
import "./convert/src/neutral.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/digest.ts
|
|
6
|
+
/**
|
|
7
|
+
* Creates a new hash object for the specified algorithm.
|
|
8
|
+
*
|
|
9
|
+
* @param algorithm - The algorithm to use for the hash.
|
|
10
|
+
* @returns A new hash object.
|
|
11
|
+
*/
|
|
12
|
+
function createHasher(algorithm) {
|
|
13
|
+
return new Hasher(algorithm);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new hash object for the specified algorithm.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* This function uses the Web Crypto API to create a hash of the input data.
|
|
20
|
+
*
|
|
21
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
|
|
22
|
+
*
|
|
23
|
+
* @param data - The data to hash.
|
|
24
|
+
* @param algorithm - The algorithm to use for the hash.
|
|
25
|
+
* @returns A hash string representation of the `data` parameter.
|
|
26
|
+
*/
|
|
27
|
+
async function digest(data, algorithm = "SHA-512") {
|
|
28
|
+
return arrayBufferToString(await globalThis.crypto.subtle.digest(algorithm, stringToUint8Array(data)));
|
|
29
|
+
}
|
|
30
|
+
const hash = digest;
|
|
31
|
+
var Hasher = class {
|
|
32
|
+
#chunks = [];
|
|
33
|
+
#algorithm;
|
|
34
|
+
constructor(algorithm) {
|
|
35
|
+
this.#algorithm = algorithm;
|
|
36
|
+
}
|
|
37
|
+
update(data) {
|
|
38
|
+
this.#chunks.push(data);
|
|
39
|
+
}
|
|
40
|
+
async digest() {
|
|
41
|
+
const data = new Uint8Array(this.#chunks.reduce((acc, chunk) => acc + chunk.length, 0));
|
|
42
|
+
let offset = 0;
|
|
43
|
+
for (const chunk of this.#chunks) {
|
|
44
|
+
data.set(chunk, offset);
|
|
45
|
+
offset += chunk.length;
|
|
46
|
+
}
|
|
47
|
+
const arrayBuffer = await globalThis.crypto.subtle.digest(this.#algorithm, data);
|
|
48
|
+
return new Uint8Array(arrayBuffer);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
export { Hasher, createHasher, digest, hash };
|
|
2
54
|
//# sourceMappingURL=digest.mjs.map
|
package/dist/digest.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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":"
|
|
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
CHANGED
|
@@ -1 +1,53 @@
|
|
|
1
|
-
|
|
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.mjs
CHANGED
|
@@ -1,2 +1,52 @@
|
|
|
1
|
-
|
|
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 };
|
|
2
52
|
//# sourceMappingURL=etag.mjs.map
|
package/dist/etag.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
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 +1,36 @@
|
|
|
1
|
-
const
|
|
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,2 +1,35 @@
|
|
|
1
|
-
import{isString
|
|
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 };
|
|
2
35
|
//# sourceMappingURL=list-files.mjs.map
|
|
@@ -1 +1 @@
|
|
|
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":"
|
|
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 +1,16 @@
|
|
|
1
|
-
const
|
|
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;
|