@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,22 +0,0 @@
1
- import { hash } from "ohash";
2
-
3
- //#region src/murmurhash.ts
4
- /**
5
- * Use a [MurmurHash3](https://en.wikipedia.org/wiki/MurmurHash) based algorithm to hash any JS value into a string.
6
- *
7
- * @see https://github.com/ohash/ohash
8
- * @see https://en.wikipedia.org/wiki/MurmurHash
9
- *
10
- * @param content - The value to hash
11
- * @param options - Hashing options
12
- * @returns A hashed string value
13
- */
14
- function murmurhash(content, options) {
15
- const result = hash(content);
16
- const maxLength = options?.maxLength ?? 32;
17
- return result.length > maxLength ? result.slice(0, maxLength) : result;
18
- }
19
-
20
- //#endregion
21
- export { murmurhash };
22
- //# sourceMappingURL=murmurhash.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"murmurhash.mjs","names":["ohash"],"sources":["../src/murmurhash.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { hash as ohash } from \"ohash\";\n\nexport interface HashOptions {\n /**\n * The maximum length of the hash\n *\n * @defaultValue 32\n */\n maxLength?: number;\n}\n\n/**\n * Use a [MurmurHash3](https://en.wikipedia.org/wiki/MurmurHash) based algorithm to hash any JS value into a string.\n *\n * @see https://github.com/ohash/ohash\n * @see https://en.wikipedia.org/wiki/MurmurHash\n *\n * @param content - The value to hash\n * @param options - Hashing options\n * @returns A hashed string value\n */\nexport function murmurhash(content: any, options?: HashOptions): string {\n const result = ohash(content);\n const maxLength = options?.maxLength ?? 32;\n\n return result.length > maxLength ? result.slice(0, maxLength) : result;\n}\n"],"mappings":";;;;;;;;;;;;;AAuCA,SAAgB,WAAW,SAAc,SAA+B;CACtE,MAAM,SAASA,KAAM,QAAQ;CAC7B,MAAM,YAAY,SAAS,aAAa;AAExC,QAAO,OAAO,SAAS,YAAY,OAAO,MAAM,GAAG,UAAU,GAAG"}
@@ -1,28 +0,0 @@
1
- const require_regex = require('./regex.cjs');
2
- const require_slash = require('./slash.cjs');
3
-
4
- //#region ../path/src/is-type.ts
5
- /**
6
- * Check if the path is an absolute path.
7
- *
8
- * @param path - The path to check
9
- * @returns An indicator specifying if the path is an absolute path
10
- */
11
- function isAbsolutePath(path) {
12
- return require_regex.ABSOLUTE_PATH_REGEX.test(require_slash.slash(path));
13
- }
14
- /**
15
- * Check if the path is an absolute path.
16
- *
17
- * @remarks
18
- * This is an alias for {@link isAbsolutePath}.
19
- *
20
- * @param path - The path to check
21
- * @returns An indicator specifying if the path is an absolute path
22
- */
23
- function isAbsolute(path) {
24
- return isAbsolutePath(path);
25
- }
26
-
27
- //#endregion
28
- exports.isAbsolute = isAbsolute;
@@ -1,29 +0,0 @@
1
- import { ABSOLUTE_PATH_REGEX } from "./regex.mjs";
2
- import { slash } from "./slash.mjs";
3
-
4
- //#region ../path/src/is-type.ts
5
- /**
6
- * Check if the path is an absolute path.
7
- *
8
- * @param path - The path to check
9
- * @returns An indicator specifying if the path is an absolute path
10
- */
11
- function isAbsolutePath(path) {
12
- return ABSOLUTE_PATH_REGEX.test(slash(path));
13
- }
14
- /**
15
- * Check if the path is an absolute path.
16
- *
17
- * @remarks
18
- * This is an alias for {@link isAbsolutePath}.
19
- *
20
- * @param path - The path to check
21
- * @returns An indicator specifying if the path is an absolute path
22
- */
23
- function isAbsolute(path) {
24
- return isAbsolutePath(path);
25
- }
26
-
27
- //#endregion
28
- export { isAbsolute };
29
- //# sourceMappingURL=is-type.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-type.mjs","names":[],"sources":["../../../../path/src/is-type.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 { ABSOLUTE_PATH_REGEX, NPM_SCOPED_PACKAGE_REGEX } from \"./regex\";\nimport { slash } from \"./slash\";\n\n/**\n * Check if the path is an absolute path.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is an absolute path\n */\nexport function isAbsolutePath(path: string): boolean {\n return ABSOLUTE_PATH_REGEX.test(slash(path));\n}\n\n/**\n * Check if the path is an absolute path.\n *\n * @remarks\n * This is an alias for {@link isAbsolutePath}.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is an absolute path\n */\nexport function isAbsolute(path: string): boolean {\n return isAbsolutePath(path);\n}\n\n/**\n * Check if the path is a relative path.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a relative path\n */\nexport function isRelativePath(path: string): boolean {\n return !isAbsolutePath(path);\n}\n\n/**\n * Check if the path is a relative path.\n *\n * @remarks\n * This is an alias for {@link isRelativePath}.\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a relative path\n */\nexport function isRelative(path: string): boolean {\n return isRelativePath(path);\n}\n\n/**\n * Check if the path is a npm package path.\n *\n * @remarks\n * This only checks if the path matches the npm namespace scoped package naming convention such as `@scope/package-name`. This is an alias for {@link isNpmScopedPackage}.\n *\n * @example\n * ```ts\n * isNpmScopedPackage(\"@stryke/path\"); // returns true\n * isNpmScopedPackage(\"lodash\"); // returns false\n * isNpmNamespacePackage(\"./src/index.ts\"); // returns false\n * ```\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a npm package path\n */\nexport function isNpmScopedPackagePath(path: string): boolean {\n return NPM_SCOPED_PACKAGE_REGEX.test(slash(path));\n}\n\n/**\n * Check if the path is a npm package path.\n *\n * @remarks\n * This only checks if the path matches the npm namespace scoped package naming convention such as `@scope/package-name`. This is an alias for {@link isNpmScopedPackagePath}.\n *\n * @example\n * ```ts\n * isNpmScopedPackagePath(\"@stryke/path\"); // returns true\n * isNpmScopedPackagePath(\"lodash\"); // returns false\n * isNpmScopedPackagePath(\"./src/index.ts\"); // returns false\n * ```\n *\n * @param path - The path to check\n * @returns An indicator specifying if the path is a npm package path\n */\nexport function isNpmScopedPackage(path: string): boolean {\n return isNpmScopedPackagePath(path);\n}\n"],"mappings":";;;;;;;;;;AA2BA,SAAgB,eAAe,MAAuB;AACpD,QAAO,oBAAoB,KAAK,MAAM,KAAK,CAAC;;;;;;;;;;;AAY9C,SAAgB,WAAW,MAAuB;AAChD,QAAO,eAAe,KAAK"}
@@ -1,122 +0,0 @@
1
- const require_regex = require('./regex.cjs');
2
- const require_is_type = require('./is-type.cjs');
3
- const require_slash = require('./slash.cjs');
4
-
5
- //#region ../path/src/join-paths.ts
6
- function normalizeWindowsPath(input = "") {
7
- if (!input) return input;
8
- return input.replace(/\\/g, "/").replace(require_regex.DRIVE_LETTER_START_REGEX, (r) => r.toUpperCase());
9
- }
10
- function correctPaths(path) {
11
- if (!path || path.length === 0) return ".";
12
- path = normalizeWindowsPath(path);
13
- const isUNCPath = path.match(require_regex.UNC_REGEX);
14
- const isPathAbsolute = require_is_type.isAbsolute(path);
15
- const trailingSeparator = path[path.length - 1] === "/";
16
- path = normalizeString(path, !isPathAbsolute);
17
- if (path.length === 0) {
18
- if (isPathAbsolute) return "/";
19
- return trailingSeparator ? "./" : ".";
20
- }
21
- if (trailingSeparator) path += "/";
22
- if (require_regex.DRIVE_LETTER_REGEX.test(path)) path += "/";
23
- if (isUNCPath) {
24
- if (!isPathAbsolute) return `//./${path}`;
25
- return `//${path}`;
26
- }
27
- return isPathAbsolute && !require_is_type.isAbsolute(path) ? `/${path}` : path;
28
- }
29
- /**
30
- * Joins all given path segments together using the platform-specific separator as a delimiter.
31
- *
32
- * @remarks
33
- * Multiple segments can be provided as separate arguments. The resulting path is normalized to remove any redundant or unnecessary segments.
34
- *
35
- * @example
36
- * ```ts
37
- * import { joinPaths } from 'stryke/path';
38
- *
39
- * const fullPath = joinPaths('folder1', 'folder2', '..', 'folder3', 'file.txt');
40
- * console.log(fullPath); // Output: 'folder1/folder3/file.txt'
41
- *
42
- * const absolutePath = joinPaths('/root', 'folder', '.', 'subfolder', 'file.txt');
43
- * console.log(absolutePath); // Output: '/root/folder/subfolder/file.txt'
44
- *
45
- * const windowsPath = joinPaths('C:\\', 'Users', 'Public', '..', 'Documents', 'file.txt');
46
- * console.log(windowsPath); // Output: 'C:/Users/Documents/file.txt'
47
- *
48
- * const uncPath = joinPaths('\\\\Server\\Share', 'Folder', 'File.txt');
49
- * console.log(uncPath); // Output: '//Server/Share/Folder/File.txt'
50
- * ```
51
- *
52
- * @param segments - The path segments to join.
53
- * @returns The joined and normalized path string.
54
- */
55
- function joinPaths(...segments) {
56
- let result = "";
57
- for (const segment of segments) if (segment && require_slash.slash(segment).replaceAll(/\//g, "") !== ".") {
58
- if (result) if (require_slash.slash(segment).replaceAll(/\//g, "") === "..") result = require_slash.slash(result).replace(/\/+$/, "").replace(/\/*[^/]+$/, "");
59
- else result = `${require_slash.slash(result).replace(/\/+$/, "")}/${require_slash.slash(segment).replace(/^\/+/, "")}`;
60
- else if (require_slash.slash(segment).replaceAll(/\//g, "") !== "..") result = segment;
61
- }
62
- return correctPaths(result);
63
- }
64
- /**
65
- * Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
66
- *
67
- * @param path - The path to normalize.
68
- * @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
69
- * @returns the normalized path string.
70
- */
71
- function normalizeString(path, allowAboveRoot) {
72
- let res = "";
73
- let lastSegmentLength = 0;
74
- let lastSlash = -1;
75
- let dots = 0;
76
- let char = null;
77
- for (let index = 0; index <= path.length; ++index) {
78
- if (index < path.length) char = path[index];
79
- else if (char === "/") break;
80
- else char = "/";
81
- if (char === "/") {
82
- if (lastSlash === index - 1 || dots === 1) {} else if (dots === 2) {
83
- if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
84
- if (res.length > 2) {
85
- const lastSlashIndex = res.lastIndexOf("/");
86
- if (lastSlashIndex === -1) {
87
- res = "";
88
- lastSegmentLength = 0;
89
- } else {
90
- res = res.slice(0, lastSlashIndex);
91
- lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
92
- }
93
- lastSlash = index;
94
- dots = 0;
95
- continue;
96
- } else if (res.length > 0) {
97
- res = "";
98
- lastSegmentLength = 0;
99
- lastSlash = index;
100
- dots = 0;
101
- continue;
102
- }
103
- }
104
- if (allowAboveRoot) {
105
- res += res.length > 0 ? "/.." : "..";
106
- lastSegmentLength = 2;
107
- }
108
- } else {
109
- if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
110
- else res = path.slice(lastSlash + 1, index);
111
- lastSegmentLength = index - lastSlash - 1;
112
- }
113
- lastSlash = index;
114
- dots = 0;
115
- } else if (char === "." && dots !== -1) ++dots;
116
- else dots = -1;
117
- }
118
- return res;
119
- }
120
-
121
- //#endregion
122
- exports.joinPaths = joinPaths;
@@ -1,123 +0,0 @@
1
- import { DRIVE_LETTER_REGEX, DRIVE_LETTER_START_REGEX, UNC_REGEX } from "./regex.mjs";
2
- import { isAbsolute } from "./is-type.mjs";
3
- import { slash } from "./slash.mjs";
4
-
5
- //#region ../path/src/join-paths.ts
6
- function normalizeWindowsPath(input = "") {
7
- if (!input) return input;
8
- return input.replace(/\\/g, "/").replace(DRIVE_LETTER_START_REGEX, (r) => r.toUpperCase());
9
- }
10
- function correctPaths(path) {
11
- if (!path || path.length === 0) return ".";
12
- path = normalizeWindowsPath(path);
13
- const isUNCPath = path.match(UNC_REGEX);
14
- const isPathAbsolute = isAbsolute(path);
15
- const trailingSeparator = path[path.length - 1] === "/";
16
- path = normalizeString(path, !isPathAbsolute);
17
- if (path.length === 0) {
18
- if (isPathAbsolute) return "/";
19
- return trailingSeparator ? "./" : ".";
20
- }
21
- if (trailingSeparator) path += "/";
22
- if (DRIVE_LETTER_REGEX.test(path)) path += "/";
23
- if (isUNCPath) {
24
- if (!isPathAbsolute) return `//./${path}`;
25
- return `//${path}`;
26
- }
27
- return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
28
- }
29
- /**
30
- * Joins all given path segments together using the platform-specific separator as a delimiter.
31
- *
32
- * @remarks
33
- * Multiple segments can be provided as separate arguments. The resulting path is normalized to remove any redundant or unnecessary segments.
34
- *
35
- * @example
36
- * ```ts
37
- * import { joinPaths } from 'stryke/path';
38
- *
39
- * const fullPath = joinPaths('folder1', 'folder2', '..', 'folder3', 'file.txt');
40
- * console.log(fullPath); // Output: 'folder1/folder3/file.txt'
41
- *
42
- * const absolutePath = joinPaths('/root', 'folder', '.', 'subfolder', 'file.txt');
43
- * console.log(absolutePath); // Output: '/root/folder/subfolder/file.txt'
44
- *
45
- * const windowsPath = joinPaths('C:\\', 'Users', 'Public', '..', 'Documents', 'file.txt');
46
- * console.log(windowsPath); // Output: 'C:/Users/Documents/file.txt'
47
- *
48
- * const uncPath = joinPaths('\\\\Server\\Share', 'Folder', 'File.txt');
49
- * console.log(uncPath); // Output: '//Server/Share/Folder/File.txt'
50
- * ```
51
- *
52
- * @param segments - The path segments to join.
53
- * @returns The joined and normalized path string.
54
- */
55
- function joinPaths(...segments) {
56
- let result = "";
57
- for (const segment of segments) if (segment && slash(segment).replaceAll(/\//g, "") !== ".") {
58
- if (result) if (slash(segment).replaceAll(/\//g, "") === "..") result = slash(result).replace(/\/+$/, "").replace(/\/*[^/]+$/, "");
59
- else result = `${slash(result).replace(/\/+$/, "")}/${slash(segment).replace(/^\/+/, "")}`;
60
- else if (slash(segment).replaceAll(/\//g, "") !== "..") result = segment;
61
- }
62
- return correctPaths(result);
63
- }
64
- /**
65
- * Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
66
- *
67
- * @param path - The path to normalize.
68
- * @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
69
- * @returns the normalized path string.
70
- */
71
- function normalizeString(path, allowAboveRoot) {
72
- let res = "";
73
- let lastSegmentLength = 0;
74
- let lastSlash = -1;
75
- let dots = 0;
76
- let char = null;
77
- for (let index = 0; index <= path.length; ++index) {
78
- if (index < path.length) char = path[index];
79
- else if (char === "/") break;
80
- else char = "/";
81
- if (char === "/") {
82
- if (lastSlash === index - 1 || dots === 1) {} else if (dots === 2) {
83
- if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
84
- if (res.length > 2) {
85
- const lastSlashIndex = res.lastIndexOf("/");
86
- if (lastSlashIndex === -1) {
87
- res = "";
88
- lastSegmentLength = 0;
89
- } else {
90
- res = res.slice(0, lastSlashIndex);
91
- lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
92
- }
93
- lastSlash = index;
94
- dots = 0;
95
- continue;
96
- } else if (res.length > 0) {
97
- res = "";
98
- lastSegmentLength = 0;
99
- lastSlash = index;
100
- dots = 0;
101
- continue;
102
- }
103
- }
104
- if (allowAboveRoot) {
105
- res += res.length > 0 ? "/.." : "..";
106
- lastSegmentLength = 2;
107
- }
108
- } else {
109
- if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
110
- else res = path.slice(lastSlash + 1, index);
111
- lastSegmentLength = index - lastSlash - 1;
112
- }
113
- lastSlash = index;
114
- dots = 0;
115
- } else if (char === "." && dots !== -1) ++dots;
116
- else dots = -1;
117
- }
118
- return res;
119
- }
120
-
121
- //#endregion
122
- export { joinPaths };
123
- //# sourceMappingURL=join-paths.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"join-paths.mjs","names":["char: string | null"],"sources":["../../../../path/src/join-paths.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 { isAbsolute } from \"./is-type\";\nimport {\n DRIVE_LETTER_REGEX,\n DRIVE_LETTER_START_REGEX,\n UNC_REGEX\n} from \"./regex\";\nimport { slash } from \"./slash\";\n\n// Util to normalize windows paths to posix\nfunction normalizeWindowsPath(input = \"\") {\n if (!input) {\n return input;\n }\n return input\n .replace(/\\\\/g, \"/\")\n .replace(DRIVE_LETTER_START_REGEX, r => r.toUpperCase());\n}\n\nfunction correctPaths(path?: string) {\n if (!path || path.length === 0) {\n return \".\";\n }\n\n // Normalize windows argument\n path = normalizeWindowsPath(path);\n\n const isUNCPath = path.match(UNC_REGEX);\n const isPathAbsolute = isAbsolute(path);\n const trailingSeparator = path[path.length - 1] === \"/\";\n\n // Normalize the path\n path = normalizeString(path, !isPathAbsolute);\n\n if (path.length === 0) {\n if (isPathAbsolute) {\n return \"/\";\n }\n return trailingSeparator ? \"./\" : \".\";\n }\n if (trailingSeparator) {\n path += \"/\";\n }\n if (DRIVE_LETTER_REGEX.test(path)) {\n path += \"/\";\n }\n\n if (isUNCPath) {\n if (!isPathAbsolute) {\n return `//./${path}`;\n }\n return `//${path}`;\n }\n\n return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;\n}\n\n/**\n * Joins all given path segments together using the platform-specific separator as a delimiter.\n *\n * @remarks\n * Multiple segments can be provided as separate arguments. The resulting path is normalized to remove any redundant or unnecessary segments.\n *\n * @example\n * ```ts\n * import { joinPaths } from 'stryke/path';\n *\n * const fullPath = joinPaths('folder1', 'folder2', '..', 'folder3', 'file.txt');\n * console.log(fullPath); // Output: 'folder1/folder3/file.txt'\n *\n * const absolutePath = joinPaths('/root', 'folder', '.', 'subfolder', 'file.txt');\n * console.log(absolutePath); // Output: '/root/folder/subfolder/file.txt'\n *\n * const windowsPath = joinPaths('C:\\\\', 'Users', 'Public', '..', 'Documents', 'file.txt');\n * console.log(windowsPath); // Output: 'C:/Users/Documents/file.txt'\n *\n * const uncPath = joinPaths('\\\\\\\\Server\\\\Share', 'Folder', 'File.txt');\n * console.log(uncPath); // Output: '//Server/Share/Folder/File.txt'\n * ```\n *\n * @param segments - The path segments to join.\n * @returns The joined and normalized path string.\n */\nexport function joinPaths(...segments: string[]): string {\n let result = \"\";\n for (const segment of segments) {\n if (segment && slash(segment).replaceAll(/\\//g, \"\") !== \".\") {\n if (result) {\n if (slash(segment).replaceAll(/\\//g, \"\") === \"..\") {\n result = slash(result)\n .replace(/\\/+$/, \"\")\n .replace(/\\/*[^/]+$/, \"\");\n } else {\n result = `${slash(result).replace(/\\/+$/, \"\")}/${slash(\n segment\n ).replace(/^\\/+/, \"\")}`;\n }\n } else if (slash(segment).replaceAll(/\\//g, \"\") !== \"..\") {\n result = segment;\n }\n }\n }\n\n return correctPaths(result);\n}\n\nexport const join = joinPaths;\n\n/**\n * Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.\n *\n * @param path - The path to normalize.\n * @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.\n * @returns the normalized path string.\n */\nfunction normalizeString(path: string, allowAboveRoot: boolean) {\n let res = \"\";\n let lastSegmentLength = 0;\n let lastSlash = -1;\n let dots = 0;\n let char: string | null = null;\n for (let index = 0; index <= path.length; ++index) {\n if (index < path.length) {\n // casted because we know it exists thanks to the length check\n char = path[index] as string;\n } else if (char === \"/\") {\n break;\n } else {\n char = \"/\";\n }\n if (char === \"/\") {\n if (lastSlash === index - 1 || dots === 1) {\n // NOOP\n } else if (dots === 2) {\n if (\n res.length < 2 ||\n lastSegmentLength !== 2 ||\n res[res.length - 1] !== \".\" ||\n res[res.length - 2] !== \".\"\n ) {\n if (res.length > 2) {\n const lastSlashIndex = res.lastIndexOf(\"/\");\n if (lastSlashIndex === -1) {\n res = \"\";\n lastSegmentLength = 0;\n } else {\n res = res.slice(0, lastSlashIndex);\n lastSegmentLength = res.length - 1 - res.lastIndexOf(\"/\");\n }\n lastSlash = index;\n dots = 0;\n continue;\n } else if (res.length > 0) {\n res = \"\";\n lastSegmentLength = 0;\n lastSlash = index;\n dots = 0;\n continue;\n }\n }\n if (allowAboveRoot) {\n res += res.length > 0 ? \"/..\" : \"..\";\n lastSegmentLength = 2;\n }\n } else {\n if (res.length > 0) {\n res += `/${path.slice(lastSlash + 1, index)}`;\n } else {\n res = path.slice(lastSlash + 1, index);\n }\n lastSegmentLength = index - lastSlash - 1;\n }\n lastSlash = index;\n dots = 0;\n } else if (char === \".\" && dots !== -1) {\n ++dots;\n } else {\n dots = -1;\n }\n }\n return res;\n}\n"],"mappings":";;;;;AA2BA,SAAS,qBAAqB,QAAQ,IAAI;AACxC,KAAI,CAAC,MACH,QAAO;AAET,QAAO,MACJ,QAAQ,OAAO,IAAI,CACnB,QAAQ,2BAA0B,MAAK,EAAE,aAAa,CAAC;;AAG5D,SAAS,aAAa,MAAe;AACnC,KAAI,CAAC,QAAQ,KAAK,WAAW,EAC3B,QAAO;AAIT,QAAO,qBAAqB,KAAK;CAEjC,MAAM,YAAY,KAAK,MAAM,UAAU;CACvC,MAAM,iBAAiB,WAAW,KAAK;CACvC,MAAM,oBAAoB,KAAK,KAAK,SAAS,OAAO;AAGpD,QAAO,gBAAgB,MAAM,CAAC,eAAe;AAE7C,KAAI,KAAK,WAAW,GAAG;AACrB,MAAI,eACF,QAAO;AAET,SAAO,oBAAoB,OAAO;;AAEpC,KAAI,kBACF,SAAQ;AAEV,KAAI,mBAAmB,KAAK,KAAK,CAC/B,SAAQ;AAGV,KAAI,WAAW;AACb,MAAI,CAAC,eACH,QAAO,OAAO;AAEhB,SAAO,KAAK;;AAGd,QAAO,kBAAkB,CAAC,WAAW,KAAK,GAAG,IAAI,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6B5D,SAAgB,UAAU,GAAG,UAA4B;CACvD,IAAI,SAAS;AACb,MAAK,MAAM,WAAW,SACpB,KAAI,WAAW,MAAM,QAAQ,CAAC,WAAW,OAAO,GAAG,KAAK,KACtD;MAAI,OACF,KAAI,MAAM,QAAQ,CAAC,WAAW,OAAO,GAAG,KAAK,KAC3C,UAAS,MAAM,OAAO,CACnB,QAAQ,QAAQ,GAAG,CACnB,QAAQ,aAAa,GAAG;MAE3B,UAAS,GAAG,MAAM,OAAO,CAAC,QAAQ,QAAQ,GAAG,CAAC,GAAG,MAC/C,QACD,CAAC,QAAQ,QAAQ,GAAG;WAEd,MAAM,QAAQ,CAAC,WAAW,OAAO,GAAG,KAAK,KAClD,UAAS;;AAKf,QAAO,aAAa,OAAO;;;;;;;;;AAY7B,SAAS,gBAAgB,MAAc,gBAAyB;CAC9D,IAAI,MAAM;CACV,IAAI,oBAAoB;CACxB,IAAI,YAAY;CAChB,IAAI,OAAO;CACX,IAAIA,OAAsB;AAC1B,MAAK,IAAI,QAAQ,GAAG,SAAS,KAAK,QAAQ,EAAE,OAAO;AACjD,MAAI,QAAQ,KAAK,OAEf,QAAO,KAAK;WACH,SAAS,IAClB;MAEA,QAAO;AAET,MAAI,SAAS,KAAK;AAChB,OAAI,cAAc,QAAQ,KAAK,SAAS,GAAG,YAEhC,SAAS,GAAG;AACrB,QACE,IAAI,SAAS,KACb,sBAAsB,KACtB,IAAI,IAAI,SAAS,OAAO,OACxB,IAAI,IAAI,SAAS,OAAO,KAExB;SAAI,IAAI,SAAS,GAAG;MAClB,MAAM,iBAAiB,IAAI,YAAY,IAAI;AAC3C,UAAI,mBAAmB,IAAI;AACzB,aAAM;AACN,2BAAoB;aACf;AACL,aAAM,IAAI,MAAM,GAAG,eAAe;AAClC,2BAAoB,IAAI,SAAS,IAAI,IAAI,YAAY,IAAI;;AAE3D,kBAAY;AACZ,aAAO;AACP;gBACS,IAAI,SAAS,GAAG;AACzB,YAAM;AACN,0BAAoB;AACpB,kBAAY;AACZ,aAAO;AACP;;;AAGJ,QAAI,gBAAgB;AAClB,YAAO,IAAI,SAAS,IAAI,QAAQ;AAChC,yBAAoB;;UAEjB;AACL,QAAI,IAAI,SAAS,EACf,QAAO,IAAI,KAAK,MAAM,YAAY,GAAG,MAAM;QAE3C,OAAM,KAAK,MAAM,YAAY,GAAG,MAAM;AAExC,wBAAoB,QAAQ,YAAY;;AAE1C,eAAY;AACZ,UAAO;aACE,SAAS,OAAO,SAAS,GAClC,GAAE;MAEF,QAAO;;AAGX,QAAO"}
@@ -1,12 +0,0 @@
1
-
2
- //#region ../path/src/regex.ts
3
- const DRIVE_LETTER_START_REGEX = /^[A-Z]:\//i;
4
- const DRIVE_LETTER_REGEX = /^[A-Z]:$/i;
5
- const UNC_REGEX = /^[/\\]{2}/;
6
- const ABSOLUTE_PATH_REGEX = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^~[/\\]|^[A-Z]:[/\\]/i;
7
-
8
- //#endregion
9
- exports.ABSOLUTE_PATH_REGEX = ABSOLUTE_PATH_REGEX;
10
- exports.DRIVE_LETTER_REGEX = DRIVE_LETTER_REGEX;
11
- exports.DRIVE_LETTER_START_REGEX = DRIVE_LETTER_START_REGEX;
12
- exports.UNC_REGEX = UNC_REGEX;
@@ -1,9 +0,0 @@
1
- //#region ../path/src/regex.ts
2
- const DRIVE_LETTER_START_REGEX = /^[A-Z]:\//i;
3
- const DRIVE_LETTER_REGEX = /^[A-Z]:$/i;
4
- const UNC_REGEX = /^[/\\]{2}/;
5
- const ABSOLUTE_PATH_REGEX = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^~[/\\]|^[A-Z]:[/\\]/i;
6
-
7
- //#endregion
8
- export { ABSOLUTE_PATH_REGEX, DRIVE_LETTER_REGEX, DRIVE_LETTER_START_REGEX, UNC_REGEX };
9
- //# sourceMappingURL=regex.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"regex.mjs","names":[],"sources":["../../../../path/src/regex.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\nexport const DRIVE_LETTER_START_REGEX = /^[A-Z]:\\//i;\nexport const DRIVE_LETTER_REGEX = /^[A-Z]:$/i;\n\nexport const UNC_REGEX = /^[/\\\\]{2}/;\n\nexport const ABSOLUTE_PATH_REGEX =\n /^[/\\\\](?![/\\\\])|^[/\\\\]{2}(?!\\.)|^~[/\\\\]|^[A-Z]:[/\\\\]/i;\n\nexport const ROOT_FOLDER_REGEX = /^\\/([A-Z]:)?$/i;\n\nexport const FILE_EXTENSION_REGEX = /\\.[0-9a-z]+$/i;\nexport const FULL_FILE_EXTENSION_REGEX = /(\\.d)?\\.[0-9a-z]+(\\.map)?$/i;\n\nexport const PACKAGE_PATH_REGEX = /^@\\w+\\/.*$/;\nexport const NPM_SCOPED_PACKAGE_REGEX = /^(?:@[\\w-]+\\/)?[\\w-]+$/;\n"],"mappings":";AAkBA,MAAa,2BAA2B;AACxC,MAAa,qBAAqB;AAElC,MAAa,YAAY;AAEzB,MAAa,sBACX"}
@@ -1,15 +0,0 @@
1
-
2
- //#region ../path/src/slash.ts
3
- /**
4
- * Replace backslash to slash
5
- *
6
- * @param path - The string to replace
7
- * @returns The string with replaced backslashes
8
- */
9
- function slash(path) {
10
- if (path.startsWith("\\\\?\\")) return path;
11
- return path.replace(/\\/g, "/");
12
- }
13
-
14
- //#endregion
15
- exports.slash = slash;
@@ -1,15 +0,0 @@
1
- //#region ../path/src/slash.ts
2
- /**
3
- * Replace backslash to slash
4
- *
5
- * @param path - The string to replace
6
- * @returns The string with replaced backslashes
7
- */
8
- function slash(path) {
9
- if (path.startsWith("\\\\?\\")) return path;
10
- return path.replace(/\\/g, "/");
11
- }
12
-
13
- //#endregion
14
- export { slash };
15
- //# sourceMappingURL=slash.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"slash.mjs","names":[],"sources":["../../../../path/src/slash.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 { isAbsolutePath } from \"./is-type\";\n\n/**\n * Replace backslash to slash\n *\n * @param path - The string to replace\n * @returns The string with replaced backslashes\n */\nexport function slash(path: string) {\n if (path.startsWith(\"\\\\\\\\?\\\\\")) {\n return path;\n }\n\n return path.replace(/\\\\/g, \"/\");\n}\n\n/**\n * Replace backslash to slash and remove unneeded leading and trailing slashes\n *\n * @param path - The string to replace\n * @returns The string with replaced backslashes\n */\nexport function formatSlash(path: string) {\n const formatted = slash(path);\n\n return isAbsolutePath(formatted)\n ? formatted.replace(/\\/+$/g, \"\")\n : formatted.replace(/^\\.\\//g, \"\").replace(/\\/+$/g, \"\");\n}\n"],"mappings":";;;;;;;AA0BA,SAAgB,MAAM,MAAc;AAClC,KAAI,KAAK,WAAW,UAAU,CAC5B,QAAO;AAGT,QAAO,KAAK,QAAQ,OAAO,IAAI"}
@@ -1,4 +0,0 @@
1
- const require_is_buffer = require('./is-buffer.cjs');
2
- require('./type-detect.cjs');
3
- require('./is-collection.cjs');
4
- const require_is_string = require('./is-string.cjs');
@@ -1,6 +0,0 @@
1
- import { isBufferExists } from "./is-buffer.mjs";
2
- import "./type-detect.mjs";
3
- import "./is-collection.mjs";
4
- import { isString } from "./is-string.mjs";
5
-
6
- export { };
@@ -1,12 +0,0 @@
1
-
2
- //#region ../type-checks/src/is-buffer.ts
3
- const isBufferExists = typeof Buffer !== "undefined";
4
- /**
5
- * Check if the provided value's type is `Buffer`
6
- */
7
- const isBuffer = isBufferExists ? Buffer.isBuffer.bind(Buffer) : function isBuffer$1(value) {
8
- return false;
9
- };
10
-
11
- //#endregion
12
- exports.isBufferExists = isBufferExists;
@@ -1,12 +0,0 @@
1
- //#region ../type-checks/src/is-buffer.ts
2
- const isBufferExists = typeof Buffer !== "undefined";
3
- /**
4
- * Check if the provided value's type is `Buffer`
5
- */
6
- const isBuffer = isBufferExists ? Buffer.isBuffer.bind(Buffer) : function isBuffer$1(value) {
7
- return false;
8
- };
9
-
10
- //#endregion
11
- export { isBufferExists };
12
- //# sourceMappingURL=is-buffer.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-buffer.mjs","names":["isBuffer: typeof Buffer.isBuffer","isBuffer"],"sources":["../../../../type-checks/src/is-buffer.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\nexport const isBufferExists = typeof Buffer !== \"undefined\";\n\n/**\n * Check if the provided value's type is `Buffer`\n */\nexport const isBuffer: typeof Buffer.isBuffer = isBufferExists\n ? Buffer.isBuffer.bind(Buffer)\n : /**\n * Check if the provided value's type is `Buffer`\n\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Buffer`\n */\n function isBuffer(\n value: Parameters<typeof Buffer.isBuffer>[0]\n ): value is Buffer {\n return false;\n };\n"],"mappings":";AAkBA,MAAa,iBAAiB,OAAO,WAAW;;;;AAKhD,MAAaA,WAAmC,iBAC5C,OAAO,SAAS,KAAK,OAAO,GAO5B,SAASC,WACP,OACiB;AACjB,QAAO"}
@@ -1 +0,0 @@
1
- require('./type-detect.cjs');
@@ -1,3 +0,0 @@
1
- import "./type-detect.mjs";
2
-
3
- export { };
@@ -1,12 +0,0 @@
1
-
2
- //#region ../type-checks/src/is-string.ts
3
- const isString = (value) => {
4
- try {
5
- return typeof value === "string";
6
- } catch {
7
- return false;
8
- }
9
- };
10
-
11
- //#endregion
12
- exports.isString = isString;
@@ -1,12 +0,0 @@
1
- //#region ../type-checks/src/is-string.ts
2
- const isString = (value) => {
3
- try {
4
- return typeof value === "string";
5
- } catch {
6
- return false;
7
- }
8
- };
9
-
10
- //#endregion
11
- export { isString };
12
- //# sourceMappingURL=is-string.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-string.mjs","names":[],"sources":["../../../../type-checks/src/is-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\nexport const isString = (value: unknown): value is string => {\n try {\n return typeof value === \"string\";\n } catch {\n return false;\n }\n};\n"],"mappings":";AAkBA,MAAa,YAAY,UAAoC;AAC3D,KAAI;AACF,SAAO,OAAO,UAAU;SAClB;AACN,SAAO"}
@@ -1,15 +0,0 @@
1
- require('./is-buffer.cjs');
2
-
3
- //#region ../type-checks/src/type-detect.ts
4
- const globalObject = ((Obj) => {
5
- if (typeof globalThis === "object") return globalThis;
6
- Object.defineProperty(Obj, "typeDetectGlobalObject", {
7
- get() {
8
- return this;
9
- },
10
- configurable: true
11
- });
12
- return globalThis;
13
- })(Object.prototype);
14
-
15
- //#endregion
@@ -1,17 +0,0 @@
1
- import "./is-buffer.mjs";
2
-
3
- //#region ../type-checks/src/type-detect.ts
4
- const globalObject = ((Obj) => {
5
- if (typeof globalThis === "object") return globalThis;
6
- Object.defineProperty(Obj, "typeDetectGlobalObject", {
7
- get() {
8
- return this;
9
- },
10
- configurable: true
11
- });
12
- return globalThis;
13
- })(Object.prototype);
14
-
15
- //#endregion
16
- export { };
17
- //# sourceMappingURL=type-detect.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type-detect.mjs","names":[],"sources":["../../../../type-checks/src/type-detect.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 { isBuffer } from \"./is-buffer\";\n\nconst globalObject = (Obj => {\n if (typeof globalThis === \"object\") {\n return globalThis;\n }\n Object.defineProperty(Obj, \"typeDetectGlobalObject\", {\n get() {\n return this;\n },\n configurable: true\n });\n\n // // biome-ignore lint/correctness/noUndeclaredVariables: <explanation>\n // const global = typeDetectGlobalObject;\n\n // // biome-ignore lint/performance/noDelete: <explanation>\n // delete Obj.typeDetectGlobalObject;\n return globalThis;\n})(Object.prototype);\n\nexport function typeDetect(obj: unknown): string {\n // NOTE: isBuffer must execute before type-detect,\n // because type-detect returns 'Uint8Array'.\n if (isBuffer(obj)) {\n return \"Buffer\";\n }\n\n const typeofObj = typeof obj;\n if (typeofObj !== \"object\") {\n return typeofObj;\n }\n\n if (obj === null) {\n return \"null\";\n }\n\n if (obj === globalObject) {\n return \"global\";\n }\n\n if (\n Array.isArray(obj) &&\n (Symbol.toStringTag === undefined || !(Symbol.toStringTag in obj))\n ) {\n return \"Array\";\n }\n\n // https://html.spec.whatwg.org/multipage/browsers.html#location\n if (typeof globalThis === \"object\" && globalThis !== null) {\n if (\n typeof (globalThis as any).location === \"object\" &&\n obj === (globalThis as any).location\n ) {\n return \"Location\";\n }\n\n // https://html.spec.whatwg.org/#document\n if (\n typeof (globalThis as any).document === \"object\" &&\n obj === (globalThis as any).document\n ) {\n return \"Document\";\n }\n\n // https://html.spec.whatwg.org/multipage/webappapis.html#mimetypearray\n if (typeof (globalThis as any).navigator === \"object\") {\n if (\n typeof (globalThis as any).navigator.mimeTypes === \"object\" &&\n obj === (globalThis as any).navigator.mimeTypes\n ) {\n return \"MimeTypeArray\";\n }\n\n // https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray\n if (\n typeof (globalThis as any).navigator.plugins === \"object\" &&\n obj === (globalThis as any).navigator.plugins\n ) {\n return \"PluginArray\";\n }\n }\n\n // https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray\n if (\n (typeof (globalThis as any).HTMLElement === \"function\" ||\n typeof (globalThis as any).HTMLElement === \"object\") &&\n obj instanceof (globalThis as any).HTMLElement\n ) {\n if ((obj as any).tagName === \"BLOCKQUOTE\") {\n return \"HTMLQuoteElement\";\n }\n\n // https://html.spec.whatwg.org/#htmltabledatacellelement\n if ((obj as any).tagName === \"TD\") {\n return \"HTMLTableDataCellElement\";\n }\n\n // https://html.spec.whatwg.org/#htmltableheadercellelement\n if ((obj as any).tagName === \"TH\") {\n return \"HTMLTableHeaderCellElement\";\n }\n }\n }\n\n const stringTag =\n Symbol.toStringTag !== undefined && (obj as any)[Symbol.toStringTag];\n if (typeof stringTag === \"string\") {\n return stringTag;\n }\n\n const objPrototype = Object.getPrototypeOf(obj);\n if (objPrototype === RegExp.prototype) {\n return \"RegExp\";\n }\n\n if (objPrototype === Date.prototype) {\n return \"Date\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-promise.prototype-@@tostringtag\n if (typeof Promise !== \"undefined\" && objPrototype === Promise.prototype) {\n return \"Promise\";\n }\n\n if (typeof Set !== \"undefined\" && objPrototype === Set.prototype) {\n return \"Set\";\n }\n\n if (typeof Map !== \"undefined\" && objPrototype === Map.prototype) {\n return \"Map\";\n }\n\n if (typeof WeakSet !== \"undefined\" && objPrototype === WeakSet.prototype) {\n return \"WeakSet\";\n }\n\n if (typeof WeakMap !== \"undefined\" && objPrototype === WeakMap.prototype) {\n return \"WeakMap\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-dataview.prototype-@@tostringtag\n if (typeof DataView !== \"undefined\" && objPrototype === DataView.prototype) {\n return \"DataView\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%mapiteratorprototype%-@@tostringtag\n if (\n typeof Map !== \"undefined\" &&\n objPrototype === Object.getPrototypeOf(new Map().entries())\n ) {\n return \"Map Iterator\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%setiteratorprototype%-@@tostringtag\n if (\n typeof Set !== \"undefined\" &&\n objPrototype === Object.getPrototypeOf(new Set().entries())\n ) {\n return \"Set Iterator\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%arrayiteratorprototype%-@@tostringtag\n if (\n typeof Array.prototype[Symbol.iterator] === \"function\" &&\n objPrototype === Object.getPrototypeOf([][Symbol.iterator]())\n ) {\n return \"Array Iterator\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%stringiteratorprototype%-@@tostringtag\n if (\n Symbol.iterator !== undefined &&\n typeof String.prototype[Symbol.iterator] === \"function\" &&\n Object.getPrototypeOf(\"\"[Symbol.iterator]()) &&\n objPrototype === Object.getPrototypeOf(\"\"[Symbol.iterator]())\n ) {\n return \"String Iterator\";\n }\n\n if (objPrototype === null) {\n return \"Object\";\n }\n\n return Object.prototype.toString.call(obj).slice(8, -1);\n}\n"],"mappings":";;;AAoBA,MAAM,iBAAgB,QAAO;AAC3B,KAAI,OAAO,eAAe,SACxB,QAAO;AAET,QAAO,eAAe,KAAK,0BAA0B;EACnD,MAAM;AACJ,UAAO;;EAET,cAAc;EACf,CAAC;AAOF,QAAO;GACN,OAAO,UAAU"}
package/dist/xx-hash.cjs DELETED
@@ -1,25 +0,0 @@
1
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
- let js_xxhash = require("js-xxhash");
3
-
4
- //#region src/xx-hash.ts
5
- /**
6
- * xxHash32 only computes 32-bit values. Run it n times with different seeds to
7
- * get a larger hash with better collision resistance.
8
- *
9
- * @param content - The string to hash
10
- * @param words - The number of 32-bit words to hash
11
- * @returns A 128-bit hash
12
- */
13
- function _xxHash32(content, words) {
14
- let hash = 0n;
15
- for (let i = 0; i < words; i++) hash = (hash << 32n) + BigInt((0, js_xxhash.xxHash32)(content, i));
16
- return hash;
17
- }
18
- const xxHash32 = (s) => (0, js_xxhash.xxHash32)(s, 0);
19
- const xxHash64 = (s) => _xxHash32(s, 2);
20
- const xxHash128 = (s) => _xxHash32(s, 4);
21
-
22
- //#endregion
23
- exports.xxHash128 = xxHash128;
24
- exports.xxHash32 = xxHash32;
25
- exports.xxHash64 = xxHash64;
@@ -1,7 +0,0 @@
1
- //#region src/xx-hash.d.ts
2
- declare const xxHash32: (s: string) => number;
3
- declare const xxHash64: (s: string) => bigint;
4
- declare const xxHash128: (s: string) => bigint;
5
- //#endregion
6
- export { xxHash128, xxHash32, xxHash64 };
7
- //# sourceMappingURL=xx-hash.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"xx-hash.d.cts","names":[],"sources":["../src/xx-hash.ts"],"sourcesContent":[],"mappings":";cAoCa;AAAA,cACA,QAD4C,EAAA,CAAA,CAAA,EAAA,MAAA,EAAA,GAAA,MAAA;AAC5C,cACA,SADyC,EAAA,CAAA,CAAA,EAAA,MAAA,EAAA,GAAA,MAAA"}
@@ -1,7 +0,0 @@
1
- //#region src/xx-hash.d.ts
2
- declare const xxHash32: (s: string) => number;
3
- declare const xxHash64: (s: string) => bigint;
4
- declare const xxHash128: (s: string) => bigint;
5
- //#endregion
6
- export { xxHash128, xxHash32, xxHash64 };
7
- //# sourceMappingURL=xx-hash.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"xx-hash.d.mts","names":[],"sources":["../src/xx-hash.ts"],"sourcesContent":[],"mappings":";cAoCa;AAAA,cACA,QAD4C,EAAA,CAAA,CAAA,EAAA,MAAA,EAAA,GAAA,MAAA;AAC5C,cACA,SADyC,EAAA,CAAA,CAAA,EAAA,MAAA,EAAA,GAAA,MAAA"}