@stryke/helpers 0.10.22 → 0.10.23

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 (196) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/arg-identity.cjs +1 -9
  3. package/dist/arg-identity.mjs +1 -4
  4. package/dist/arg-identity.mjs.map +1 -1
  5. package/dist/deep-clone.cjs +1 -9
  6. package/dist/deep-clone.mjs +1 -3
  7. package/dist/deep-clone.mjs.map +1 -1
  8. package/dist/deep-merge.cjs +1 -9
  9. package/dist/deep-merge.mjs +1 -3
  10. package/dist/deep-merge.mjs.map +1 -1
  11. package/dist/filter-empty.cjs +1 -9
  12. package/dist/filter-empty.mjs +1 -3
  13. package/dist/filter-empty.mjs.map +1 -1
  14. package/dist/flatten-object.cjs +1 -9
  15. package/dist/flatten-object.mjs +1 -3
  16. package/dist/flatten-object.mjs.map +1 -1
  17. package/dist/get-field.cjs +1 -9
  18. package/dist/get-field.mjs +1 -3
  19. package/dist/get-field.mjs.map +1 -1
  20. package/dist/get-ordered-by.cjs +1 -9
  21. package/dist/get-ordered-by.mjs +1 -4
  22. package/dist/get-ordered-by.mjs.map +1 -1
  23. package/dist/get-unique.cjs +1 -12
  24. package/dist/get-unique.mjs +1 -7
  25. package/dist/get-unique.mjs.map +1 -1
  26. package/dist/identity.cjs +1 -9
  27. package/dist/identity.mjs +1 -4
  28. package/dist/identity.mjs.map +1 -1
  29. package/dist/index.cjs +0 -41
  30. package/dist/index.mjs +1 -37
  31. package/dist/is-equal.cjs +1 -9
  32. package/dist/is-equal.mjs +1 -3
  33. package/dist/is-equal.mjs.map +1 -1
  34. package/dist/lru-cache.cjs +1 -9
  35. package/dist/lru-cache.mjs +1 -4
  36. package/dist/lru-cache.mjs.map +1 -1
  37. package/dist/match-sorter.cjs +0 -12
  38. package/dist/match-sorter.mjs +1 -7
  39. package/dist/match-sorter.mjs.map +1 -1
  40. package/dist/memoize.cjs +1 -9
  41. package/dist/memoize.mjs +1 -4
  42. package/dist/memoize.mjs.map +1 -1
  43. package/dist/noop.cjs +1 -12
  44. package/dist/noop.mjs +1 -7
  45. package/dist/noop.mjs.map +1 -1
  46. package/dist/omit.cjs +1 -9
  47. package/dist/omit.mjs +1 -4
  48. package/dist/omit.mjs.map +1 -1
  49. package/dist/pick.cjs +1 -9
  50. package/dist/pick.mjs +1 -4
  51. package/dist/pick.mjs.map +1 -1
  52. package/dist/remove-accents.cjs +1 -12
  53. package/dist/remove-accents.mjs +1 -7
  54. package/dist/remove-accents.mjs.map +1 -1
  55. package/dist/remove-empty-items.cjs +1 -9
  56. package/dist/remove-empty-items.mjs +1 -4
  57. package/dist/remove-empty-items.mjs.map +1 -1
  58. package/dist/set-field.cjs +1 -9
  59. package/dist/set-field.mjs +1 -3
  60. package/dist/set-field.mjs.map +1 -1
  61. package/dist/to-deep-key.cjs +1 -12
  62. package/dist/to-deep-key.mjs +1 -6
  63. package/dist/to-deep-key.mjs.map +1 -1
  64. package/dist/to-path.cjs +1 -9
  65. package/dist/to-path.mjs +1 -4
  66. package/dist/to-path.mjs.map +1 -1
  67. package/dist/unflatten-object.cjs +1 -9
  68. package/dist/unflatten-object.mjs +1 -3
  69. package/dist/unflatten-object.mjs.map +1 -1
  70. package/dist/union.cjs +1 -9
  71. package/dist/union.mjs +1 -3
  72. package/dist/union.mjs.map +1 -1
  73. package/package.json +5 -101
  74. package/dist/_virtual/_rolldown/runtime.cjs +0 -19
  75. package/dist/_virtual/_rolldown/runtime.mjs +0 -18
  76. package/dist/arg-identity.test.cjs +0 -12
  77. package/dist/arg-identity.test.d.cts +0 -1
  78. package/dist/arg-identity.test.d.mts +0 -1
  79. package/dist/arg-identity.test.mjs +0 -14
  80. package/dist/arg-identity.test.mjs.map +0 -1
  81. package/dist/deep-clone.test.cjs +0 -12
  82. package/dist/deep-clone.test.d.cts +0 -1
  83. package/dist/deep-clone.test.d.mts +0 -1
  84. package/dist/deep-clone.test.mjs +0 -14
  85. package/dist/deep-clone.test.mjs.map +0 -1
  86. package/dist/deep-merge.test.cjs +0 -12
  87. package/dist/deep-merge.test.d.cts +0 -1
  88. package/dist/deep-merge.test.d.mts +0 -1
  89. package/dist/deep-merge.test.mjs +0 -14
  90. package/dist/deep-merge.test.mjs.map +0 -1
  91. package/dist/filter-empty.test.cjs +0 -12
  92. package/dist/filter-empty.test.d.cts +0 -1
  93. package/dist/filter-empty.test.d.mts +0 -1
  94. package/dist/filter-empty.test.mjs +0 -14
  95. package/dist/filter-empty.test.mjs.map +0 -1
  96. package/dist/flatten-object.test.cjs +0 -12
  97. package/dist/flatten-object.test.d.cts +0 -1
  98. package/dist/flatten-object.test.d.mts +0 -1
  99. package/dist/flatten-object.test.mjs +0 -14
  100. package/dist/flatten-object.test.mjs.map +0 -1
  101. package/dist/get-field.test.cjs +0 -12
  102. package/dist/get-field.test.d.cts +0 -1
  103. package/dist/get-field.test.d.mts +0 -1
  104. package/dist/get-field.test.mjs +0 -14
  105. package/dist/get-field.test.mjs.map +0 -1
  106. package/dist/get-ordered-by.test.cjs +0 -12
  107. package/dist/get-ordered-by.test.d.cts +0 -1
  108. package/dist/get-ordered-by.test.d.mts +0 -1
  109. package/dist/get-ordered-by.test.mjs +0 -14
  110. package/dist/get-ordered-by.test.mjs.map +0 -1
  111. package/dist/get-unique.test.cjs +0 -12
  112. package/dist/get-unique.test.d.cts +0 -1
  113. package/dist/get-unique.test.d.mts +0 -1
  114. package/dist/get-unique.test.mjs +0 -14
  115. package/dist/get-unique.test.mjs.map +0 -1
  116. package/dist/identity.test.cjs +0 -12
  117. package/dist/identity.test.d.cts +0 -1
  118. package/dist/identity.test.d.mts +0 -1
  119. package/dist/identity.test.mjs +0 -14
  120. package/dist/identity.test.mjs.map +0 -1
  121. package/dist/index.mjs.map +0 -1
  122. package/dist/index.test.cjs +0 -12
  123. package/dist/index.test.d.cts +0 -1
  124. package/dist/index.test.d.mts +0 -1
  125. package/dist/index.test.mjs +0 -14
  126. package/dist/index.test.mjs.map +0 -1
  127. package/dist/is-equal.test.cjs +0 -12
  128. package/dist/is-equal.test.d.cts +0 -1
  129. package/dist/is-equal.test.d.mts +0 -1
  130. package/dist/is-equal.test.mjs +0 -14
  131. package/dist/is-equal.test.mjs.map +0 -1
  132. package/dist/lru-cache.test.cjs +0 -12
  133. package/dist/lru-cache.test.d.cts +0 -1
  134. package/dist/lru-cache.test.d.mts +0 -1
  135. package/dist/lru-cache.test.mjs +0 -14
  136. package/dist/lru-cache.test.mjs.map +0 -1
  137. package/dist/match-sorter.test.cjs +0 -12
  138. package/dist/match-sorter.test.d.cts +0 -1
  139. package/dist/match-sorter.test.d.mts +0 -1
  140. package/dist/match-sorter.test.mjs +0 -14
  141. package/dist/match-sorter.test.mjs.map +0 -1
  142. package/dist/memoize.test.cjs +0 -12
  143. package/dist/memoize.test.d.cts +0 -1
  144. package/dist/memoize.test.d.mts +0 -1
  145. package/dist/memoize.test.mjs +0 -14
  146. package/dist/memoize.test.mjs.map +0 -1
  147. package/dist/noop.test.cjs +0 -12
  148. package/dist/noop.test.d.cts +0 -1
  149. package/dist/noop.test.d.mts +0 -1
  150. package/dist/noop.test.mjs +0 -14
  151. package/dist/noop.test.mjs.map +0 -1
  152. package/dist/omit.test.cjs +0 -12
  153. package/dist/omit.test.d.cts +0 -1
  154. package/dist/omit.test.d.mts +0 -1
  155. package/dist/omit.test.mjs +0 -14
  156. package/dist/omit.test.mjs.map +0 -1
  157. package/dist/pick.test.cjs +0 -12
  158. package/dist/pick.test.d.cts +0 -1
  159. package/dist/pick.test.d.mts +0 -1
  160. package/dist/pick.test.mjs +0 -14
  161. package/dist/pick.test.mjs.map +0 -1
  162. package/dist/remove-accents.test.cjs +0 -12
  163. package/dist/remove-accents.test.d.cts +0 -1
  164. package/dist/remove-accents.test.d.mts +0 -1
  165. package/dist/remove-accents.test.mjs +0 -14
  166. package/dist/remove-accents.test.mjs.map +0 -1
  167. package/dist/remove-empty-items.test.cjs +0 -12
  168. package/dist/remove-empty-items.test.d.cts +0 -1
  169. package/dist/remove-empty-items.test.d.mts +0 -1
  170. package/dist/remove-empty-items.test.mjs +0 -14
  171. package/dist/remove-empty-items.test.mjs.map +0 -1
  172. package/dist/set-field.test.cjs +0 -12
  173. package/dist/set-field.test.d.cts +0 -1
  174. package/dist/set-field.test.d.mts +0 -1
  175. package/dist/set-field.test.mjs +0 -14
  176. package/dist/set-field.test.mjs.map +0 -1
  177. package/dist/to-deep-key.test.cjs +0 -12
  178. package/dist/to-deep-key.test.d.cts +0 -1
  179. package/dist/to-deep-key.test.d.mts +0 -1
  180. package/dist/to-deep-key.test.mjs +0 -14
  181. package/dist/to-deep-key.test.mjs.map +0 -1
  182. package/dist/to-path.test.cjs +0 -12
  183. package/dist/to-path.test.d.cts +0 -1
  184. package/dist/to-path.test.d.mts +0 -1
  185. package/dist/to-path.test.mjs +0 -14
  186. package/dist/to-path.test.mjs.map +0 -1
  187. package/dist/unflatten-object.test.cjs +0 -12
  188. package/dist/unflatten-object.test.d.cts +0 -1
  189. package/dist/unflatten-object.test.d.mts +0 -1
  190. package/dist/unflatten-object.test.mjs +0 -14
  191. package/dist/unflatten-object.test.mjs.map +0 -1
  192. package/dist/union.test.cjs +0 -12
  193. package/dist/union.test.d.cts +0 -1
  194. package/dist/union.test.d.mts +0 -1
  195. package/dist/union.test.mjs +0 -14
  196. package/dist/union.test.mjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  # Changelog for Stryke - Helpers
4
4
 
5
+ ## [0.10.22](https://github.com/storm-software/stryke/releases/tag/helpers%400.10.22) (06/01/2026)
6
+
7
+ ### Miscellaneous
8
+
9
+ - **monorepo:** Update workspace dependencies and `vitest.config.mts` files ([998ff756](https://github.com/storm-software/stryke/commit/998ff756))
10
+
11
+ ### Updated Dependencies
12
+
13
+ - Updated **convert** to **v0.7.13**
14
+ - Updated **type-checks** to **v0.6.15**
15
+ - Updated **types** to **v0.12.10**
16
+
5
17
  ## [0.10.21](https://github.com/storm-software/stryke/releases/tag/helpers%400.10.21) (05/30/2026)
6
18
 
7
19
  ### Miscellaneous
@@ -1,8 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
2
 
4
3
  //#region src/arg-identity.ts
5
- var arg_identity_exports = /* @__PURE__ */ require_runtime.__exportAll({ argIdentity: () => argIdentity });
6
4
  /**
7
5
  * This method returns the first argument provided to it.
8
6
  *
@@ -17,10 +15,4 @@ function argIdentity(value) {
17
15
  }
18
16
 
19
17
  //#endregion
20
- exports.argIdentity = argIdentity;
21
- Object.defineProperty(exports, 'arg_identity_exports', {
22
- enumerable: true,
23
- get: function () {
24
- return arg_identity_exports;
25
- }
26
- });
18
+ exports.argIdentity = argIdentity;
@@ -1,7 +1,4 @@
1
- import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
2
-
3
1
  //#region src/arg-identity.ts
4
- var arg_identity_exports = /* @__PURE__ */ __exportAll({ argIdentity: () => argIdentity });
5
2
  /**
6
3
  * This method returns the first argument provided to it.
7
4
  *
@@ -16,5 +13,5 @@ function argIdentity(value) {
16
13
  }
17
14
 
18
15
  //#endregion
19
- export { argIdentity, arg_identity_exports };
16
+ export { argIdentity };
20
17
  //# sourceMappingURL=arg-identity.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"arg-identity.mjs","names":[],"sources":["../src/arg-identity.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 * This method returns the first argument provided to it.\n *\n * @remarks\n * For more info, please see {@link https://lodash.com/docs/4.17.15#identity | the original Lodash documentation}.\n *\n * @param value - The value to return.\n * @returns The value provided.\n */\nexport function argIdentity(value: any) {\n return value;\n}\n"],"mappings":";;;;;;;;;;;;;AA2BA,SAAgB,YAAY,OAAY;AACtC,QAAO"}
1
+ {"version":3,"file":"arg-identity.mjs","names":[],"sources":["../src/arg-identity.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 * This method returns the first argument provided to it.\n *\n * @remarks\n * For more info, please see {@link https://lodash.com/docs/4.17.15#identity | the original Lodash documentation}.\n *\n * @param value - The value to return.\n * @returns The value provided.\n */\nexport function argIdentity(value: any) {\n return value;\n}\n"],"mappings":";;;;;;;;;;AA2BA,SAAgB,YAAY,OAAY;AACtC,QAAO"}
@@ -1,9 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
2
  let _stryke_type_checks = require("@stryke/type-checks");
4
3
 
5
4
  //#region src/deep-clone.ts
6
- var deep_clone_exports = /* @__PURE__ */ require_runtime.__exportAll({ deepClone: () => deepClone });
7
5
  /**
8
6
  * Creates a deep clone of the given object.
9
7
  *
@@ -112,10 +110,4 @@ function cloneDeepHelper(obj, clonedObj) {
112
110
  }
113
111
 
114
112
  //#endregion
115
- exports.deepClone = deepClone;
116
- Object.defineProperty(exports, 'deep_clone_exports', {
117
- enumerable: true,
118
- get: function () {
119
- return deep_clone_exports;
120
- }
121
- });
113
+ exports.deepClone = deepClone;
@@ -1,8 +1,6 @@
1
- import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
2
1
  import { isPrimitive, isTypedArray } from "@stryke/type-checks";
3
2
 
4
3
  //#region src/deep-clone.ts
5
- var deep_clone_exports = /* @__PURE__ */ __exportAll({ deepClone: () => deepClone });
6
4
  /**
7
5
  * Creates a deep clone of the given object.
8
6
  *
@@ -111,5 +109,5 @@ function cloneDeepHelper(obj, clonedObj) {
111
109
  }
112
110
 
113
111
  //#endregion
114
- export { deepClone, deep_clone_exports };
112
+ export { deepClone };
115
113
  //# sourceMappingURL=deep-clone.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"deep-clone.mjs","names":[],"sources":["../src/deep-clone.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 { isPrimitive, isTypedArray } from \"@stryke/type-checks\";\n\nexport type Resolved<T> =\n Equal<T, ResolvedMain<T>> extends true ? T : ResolvedMain<T>;\n\ntype Equal<X, Y> = X extends Y ? (Y extends X ? true : false) : false;\n\ntype ResolvedMain<T> = T extends [never]\n ? never // (special trick for jsonable | null) type\n : ValueOf<T> extends boolean | number | bigint | string\n ? ValueOf<T>\n : T extends (...args: any[]) => any\n ? never\n : T extends object\n ? ResolvedObject<T>\n : ValueOf<T>;\n\ntype ResolvedObject<T extends object> = T extends (infer U)[]\n ? IsTuple<T> extends true\n ? ResolvedTuple<T>\n : ResolvedMain<U>[]\n : T extends Set<infer U>\n ? Set<ResolvedMain<U>>\n : T extends Map<infer K, infer V>\n ? Map<ResolvedMain<K>, ResolvedMain<V>>\n : T extends WeakSet<any> | WeakMap<any, any>\n ? never\n : T extends\n | Date\n | Uint8Array\n | Uint8ClampedArray\n | Uint16Array\n | Uint32Array\n | BigUint64Array\n | Int8Array\n | Int16Array\n | Int32Array\n | BigInt64Array\n | Float32Array\n | Float64Array\n | ArrayBuffer\n | SharedArrayBuffer\n | DataView\n | Blob\n | File\n ? T\n : {\n [P in keyof T]: ResolvedMain<T[P]>;\n };\n\ntype ResolvedTuple<T extends readonly any[]> = T extends []\n ? []\n : T extends [infer F]\n ? [ResolvedMain<F>]\n : T extends [infer F, ...infer Rest extends readonly any[]]\n ? [ResolvedMain<F>, ...ResolvedTuple<Rest>]\n : T extends [(infer F)?]\n ? [ResolvedMain<F>?]\n : T extends [(infer F)?, ...infer Rest extends readonly any[]]\n ? [ResolvedMain<F>?, ...ResolvedTuple<Rest>]\n : [];\n\ntype IsTuple<T extends readonly any[] | { length: number }> = [T] extends [\n never\n]\n ? false\n : T extends readonly any[]\n ? number extends T[\"length\"]\n ? false\n : true\n : false;\n\ntype ValueOf<Instance> =\n IsValueOf<Instance, boolean> extends true\n ? boolean\n : IsValueOf<Instance, number> extends true\n ? number\n : IsValueOf<Instance, string> extends true\n ? string\n : Instance;\n\ntype IsValueOf<Instance, O extends ValueOfInterface<any>> = Instance extends O\n ? O extends ValueOfInterface<infer Primitive>\n ? Instance extends Primitive\n ? false\n : true // not Primitive, but Object\n : false // cannot be\n : false;\n\ninterface ValueOfInterface<T> {\n valueOf: () => T;\n}\n\n/**\n * Creates a deep clone of the given object.\n *\n * @remarks\n * This function creates a deep clone of the given object, including nested objects and arrays. The resulting output will be of type `Resolved<T>`, which is a type that resolves to the most specific type possible for the given input type `T`. **If you are just looking for a way to copy an object deeply, use {@link deepCopy} instead.**\n *\n * @example\n * ```typescript\n * // Clone a primitive values\n * const num = 29;\n * const clonedNum = clone(num);\n * console.log(clonedNum); // 29\n * console.log(clonedNum === num) ; // true\n *\n * // Clone an array\n * const arr = [1, 2, 3];\n * const clonedArr = clone(arr);\n * console.log(clonedArr); // [1, 2, 3]\n * console.log(clonedArr === arr); // false\n *\n * // Clone an array with nested objects\n * const arr = [1, { a: 1 }, [1, 2, 3]];\n * const clonedArr = clone(arr);\n * arr[1].a = 2;\n * console.log(arr); // [2, { a: 2 }, [1, 2, 3]]\n * console.log(clonedArr); // [1, { a: 1 }, [1, 2, 3]]\n * console.log(clonedArr === arr); // false\n *\n * // Clone an object\n * const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };\n * const clonedObj = clone(obj);\n * console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }\n * console.log(clonedObj === obj); // false\n *\n *\n * // Clone an object with nested objects\n * const obj = { a: 1, b: { c: 1 } };\n * const clonedObj = clone(obj);\n * obj.b.c = 2;\n * console.log(obj); // { a: 1, b: { c: 2 } }\n * console.log(clonedObj); // { a: 1, b: { c: 1 } }\n * console.log(clonedObj === obj); // false\n * ```\n *\n * @param obj - The object to clone.\n * @returns A deep clone of the given object.\n */\nexport function deepClone<T>(obj: T): Resolved<T> {\n if (isPrimitive(obj)) {\n return obj as Resolved<T>;\n }\n\n if (Array.isArray(obj)) {\n return obj.map(item => deepClone(item)) as Resolved<T>;\n }\n\n if (obj instanceof Date) {\n return new Date(obj.getTime()) as Resolved<T>;\n }\n\n if (obj instanceof RegExp) {\n return new RegExp(obj.source, obj.flags) as Resolved<T>;\n }\n\n if (obj instanceof Map) {\n const result = new Map();\n for (const [key, value] of obj.entries()) {\n result.set(key, deepClone(value));\n }\n return result as Resolved<T>;\n }\n\n if (obj instanceof Set) {\n const result = new Set();\n for (const value of obj.values()) {\n result.add(deepClone(value));\n }\n return result as Resolved<T>;\n }\n\n if (isTypedArray(obj)) {\n // eslint-disable-next-line ts/no-unsafe-call\n const result = new (Object.getPrototypeOf(obj).constructor)(obj.length);\n\n for (const [i, element] of obj.entries()) {\n result[i] = deepClone(element);\n }\n return result as Resolved<T>;\n }\n\n if (\n obj instanceof ArrayBuffer ||\n (typeof SharedArrayBuffer !== \"undefined\" &&\n obj instanceof SharedArrayBuffer)\n ) {\n return [...(obj as any)] as Resolved<T>;\n }\n\n if (obj instanceof DataView) {\n const result = new DataView([...(obj.buffer as any)] as any);\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n // For legacy NodeJS support\n if (typeof File !== \"undefined\" && obj instanceof File) {\n const result = new File([obj], obj.name, { type: obj.type });\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n if (obj instanceof Blob) {\n const result = new Blob([obj], { type: obj.type });\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n if (obj instanceof Error) {\n const result = new (obj.constructor as new () => Error)();\n result.message = obj.message;\n result.name = obj.name;\n result.stack = obj.stack;\n result.cause = obj.cause;\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n if (typeof obj === \"object\" && obj !== null) {\n const result = {};\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n return obj as Resolved<T>;\n}\n\nfunction cloneDeepHelper(obj: any, clonedObj: any): void {\n const keys = Object.keys(obj);\n\n for (const key of keys) {\n const descriptor = Object.getOwnPropertyDescriptor(obj, key);\n\n if (descriptor?.writable || descriptor?.set) {\n clonedObj[key] = deepClone(obj[key]);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8JA,SAAgB,UAAa,KAAqB;AAChD,KAAI,YAAY,IAAI,CAClB,QAAO;AAGT,KAAI,MAAM,QAAQ,IAAI,CACpB,QAAO,IAAI,KAAI,SAAQ,UAAU,KAAK,CAAC;AAGzC,KAAI,eAAe,KACjB,QAAO,IAAI,KAAK,IAAI,SAAS,CAAC;AAGhC,KAAI,eAAe,OACjB,QAAO,IAAI,OAAO,IAAI,QAAQ,IAAI,MAAM;AAG1C,KAAI,eAAe,KAAK;EACtB,MAAM,yBAAS,IAAI,KAAK;AACxB,OAAK,MAAM,CAAC,KAAK,UAAU,IAAI,SAAS,CACtC,QAAO,IAAI,KAAK,UAAU,MAAM,CAAC;AAEnC,SAAO;;AAGT,KAAI,eAAe,KAAK;EACtB,MAAM,yBAAS,IAAI,KAAK;AACxB,OAAK,MAAM,SAAS,IAAI,QAAQ,CAC9B,QAAO,IAAI,UAAU,MAAM,CAAC;AAE9B,SAAO;;AAGT,KAAI,aAAa,IAAI,EAAE;EAErB,MAAM,SAAS,KAAK,OAAO,eAAe,IAAI,EAAC,YAAa,IAAI,OAAO;AAEvE,OAAK,MAAM,CAAC,GAAG,YAAY,IAAI,SAAS,CACtC,QAAO,KAAK,UAAU,QAAQ;AAEhC,SAAO;;AAGT,KACE,eAAe,eACd,OAAO,sBAAsB,eAC5B,eAAe,kBAEjB,QAAO,CAAC,GAAI,IAAY;AAG1B,KAAI,eAAe,UAAU;EAC3B,MAAM,SAAS,IAAI,SAAS,CAAC,GAAI,IAAI,OAAe,CAAQ;AAC5D,kBAAgB,KAAK,OAAO;AAC5B,SAAO;;AAIT,KAAI,OAAO,SAAS,eAAe,eAAe,MAAM;EACtD,MAAM,SAAS,IAAI,KAAK,CAAC,IAAI,EAAE,IAAI,MAAM,EAAE,MAAM,IAAI,MAAM,CAAC;AAC5D,kBAAgB,KAAK,OAAO;AAC5B,SAAO;;AAGT,KAAI,eAAe,MAAM;EACvB,MAAM,SAAS,IAAI,KAAK,CAAC,IAAI,EAAE,EAAE,MAAM,IAAI,MAAM,CAAC;AAClD,kBAAgB,KAAK,OAAO;AAC5B,SAAO;;AAGT,KAAI,eAAe,OAAO;EACxB,MAAM,SAAS,IAAK,IAAI,aAAiC;AACzD,SAAO,UAAU,IAAI;AACrB,SAAO,OAAO,IAAI;AAClB,SAAO,QAAQ,IAAI;AACnB,SAAO,QAAQ,IAAI;AACnB,kBAAgB,KAAK,OAAO;AAC5B,SAAO;;AAGT,KAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM;EAC3C,MAAM,SAAS,EAAE;AACjB,kBAAgB,KAAK,OAAO;AAC5B,SAAO;;AAGT,QAAO;;AAGT,SAAS,gBAAgB,KAAU,WAAsB;CACvD,MAAM,OAAO,OAAO,KAAK,IAAI;AAE7B,MAAK,MAAM,OAAO,MAAM;EACtB,MAAM,aAAa,OAAO,yBAAyB,KAAK,IAAI;AAE5D,MAAI,YAAY,YAAY,YAAY,IACtC,WAAU,OAAO,UAAU,IAAI,KAAK"}
1
+ {"version":3,"file":"deep-clone.mjs","names":[],"sources":["../src/deep-clone.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 { isPrimitive, isTypedArray } from \"@stryke/type-checks\";\n\nexport type Resolved<T> =\n Equal<T, ResolvedMain<T>> extends true ? T : ResolvedMain<T>;\n\ntype Equal<X, Y> = X extends Y ? (Y extends X ? true : false) : false;\n\ntype ResolvedMain<T> = T extends [never]\n ? never // (special trick for jsonable | null) type\n : ValueOf<T> extends boolean | number | bigint | string\n ? ValueOf<T>\n : T extends (...args: any[]) => any\n ? never\n : T extends object\n ? ResolvedObject<T>\n : ValueOf<T>;\n\ntype ResolvedObject<T extends object> = T extends (infer U)[]\n ? IsTuple<T> extends true\n ? ResolvedTuple<T>\n : ResolvedMain<U>[]\n : T extends Set<infer U>\n ? Set<ResolvedMain<U>>\n : T extends Map<infer K, infer V>\n ? Map<ResolvedMain<K>, ResolvedMain<V>>\n : T extends WeakSet<any> | WeakMap<any, any>\n ? never\n : T extends\n | Date\n | Uint8Array\n | Uint8ClampedArray\n | Uint16Array\n | Uint32Array\n | BigUint64Array\n | Int8Array\n | Int16Array\n | Int32Array\n | BigInt64Array\n | Float32Array\n | Float64Array\n | ArrayBuffer\n | SharedArrayBuffer\n | DataView\n | Blob\n | File\n ? T\n : {\n [P in keyof T]: ResolvedMain<T[P]>;\n };\n\ntype ResolvedTuple<T extends readonly any[]> = T extends []\n ? []\n : T extends [infer F]\n ? [ResolvedMain<F>]\n : T extends [infer F, ...infer Rest extends readonly any[]]\n ? [ResolvedMain<F>, ...ResolvedTuple<Rest>]\n : T extends [(infer F)?]\n ? [ResolvedMain<F>?]\n : T extends [(infer F)?, ...infer Rest extends readonly any[]]\n ? [ResolvedMain<F>?, ...ResolvedTuple<Rest>]\n : [];\n\ntype IsTuple<T extends readonly any[] | { length: number }> = [T] extends [\n never\n]\n ? false\n : T extends readonly any[]\n ? number extends T[\"length\"]\n ? false\n : true\n : false;\n\ntype ValueOf<Instance> =\n IsValueOf<Instance, boolean> extends true\n ? boolean\n : IsValueOf<Instance, number> extends true\n ? number\n : IsValueOf<Instance, string> extends true\n ? string\n : Instance;\n\ntype IsValueOf<Instance, O extends ValueOfInterface<any>> = Instance extends O\n ? O extends ValueOfInterface<infer Primitive>\n ? Instance extends Primitive\n ? false\n : true // not Primitive, but Object\n : false // cannot be\n : false;\n\ninterface ValueOfInterface<T> {\n valueOf: () => T;\n}\n\n/**\n * Creates a deep clone of the given object.\n *\n * @remarks\n * This function creates a deep clone of the given object, including nested objects and arrays. The resulting output will be of type `Resolved<T>`, which is a type that resolves to the most specific type possible for the given input type `T`. **If you are just looking for a way to copy an object deeply, use {@link deepCopy} instead.**\n *\n * @example\n * ```typescript\n * // Clone a primitive values\n * const num = 29;\n * const clonedNum = clone(num);\n * console.log(clonedNum); // 29\n * console.log(clonedNum === num) ; // true\n *\n * // Clone an array\n * const arr = [1, 2, 3];\n * const clonedArr = clone(arr);\n * console.log(clonedArr); // [1, 2, 3]\n * console.log(clonedArr === arr); // false\n *\n * // Clone an array with nested objects\n * const arr = [1, { a: 1 }, [1, 2, 3]];\n * const clonedArr = clone(arr);\n * arr[1].a = 2;\n * console.log(arr); // [2, { a: 2 }, [1, 2, 3]]\n * console.log(clonedArr); // [1, { a: 1 }, [1, 2, 3]]\n * console.log(clonedArr === arr); // false\n *\n * // Clone an object\n * const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };\n * const clonedObj = clone(obj);\n * console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }\n * console.log(clonedObj === obj); // false\n *\n *\n * // Clone an object with nested objects\n * const obj = { a: 1, b: { c: 1 } };\n * const clonedObj = clone(obj);\n * obj.b.c = 2;\n * console.log(obj); // { a: 1, b: { c: 2 } }\n * console.log(clonedObj); // { a: 1, b: { c: 1 } }\n * console.log(clonedObj === obj); // false\n * ```\n *\n * @param obj - The object to clone.\n * @returns A deep clone of the given object.\n */\nexport function deepClone<T>(obj: T): Resolved<T> {\n if (isPrimitive(obj)) {\n return obj as Resolved<T>;\n }\n\n if (Array.isArray(obj)) {\n return obj.map(item => deepClone(item)) as Resolved<T>;\n }\n\n if (obj instanceof Date) {\n return new Date(obj.getTime()) as Resolved<T>;\n }\n\n if (obj instanceof RegExp) {\n return new RegExp(obj.source, obj.flags) as Resolved<T>;\n }\n\n if (obj instanceof Map) {\n const result = new Map();\n for (const [key, value] of obj.entries()) {\n result.set(key, deepClone(value));\n }\n return result as Resolved<T>;\n }\n\n if (obj instanceof Set) {\n const result = new Set();\n for (const value of obj.values()) {\n result.add(deepClone(value));\n }\n return result as Resolved<T>;\n }\n\n if (isTypedArray(obj)) {\n // eslint-disable-next-line ts/no-unsafe-call\n const result = new (Object.getPrototypeOf(obj).constructor)(obj.length);\n\n for (const [i, element] of obj.entries()) {\n result[i] = deepClone(element);\n }\n return result as Resolved<T>;\n }\n\n if (\n obj instanceof ArrayBuffer ||\n (typeof SharedArrayBuffer !== \"undefined\" &&\n obj instanceof SharedArrayBuffer)\n ) {\n return [...(obj as any)] as Resolved<T>;\n }\n\n if (obj instanceof DataView) {\n const result = new DataView([...(obj.buffer as any)] as any);\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n // For legacy NodeJS support\n if (typeof File !== \"undefined\" && obj instanceof File) {\n const result = new File([obj], obj.name, { type: obj.type });\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n if (obj instanceof Blob) {\n const result = new Blob([obj], { type: obj.type });\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n if (obj instanceof Error) {\n const result = new (obj.constructor as new () => Error)();\n result.message = obj.message;\n result.name = obj.name;\n result.stack = obj.stack;\n result.cause = obj.cause;\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n if (typeof obj === \"object\" && obj !== null) {\n const result = {};\n cloneDeepHelper(obj, result);\n return result as Resolved<T>;\n }\n\n return obj as Resolved<T>;\n}\n\nfunction cloneDeepHelper(obj: any, clonedObj: any): void {\n const keys = Object.keys(obj);\n\n for (const key of keys) {\n const descriptor = Object.getOwnPropertyDescriptor(obj, key);\n\n if (descriptor?.writable || descriptor?.set) {\n clonedObj[key] = deepClone(obj[key]);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8JA,SAAgB,UAAa,KAAqB;AAChD,KAAI,YAAY,IAAI,CAClB,QAAO;AAGT,KAAI,MAAM,QAAQ,IAAI,CACpB,QAAO,IAAI,KAAI,SAAQ,UAAU,KAAK,CAAC;AAGzC,KAAI,eAAe,KACjB,QAAO,IAAI,KAAK,IAAI,SAAS,CAAC;AAGhC,KAAI,eAAe,OACjB,QAAO,IAAI,OAAO,IAAI,QAAQ,IAAI,MAAM;AAG1C,KAAI,eAAe,KAAK;EACtB,MAAM,yBAAS,IAAI,KAAK;AACxB,OAAK,MAAM,CAAC,KAAK,UAAU,IAAI,SAAS,CACtC,QAAO,IAAI,KAAK,UAAU,MAAM,CAAC;AAEnC,SAAO;;AAGT,KAAI,eAAe,KAAK;EACtB,MAAM,yBAAS,IAAI,KAAK;AACxB,OAAK,MAAM,SAAS,IAAI,QAAQ,CAC9B,QAAO,IAAI,UAAU,MAAM,CAAC;AAE9B,SAAO;;AAGT,KAAI,aAAa,IAAI,EAAE;EAErB,MAAM,SAAS,KAAK,OAAO,eAAe,IAAI,EAAC,YAAa,IAAI,OAAO;AAEvE,OAAK,MAAM,CAAC,GAAG,YAAY,IAAI,SAAS,CACtC,QAAO,KAAK,UAAU,QAAQ;AAEhC,SAAO;;AAGT,KACE,eAAe,eACd,OAAO,sBAAsB,eAC5B,eAAe,kBAEjB,QAAO,CAAC,GAAI,IAAY;AAG1B,KAAI,eAAe,UAAU;EAC3B,MAAM,SAAS,IAAI,SAAS,CAAC,GAAI,IAAI,OAAe,CAAQ;AAC5D,kBAAgB,KAAK,OAAO;AAC5B,SAAO;;AAIT,KAAI,OAAO,SAAS,eAAe,eAAe,MAAM;EACtD,MAAM,SAAS,IAAI,KAAK,CAAC,IAAI,EAAE,IAAI,MAAM,EAAE,MAAM,IAAI,MAAM,CAAC;AAC5D,kBAAgB,KAAK,OAAO;AAC5B,SAAO;;AAGT,KAAI,eAAe,MAAM;EACvB,MAAM,SAAS,IAAI,KAAK,CAAC,IAAI,EAAE,EAAE,MAAM,IAAI,MAAM,CAAC;AAClD,kBAAgB,KAAK,OAAO;AAC5B,SAAO;;AAGT,KAAI,eAAe,OAAO;EACxB,MAAM,SAAS,IAAK,IAAI,aAAiC;AACzD,SAAO,UAAU,IAAI;AACrB,SAAO,OAAO,IAAI;AAClB,SAAO,QAAQ,IAAI;AACnB,SAAO,QAAQ,IAAI;AACnB,kBAAgB,KAAK,OAAO;AAC5B,SAAO;;AAGT,KAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM;EAC3C,MAAM,SAAS,EAAE;AACjB,kBAAgB,KAAK,OAAO;AAC5B,SAAO;;AAGT,QAAO;;AAGT,SAAS,gBAAgB,KAAU,WAAsB;CACvD,MAAM,OAAO,OAAO,KAAK,IAAI;AAE7B,MAAK,MAAM,OAAO,MAAM;EACtB,MAAM,aAAa,OAAO,yBAAyB,KAAK,IAAI;AAE5D,MAAI,YAAY,YAAY,YAAY,IACtC,WAAU,OAAO,UAAU,IAAI,KAAK"}
@@ -1,11 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
2
  let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
4
3
  let _stryke_type_checks_is_mergeable_object = require("@stryke/type-checks/is-mergeable-object");
5
4
  let _stryke_type_checks_property_exists = require("@stryke/type-checks/property-exists");
6
5
 
7
6
  //#region src/deep-merge.ts
8
- var deep_merge_exports = /* @__PURE__ */ require_runtime.__exportAll({ deepMerge: () => deepMerge });
9
7
  const emptyTarget = (val) => {
10
8
  return Array.isArray(val) ? [] : {};
11
9
  };
@@ -60,10 +58,4 @@ deepMerge.all = function deepMergeAll(array, options) {
60
58
  };
61
59
 
62
60
  //#endregion
63
- exports.deepMerge = deepMerge;
64
- Object.defineProperty(exports, 'deep_merge_exports', {
65
- enumerable: true,
66
- get: function () {
67
- return deep_merge_exports;
68
- }
69
- });
61
+ exports.deepMerge = deepMerge;
@@ -1,10 +1,8 @@
1
- import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
2
1
  import { isFunction } from "@stryke/type-checks/is-function";
3
2
  import { isMergeableObject } from "@stryke/type-checks/is-mergeable-object";
4
3
  import { propertyUnsafe } from "@stryke/type-checks/property-exists";
5
4
 
6
5
  //#region src/deep-merge.ts
7
- var deep_merge_exports = /* @__PURE__ */ __exportAll({ deepMerge: () => deepMerge });
8
6
  const emptyTarget = (val) => {
9
7
  return Array.isArray(val) ? [] : {};
10
8
  };
@@ -59,5 +57,5 @@ deepMerge.all = function deepMergeAll(array, options) {
59
57
  };
60
58
 
61
59
  //#endregion
62
- export { deepMerge, deep_merge_exports };
60
+ export { deepMerge };
63
61
  //# sourceMappingURL=deep-merge.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"deep-merge.mjs","names":[],"sources":["../src/deep-merge.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 { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isMergeableObject } from \"@stryke/type-checks/is-mergeable-object\";\nimport { propertyUnsafe } from \"@stryke/type-checks/property-exists\";\n\nconst emptyTarget = (val: any) => {\n return Array.isArray(val) ? [] : {};\n};\n\nconst cloneUnlessOtherwiseSpecified = (\n value: any,\n options: {\n clone?: boolean;\n isMergeableObject: (value: any) => boolean;\n }\n) => {\n return options.clone !== false && options.isMergeableObject(value)\n ? deepMerge(emptyTarget(value), value, options)\n : value;\n};\n\nconst defaultArrayMerge = (target: any[], source: any[], options?: any) => {\n return [...target, ...source].map(element => {\n return cloneUnlessOtherwiseSpecified(element, options);\n });\n};\n\nconst getMergeFunction = (\n key: string,\n options: {\n customMerge?: (key: string) => any;\n }\n) => {\n if (!options.customMerge) {\n return deepMerge;\n }\n const customMerge = options.customMerge(key);\n\n return isFunction(customMerge) ? customMerge : deepMerge;\n};\n\nconst getKeys = (target: Record<string, any>) => {\n return [\n ...Object.keys(target),\n ...((Object.getOwnPropertySymbols\n ? Object.getOwnPropertySymbols(target).filter(symbol => {\n return Object.propertyIsEnumerable.call(target, symbol);\n })\n : []) as unknown as string[])\n ];\n};\n\nconst mergeObject = (\n target: Record<string, any>,\n source: Record<string, any>,\n options: {\n clone?: boolean;\n customMerge?: (key: string) => any;\n isMergeableObject: (value: any) => boolean;\n cloneUnlessOtherwiseSpecified?: (\n value: any,\n options: {\n clone: boolean;\n isMergeableObject: (value: any) => boolean;\n }\n ) => any;\n }\n) => {\n const destination: Record<string, any> = {};\n if (options.isMergeableObject(target)) {\n for (const key of getKeys(target)) {\n destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);\n }\n }\n for (const key of getKeys(source)) {\n destination[key] =\n propertyUnsafe(target, key) && options.isMergeableObject(source[key])\n ? getMergeFunction(key, options)(target[key], source[key], options)\n : cloneUnlessOtherwiseSpecified(source[key], options);\n }\n return destination;\n};\n\nexport interface DeepMergeOptions {\n clone?: boolean;\n customMerge?: (key: string) => any;\n isMergeableObject: (value: any) => boolean;\n cloneUnlessOtherwiseSpecified: (\n value: any,\n options: {\n clone?: boolean;\n isMergeableObject: (value: any) => boolean;\n }\n ) => any;\n arrayMerge: (target: any[], source: any[], options: any) => any;\n}\n\n/**\n * Deep merge two objects\n *\n * @param target - The target object\n * @param source - The source object\n * @param options - The options object\n * @returns The merged object\n */\nexport function deepMerge<X = any | any[], Y = any | any[], Z = X & Y>(\n target: X,\n source: Y,\n options?: Partial<DeepMergeOptions>\n): Z {\n if (!target || !source) {\n return (target || source) as Z;\n }\n\n const opts = (options ?? {}) as DeepMergeOptions;\n opts.arrayMerge ??= defaultArrayMerge;\n opts.isMergeableObject ??= isMergeableObject;\n // cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()\n // implementations can use it. The caller may not replace it.\n opts.cloneUnlessOtherwiseSpecified ??= cloneUnlessOtherwiseSpecified;\n\n const sourceIsArray = Array.isArray(source);\n const targetIsArray = Array.isArray(target);\n const sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;\n\n if (!sourceAndTargetTypesMatch) {\n return cloneUnlessOtherwiseSpecified(source, opts);\n }\n if (sourceIsArray) {\n return opts.arrayMerge(target as any[], source, opts);\n }\n return mergeObject(target, source, opts) as Z;\n}\n\ndeepMerge.all = function deepMergeAll(array: any[], options?: any) {\n if (!Array.isArray(array)) {\n throw new TypeError(\"first argument should be an array\");\n }\n\n return array.reduce((prev, next) => {\n return deepMerge(prev, next, options);\n }, {});\n};\n"],"mappings":";;;;;;;AAsBA,MAAM,eAAe,QAAa;AAChC,QAAO,MAAM,QAAQ,IAAI,GAAG,EAAE,GAAG,EAAE;;AAGrC,MAAM,iCACJ,OACA,YAIG;AACH,QAAO,QAAQ,UAAU,SAAS,QAAQ,kBAAkB,MAAM,GAC9D,UAAU,YAAY,MAAM,EAAE,OAAO,QAAQ,GAC7C;;AAGN,MAAM,qBAAqB,QAAe,QAAe,YAAkB;AACzE,QAAO,CAAC,GAAG,QAAQ,GAAG,OAAO,CAAC,KAAI,YAAW;AAC3C,SAAO,8BAA8B,SAAS,QAAQ;GACtD;;AAGJ,MAAM,oBACJ,KACA,YAGG;AACH,KAAI,CAAC,QAAQ,YACX,QAAO;CAET,MAAM,cAAc,QAAQ,YAAY,IAAI;AAE5C,QAAO,WAAW,YAAY,GAAG,cAAc;;AAGjD,MAAM,WAAW,WAAgC;AAC/C,QAAO,CACL,GAAG,OAAO,KAAK,OAAO,EACtB,GAAK,OAAO,wBACR,OAAO,sBAAsB,OAAO,CAAC,QAAO,WAAU;AACpD,SAAO,OAAO,qBAAqB,KAAK,QAAQ,OAAO;GACvD,GACF,EAAE,CACP;;AAGH,MAAM,eACJ,QACA,QACA,YAYG;CACH,MAAM,cAAmC,EAAE;AAC3C,KAAI,QAAQ,kBAAkB,OAAO,CACnC,MAAK,MAAM,OAAO,QAAQ,OAAO,CAC/B,aAAY,OAAO,8BAA8B,OAAO,MAAM,QAAQ;AAG1E,MAAK,MAAM,OAAO,QAAQ,OAAO,CAC/B,aAAY,OACV,eAAe,QAAQ,IAAI,IAAI,QAAQ,kBAAkB,OAAO,KAAK,GACjE,iBAAiB,KAAK,QAAQ,CAAC,OAAO,MAAM,OAAO,MAAM,QAAQ,GACjE,8BAA8B,OAAO,MAAM,QAAQ;AAE3D,QAAO;;;;;;;;;;AAyBT,SAAgB,UACd,QACA,QACA,SACG;AACH,KAAI,CAAC,UAAU,CAAC,OACd,QAAQ,UAAU;CAGpB,MAAM,OAAQ,WAAW,EAAE;AAC3B,MAAK,eAAe;AACpB,MAAK,sBAAsB;AAG3B,MAAK,kCAAkC;CAEvC,MAAM,gBAAgB,MAAM,QAAQ,OAAO;AAI3C,KAAI,EAF8B,kBADZ,MAAM,QAAQ,OAC6B,EAG/D,QAAO,8BAA8B,QAAQ,KAAK;AAEpD,KAAI,cACF,QAAO,KAAK,WAAW,QAAiB,QAAQ,KAAK;AAEvD,QAAO,YAAY,QAAQ,QAAQ,KAAK;;AAG1C,UAAU,MAAM,SAAS,aAAa,OAAc,SAAe;AACjE,KAAI,CAAC,MAAM,QAAQ,MAAM,CACvB,OAAM,IAAI,UAAU,oCAAoC;AAG1D,QAAO,MAAM,QAAQ,MAAM,SAAS;AAClC,SAAO,UAAU,MAAM,MAAM,QAAQ;IACpC,EAAE,CAAC"}
1
+ {"version":3,"file":"deep-merge.mjs","names":[],"sources":["../src/deep-merge.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 { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isMergeableObject } from \"@stryke/type-checks/is-mergeable-object\";\nimport { propertyUnsafe } from \"@stryke/type-checks/property-exists\";\n\nconst emptyTarget = (val: any) => {\n return Array.isArray(val) ? [] : {};\n};\n\nconst cloneUnlessOtherwiseSpecified = (\n value: any,\n options: {\n clone?: boolean;\n isMergeableObject: (value: any) => boolean;\n }\n) => {\n return options.clone !== false && options.isMergeableObject(value)\n ? deepMerge(emptyTarget(value), value, options)\n : value;\n};\n\nconst defaultArrayMerge = (target: any[], source: any[], options?: any) => {\n return [...target, ...source].map(element => {\n return cloneUnlessOtherwiseSpecified(element, options);\n });\n};\n\nconst getMergeFunction = (\n key: string,\n options: {\n customMerge?: (key: string) => any;\n }\n) => {\n if (!options.customMerge) {\n return deepMerge;\n }\n const customMerge = options.customMerge(key);\n\n return isFunction(customMerge) ? customMerge : deepMerge;\n};\n\nconst getKeys = (target: Record<string, any>) => {\n return [\n ...Object.keys(target),\n ...((Object.getOwnPropertySymbols\n ? Object.getOwnPropertySymbols(target).filter(symbol => {\n return Object.propertyIsEnumerable.call(target, symbol);\n })\n : []) as unknown as string[])\n ];\n};\n\nconst mergeObject = (\n target: Record<string, any>,\n source: Record<string, any>,\n options: {\n clone?: boolean;\n customMerge?: (key: string) => any;\n isMergeableObject: (value: any) => boolean;\n cloneUnlessOtherwiseSpecified?: (\n value: any,\n options: {\n clone: boolean;\n isMergeableObject: (value: any) => boolean;\n }\n ) => any;\n }\n) => {\n const destination: Record<string, any> = {};\n if (options.isMergeableObject(target)) {\n for (const key of getKeys(target)) {\n destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);\n }\n }\n for (const key of getKeys(source)) {\n destination[key] =\n propertyUnsafe(target, key) && options.isMergeableObject(source[key])\n ? getMergeFunction(key, options)(target[key], source[key], options)\n : cloneUnlessOtherwiseSpecified(source[key], options);\n }\n return destination;\n};\n\nexport interface DeepMergeOptions {\n clone?: boolean;\n customMerge?: (key: string) => any;\n isMergeableObject: (value: any) => boolean;\n cloneUnlessOtherwiseSpecified: (\n value: any,\n options: {\n clone?: boolean;\n isMergeableObject: (value: any) => boolean;\n }\n ) => any;\n arrayMerge: (target: any[], source: any[], options: any) => any;\n}\n\n/**\n * Deep merge two objects\n *\n * @param target - The target object\n * @param source - The source object\n * @param options - The options object\n * @returns The merged object\n */\nexport function deepMerge<X = any | any[], Y = any | any[], Z = X & Y>(\n target: X,\n source: Y,\n options?: Partial<DeepMergeOptions>\n): Z {\n if (!target || !source) {\n return (target || source) as Z;\n }\n\n const opts = (options ?? {}) as DeepMergeOptions;\n opts.arrayMerge ??= defaultArrayMerge;\n opts.isMergeableObject ??= isMergeableObject;\n // cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()\n // implementations can use it. The caller may not replace it.\n opts.cloneUnlessOtherwiseSpecified ??= cloneUnlessOtherwiseSpecified;\n\n const sourceIsArray = Array.isArray(source);\n const targetIsArray = Array.isArray(target);\n const sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;\n\n if (!sourceAndTargetTypesMatch) {\n return cloneUnlessOtherwiseSpecified(source, opts);\n }\n if (sourceIsArray) {\n return opts.arrayMerge(target as any[], source, opts);\n }\n return mergeObject(target, source, opts) as Z;\n}\n\ndeepMerge.all = function deepMergeAll(array: any[], options?: any) {\n if (!Array.isArray(array)) {\n throw new TypeError(\"first argument should be an array\");\n }\n\n return array.reduce((prev, next) => {\n return deepMerge(prev, next, options);\n }, {});\n};\n"],"mappings":";;;;;AAsBA,MAAM,eAAe,QAAa;AAChC,QAAO,MAAM,QAAQ,IAAI,GAAG,EAAE,GAAG,EAAE;;AAGrC,MAAM,iCACJ,OACA,YAIG;AACH,QAAO,QAAQ,UAAU,SAAS,QAAQ,kBAAkB,MAAM,GAC9D,UAAU,YAAY,MAAM,EAAE,OAAO,QAAQ,GAC7C;;AAGN,MAAM,qBAAqB,QAAe,QAAe,YAAkB;AACzE,QAAO,CAAC,GAAG,QAAQ,GAAG,OAAO,CAAC,KAAI,YAAW;AAC3C,SAAO,8BAA8B,SAAS,QAAQ;GACtD;;AAGJ,MAAM,oBACJ,KACA,YAGG;AACH,KAAI,CAAC,QAAQ,YACX,QAAO;CAET,MAAM,cAAc,QAAQ,YAAY,IAAI;AAE5C,QAAO,WAAW,YAAY,GAAG,cAAc;;AAGjD,MAAM,WAAW,WAAgC;AAC/C,QAAO,CACL,GAAG,OAAO,KAAK,OAAO,EACtB,GAAK,OAAO,wBACR,OAAO,sBAAsB,OAAO,CAAC,QAAO,WAAU;AACpD,SAAO,OAAO,qBAAqB,KAAK,QAAQ,OAAO;GACvD,GACF,EAAE,CACP;;AAGH,MAAM,eACJ,QACA,QACA,YAYG;CACH,MAAM,cAAmC,EAAE;AAC3C,KAAI,QAAQ,kBAAkB,OAAO,CACnC,MAAK,MAAM,OAAO,QAAQ,OAAO,CAC/B,aAAY,OAAO,8BAA8B,OAAO,MAAM,QAAQ;AAG1E,MAAK,MAAM,OAAO,QAAQ,OAAO,CAC/B,aAAY,OACV,eAAe,QAAQ,IAAI,IAAI,QAAQ,kBAAkB,OAAO,KAAK,GACjE,iBAAiB,KAAK,QAAQ,CAAC,OAAO,MAAM,OAAO,MAAM,QAAQ,GACjE,8BAA8B,OAAO,MAAM,QAAQ;AAE3D,QAAO;;;;;;;;;;AAyBT,SAAgB,UACd,QACA,QACA,SACG;AACH,KAAI,CAAC,UAAU,CAAC,OACd,QAAQ,UAAU;CAGpB,MAAM,OAAQ,WAAW,EAAE;AAC3B,MAAK,eAAe;AACpB,MAAK,sBAAsB;AAG3B,MAAK,kCAAkC;CAEvC,MAAM,gBAAgB,MAAM,QAAQ,OAAO;AAI3C,KAAI,EAF8B,kBADZ,MAAM,QAAQ,OAC6B,EAG/D,QAAO,8BAA8B,QAAQ,KAAK;AAEpD,KAAI,cACF,QAAO,KAAK,WAAW,QAAiB,QAAQ,KAAK;AAEvD,QAAO,YAAY,QAAQ,QAAQ,KAAK;;AAG1C,UAAU,MAAM,SAAS,aAAa,OAAc,SAAe;AACjE,KAAI,CAAC,MAAM,QAAQ,MAAM,CACvB,OAAM,IAAI,UAAU,oCAAoC;AAG1D,QAAO,MAAM,QAAQ,MAAM,SAAS;AAClC,SAAO,UAAU,MAAM,MAAM,QAAQ;IACpC,EAAE,CAAC"}
@@ -1,16 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
2
  let _stryke_type_checks_is_empty = require("@stryke/type-checks/is-empty");
4
3
 
5
4
  //#region src/filter-empty.ts
6
- var filter_empty_exports = /* @__PURE__ */ require_runtime.__exportAll({ filterEmpty: () => filterEmpty });
7
5
  const filterEmpty = (values = []) => values.filter((value) => !(0, _stryke_type_checks_is_empty.isEmpty)(value));
8
6
 
9
7
  //#endregion
10
- exports.filterEmpty = filterEmpty;
11
- Object.defineProperty(exports, 'filter_empty_exports', {
12
- enumerable: true,
13
- get: function () {
14
- return filter_empty_exports;
15
- }
16
- });
8
+ exports.filterEmpty = filterEmpty;
@@ -1,10 +1,8 @@
1
- import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
2
1
  import { isEmpty } from "@stryke/type-checks/is-empty";
3
2
 
4
3
  //#region src/filter-empty.ts
5
- var filter_empty_exports = /* @__PURE__ */ __exportAll({ filterEmpty: () => filterEmpty });
6
4
  const filterEmpty = (values = []) => values.filter((value) => !isEmpty(value));
7
5
 
8
6
  //#endregion
9
- export { filterEmpty, filter_empty_exports };
7
+ export { filterEmpty };
10
8
  //# sourceMappingURL=filter-empty.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"filter-empty.mjs","names":[],"sources":["../src/filter-empty.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 { isEmpty } from \"@stryke/type-checks/is-empty\";\n\nexport const filterEmpty = <T>(values: (T | null | undefined)[] = []): T[] =>\n values.filter(value => !isEmpty(value)) as T[];\n"],"mappings":";;;;;AAoBA,MAAa,eAAkB,SAAmC,EAAE,KAClE,OAAO,QAAO,UAAS,CAAC,QAAQ,MAAM,CAAC"}
1
+ {"version":3,"file":"filter-empty.mjs","names":[],"sources":["../src/filter-empty.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 { isEmpty } from \"@stryke/type-checks/is-empty\";\n\nexport const filterEmpty = <T>(values: (T | null | undefined)[] = []): T[] =>\n values.filter(value => !isEmpty(value)) as T[];\n"],"mappings":";;;AAoBA,MAAa,eAAkB,SAAmC,EAAE,KAClE,OAAO,QAAO,UAAS,CAAC,QAAQ,MAAM,CAAC"}
@@ -1,9 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
2
  let _stryke_type_checks = require("@stryke/type-checks");
4
3
 
5
4
  //#region src/flatten-object.ts
6
- var flatten_object_exports = /* @__PURE__ */ require_runtime.__exportAll({ flattenObject: () => flattenObject });
7
5
  /**
8
6
  * Flattens a nested object into a single level object with dot-separated keys.
9
7
  *
@@ -48,10 +46,4 @@ function flattenObjectImpl(object, prefix = "") {
48
46
  }
49
47
 
50
48
  //#endregion
51
- exports.flattenObject = flattenObject;
52
- Object.defineProperty(exports, 'flatten_object_exports', {
53
- enumerable: true,
54
- get: function () {
55
- return flatten_object_exports;
56
- }
57
- });
49
+ exports.flattenObject = flattenObject;
@@ -1,8 +1,6 @@
1
- import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
2
1
  import { isPlainObject } from "@stryke/type-checks";
3
2
 
4
3
  //#region src/flatten-object.ts
5
- var flatten_object_exports = /* @__PURE__ */ __exportAll({ flattenObject: () => flattenObject });
6
4
  /**
7
5
  * Flattens a nested object into a single level object with dot-separated keys.
8
6
  *
@@ -47,5 +45,5 @@ function flattenObjectImpl(object, prefix = "") {
47
45
  }
48
46
 
49
47
  //#endregion
50
- export { flattenObject, flatten_object_exports };
48
+ export { flattenObject };
51
49
  //# sourceMappingURL=flatten-object.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"flatten-object.mjs","names":[],"sources":["../src/flatten-object.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 { isPlainObject } from \"@stryke/type-checks\";\nimport type { DeepKey, DeepValue } from \"@stryke/types\";\n\n/**\n * Flattens a nested object into a single level object with dot-separated keys.\n *\n * @example\n * ```typescript\n * const nestedObject = {\n * a: {\n * b: {\n * c: 1\n * }\n * },\n * d: [2, 3]\n * };\n *\n * const flattened = flattenObject(nestedObject);\n * console.log(flattened);\n * // Output:\n * // {\n * // 'a.b.c': 1,\n * // 'd.0': 2,\n * // 'd.1': 3\n * // }\n * ```\n *\n * @param object - The object to flatten.\n * @returns - The flattened object.\n */\nexport function flattenObject<\n TObject extends Record<string, any> = Record<string, any>,\n TDeepKeyObject extends {\n [TKey in DeepKey<TObject>]: DeepValue<TObject, TKey>;\n } = { [TKey in DeepKey<TObject>]: DeepValue<TObject, TKey> }\n>(object: TObject): TDeepKeyObject {\n return flattenObjectImpl<TObject, TDeepKeyObject>(object);\n}\n\nfunction flattenObjectImpl<\n TObject extends Record<string, any> = Record<string, any>,\n TDeepKeyObject extends {\n [TKey in DeepKey<TObject>]: DeepValue<TObject, TKey>;\n } = { [TKey in DeepKey<TObject>]: DeepValue<TObject, TKey> }\n>(object: TObject, prefix = \"\"): TDeepKeyObject {\n const result = {} as TDeepKeyObject;\n const keys = Object.keys(object);\n\n for (const key of keys) {\n const value = (object as any)[key];\n\n const prefixedKey = prefix ? `${prefix}.${key}` : key;\n\n if (isPlainObject(value) && Object.keys(value).length > 0) {\n Object.assign(\n result,\n flattenObjectImpl<typeof value>(value, prefixedKey)\n );\n } else if (Array.isArray(value)) {\n for (const [index, element] of value.entries()) {\n (result as any)[`${prefixedKey}.${index}` as DeepKey<TObject>] =\n element;\n }\n } else {\n (result as any)[prefixedKey as DeepKey<TObject>] = value;\n }\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,SAAgB,cAKd,QAAiC;AACjC,QAAO,kBAA2C,OAAO;;AAG3D,SAAS,kBAKP,QAAiB,SAAS,IAAoB;CAC9C,MAAM,SAAS,EAAE;CACjB,MAAM,OAAO,OAAO,KAAK,OAAO;AAEhC,MAAK,MAAM,OAAO,MAAM;EACtB,MAAM,QAAS,OAAe;EAE9B,MAAM,cAAc,SAAS,GAAG,OAAO,GAAG,QAAQ;AAElD,MAAI,cAAc,MAAM,IAAI,OAAO,KAAK,MAAM,CAAC,SAAS,EACtD,QAAO,OACL,QACA,kBAAgC,OAAO,YAAY,CACpD;WACQ,MAAM,QAAQ,MAAM,CAC7B,MAAK,MAAM,CAAC,OAAO,YAAY,MAAM,SAAS,CAC5C,CAAC,OAAe,GAAG,YAAY,GAAG,WAChC;MAGJ,CAAC,OAAe,eAAmC;;AAIvD,QAAO"}
1
+ {"version":3,"file":"flatten-object.mjs","names":[],"sources":["../src/flatten-object.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 { isPlainObject } from \"@stryke/type-checks\";\nimport type { DeepKey, DeepValue } from \"@stryke/types\";\n\n/**\n * Flattens a nested object into a single level object with dot-separated keys.\n *\n * @example\n * ```typescript\n * const nestedObject = {\n * a: {\n * b: {\n * c: 1\n * }\n * },\n * d: [2, 3]\n * };\n *\n * const flattened = flattenObject(nestedObject);\n * console.log(flattened);\n * // Output:\n * // {\n * // 'a.b.c': 1,\n * // 'd.0': 2,\n * // 'd.1': 3\n * // }\n * ```\n *\n * @param object - The object to flatten.\n * @returns - The flattened object.\n */\nexport function flattenObject<\n TObject extends Record<string, any> = Record<string, any>,\n TDeepKeyObject extends {\n [TKey in DeepKey<TObject>]: DeepValue<TObject, TKey>;\n } = { [TKey in DeepKey<TObject>]: DeepValue<TObject, TKey> }\n>(object: TObject): TDeepKeyObject {\n return flattenObjectImpl<TObject, TDeepKeyObject>(object);\n}\n\nfunction flattenObjectImpl<\n TObject extends Record<string, any> = Record<string, any>,\n TDeepKeyObject extends {\n [TKey in DeepKey<TObject>]: DeepValue<TObject, TKey>;\n } = { [TKey in DeepKey<TObject>]: DeepValue<TObject, TKey> }\n>(object: TObject, prefix = \"\"): TDeepKeyObject {\n const result = {} as TDeepKeyObject;\n const keys = Object.keys(object);\n\n for (const key of keys) {\n const value = (object as any)[key];\n\n const prefixedKey = prefix ? `${prefix}.${key}` : key;\n\n if (isPlainObject(value) && Object.keys(value).length > 0) {\n Object.assign(\n result,\n flattenObjectImpl<typeof value>(value, prefixedKey)\n );\n } else if (Array.isArray(value)) {\n for (const [index, element] of value.entries()) {\n (result as any)[`${prefixedKey}.${index}` as DeepKey<TObject>] =\n element;\n }\n } else {\n (result as any)[prefixedKey as DeepKey<TObject>] = value;\n }\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,SAAgB,cAKd,QAAiC;AACjC,QAAO,kBAA2C,OAAO;;AAG3D,SAAS,kBAKP,QAAiB,SAAS,IAAoB;CAC9C,MAAM,SAAS,EAAE;CACjB,MAAM,OAAO,OAAO,KAAK,OAAO;AAEhC,MAAK,MAAM,OAAO,MAAM;EACtB,MAAM,QAAS,OAAe;EAE9B,MAAM,cAAc,SAAS,GAAG,OAAO,GAAG,QAAQ;AAElD,MAAI,cAAc,MAAM,IAAI,OAAO,KAAK,MAAM,CAAC,SAAS,EACtD,QAAO,OACL,QACA,kBAAgC,OAAO,YAAY,CACpD;WACQ,MAAM,QAAQ,MAAM,CAC7B,MAAK,MAAM,CAAC,OAAO,YAAY,MAAM,SAAS,CAC5C,CAAC,OAAe,GAAG,YAAY,GAAG,WAChC;MAGJ,CAAC,OAAe,eAAmC;;AAIvD,QAAO"}
@@ -1,11 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
2
  const require_to_path = require('./to-path.cjs');
4
3
  let _stryke_type_checks = require("@stryke/type-checks");
5
4
  let _stryke_convert = require("@stryke/convert");
6
5
 
7
6
  //#region src/get-field.ts
8
- var get_field_exports = /* @__PURE__ */ require_runtime.__exportAll({ getField: () => getField });
9
7
  /**
10
8
  * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
11
9
  *
@@ -53,10 +51,4 @@ function getWithPath(object, path, defaultValue) {
53
51
  }
54
52
 
55
53
  //#endregion
56
- exports.getField = getField;
57
- Object.defineProperty(exports, 'get_field_exports', {
58
- enumerable: true,
59
- get: function () {
60
- return get_field_exports;
61
- }
62
- });
54
+ exports.getField = getField;
@@ -1,10 +1,8 @@
1
- import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
2
1
  import { toPath } from "./to-path.mjs";
3
2
  import { isDeepKey, isNumber } from "@stryke/type-checks";
4
3
  import { toStringKey } from "@stryke/convert";
5
4
 
6
5
  //#region src/get-field.ts
7
- var get_field_exports = /* @__PURE__ */ __exportAll({ getField: () => getField });
8
6
  /**
9
7
  * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
10
8
  *
@@ -52,5 +50,5 @@ function getWithPath(object, path, defaultValue) {
52
50
  }
53
51
 
54
52
  //#endregion
55
- export { getField, get_field_exports };
53
+ export { getField };
56
54
  //# sourceMappingURL=get-field.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-field.mjs","names":[],"sources":["../src/get-field.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 { toStringKey } from \"@stryke/convert\";\nimport { isDeepKey, isNumber } from \"@stryke/type-checks\";\nimport { toPath } from \"./to-path\";\n\n/**\n * See the definition of `@types/lodash`.\n */\ntype GetIndexedField<T, K> = K extends keyof T\n ? T[K]\n : K extends `${number}`\n ? \"length\" extends keyof T\n ? number extends T[\"length\"]\n ? number extends keyof T\n ? T[number]\n : undefined\n : undefined\n : undefined\n : undefined;\n\ntype FieldWithPossiblyUndefined<T, Key> =\n | GetField<Exclude<T, undefined>, Key>\n | Extract<T, undefined>;\n\ntype IndexedFieldWithPossiblyUndefined<T, Key> =\n | GetIndexedField<Exclude<T, undefined>, Key>\n | Extract<T, undefined>;\n\nexport type GetField<T, P> = P extends `${infer Left}.${infer Right}`\n ? Left extends keyof Exclude<T, undefined>\n ?\n | FieldWithPossiblyUndefined<Exclude<T, undefined>[Left], Right>\n | Extract<T, undefined>\n : Left extends `${infer FieldKey}[${infer IndexKey}]`\n ? FieldKey extends keyof T\n ? FieldWithPossiblyUndefined<\n IndexedFieldWithPossiblyUndefined<T[FieldKey], IndexKey>,\n Right\n >\n : undefined\n : undefined\n : P extends keyof T\n ? T[P]\n : P extends `${infer FieldKey}[${infer IndexKey}]`\n ? FieldKey extends keyof T\n ? IndexedFieldWithPossiblyUndefined<T[FieldKey], IndexKey>\n : undefined\n : IndexedFieldWithPossiblyUndefined<T, P>;\n\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K - The type of the key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value.\n */\nexport function getField<T extends object, K extends keyof T>(\n object: T,\n path: K | readonly [K]\n): T[K];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K - The type of the key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value or undefined.\n */\nexport function getField<T extends object, K extends keyof T>(\n object: T | null | undefined,\n path: K | readonly [K]\n): T[K] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K - The type of the key in the object.\n * @typeParam D - The type of the default value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value or default value.\n */\nexport function getField<T extends object, K extends keyof T, D>(\n object: T | null | undefined,\n path: K | readonly [K],\n defaultValue: D\n): Exclude<T[K], undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1]\n>(object: T, path: readonly [K1, K2]): T[K1][K2];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value or undefined.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1]\n>(object: T | null | undefined, path: readonly [K1, K2]): T[K1][K2] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam D - The type of the default value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value or default value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n D\n>(\n object: T | null | undefined,\n path: readonly [K1, K2],\n defaultValue: D\n): Exclude<T[K1][K2], undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam K3 - The type of the third key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2]\n>(object: T, path: readonly [K1, K2, K3]): T[K1][K2][K3];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam K3 - The type of the third key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value or undefined.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2]\n>(\n object: T | null | undefined,\n path: readonly [K1, K2, K3]\n): T[K1][K2][K3] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam K3 - The type of the third key in the object.\n * @typeParam D - The type of the default value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value or default value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2],\n D\n>(\n object: T | null | undefined,\n path: readonly [K1, K2, K3],\n defaultValue: D\n): Exclude<T[K1][K2][K3], undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam K3 - The type of the third key in the object.\n * @typeParam K4 - The type of the fourth key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2],\n K4 extends keyof T[K1][K2][K3]\n>(object: T, path: readonly [K1, K2, K3, K4]): T[K1][K2][K3][K4];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam K3 - The type of the third key in the object.\n * @typeParam K4 - The type of the fourth key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value or undefined.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2],\n K4 extends keyof T[K1][K2][K3]\n>(\n object: T | null | undefined,\n path: readonly [K1, K2, K3, K4]\n): T[K1][K2][K3][K4] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam K3 - The type of the third key in the object.\n * @typeParam K4 - The type of the fourth key in the object.\n * @typeParam D - The type of the default value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value or default value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2],\n K4 extends keyof T[K1][K2][K3],\n D\n>(\n object: T | null | undefined,\n path: readonly [K1, K2, K3, K4],\n defaultValue: D\n): Exclude<T[K1][K2][K3][K4], undefined> | D;\n/**\n * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value.\n */\nexport function getField<T>(object: Record<number, T>, path: number): T;\n/**\n * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value or undefined.\n */\nexport function getField<T>(\n object: Record<number, T> | null | undefined,\n path: number\n): T | undefined;\n/**\n * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the value.\n * @typeParam D - The type of the default value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value or default value.\n */\nexport function getField<T, D>(\n object: Record<number, T> | null | undefined,\n path: number,\n defaultValue: D\n): T | D;\n/**\n * Retrieves the value at a given path from a null or undefined object, returning the default value.\n *\n * @typeParam D - The type of the default value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The default value.\n */\nexport function getField<D>(\n object: null | undefined,\n path: PropertyKey,\n defaultValue: D\n): D;\n\n/**\n * Retrieves the value at a given path from a null or undefined object, returning undefined.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n */\nexport function getField(\n object: null | undefined,\n path: PropertyKey\n): undefined;\n\n/**\n * Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam P - The type of the path.\n *\n * @param data - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value, or any if path is a general string.\n */\nexport function getField<T, P extends string>(\n data: T,\n path: P\n): string extends P ? any : GetField<T, P>;\n/**\n * Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam P - The type of the path.\n * @typeParam D - The type of the default value.\n *\n * @param data - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value or default value.\n */\nexport function getField<T, P extends string, D = GetField<T, P>>(\n data: T,\n path: P,\n defaultValue: D\n): Exclude<GetField<T, P>, null | undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value.\n */\nexport function getField(\n object: unknown,\n path: PropertyKey | readonly PropertyKey[],\n defaultValue?: unknown\n): any;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value.\n */\nexport function getField(\n object: any,\n path: PropertyKey | readonly PropertyKey[],\n defaultValue?: any\n): any {\n if (object === null) {\n return defaultValue;\n }\n\n switch (typeof path) {\n case \"string\": {\n const result = object[path];\n\n if (result === undefined) {\n if (isDeepKey(path)) {\n return getField(object, toPath(path), defaultValue);\n }\n return defaultValue;\n }\n\n return result;\n }\n case \"number\":\n case \"symbol\": {\n if (isNumber(path)) {\n path = toStringKey(path);\n }\n\n const result = Array.isArray(path)\n ? undefined\n : object[path as PropertyKey];\n if (result === undefined) {\n return defaultValue;\n }\n\n return result;\n }\n case \"bigint\":\n case \"boolean\":\n case \"undefined\":\n case \"object\":\n case \"function\":\n default: {\n if (Array.isArray(path)) {\n return getWithPath(object, path, defaultValue);\n }\n\n path = Object.is(path?.valueOf(), -0) ? \"-0\" : String(path);\n\n const result = object[path];\n\n if (result === undefined) {\n return defaultValue;\n }\n\n return result;\n }\n }\n}\n\nfunction getWithPath(\n object: any,\n path: readonly PropertyKey[],\n defaultValue?: any\n): any {\n if (path.length === 0) {\n return defaultValue;\n }\n\n let current = object;\n\n for (const element of path) {\n if (current === null) {\n return defaultValue;\n }\n\n current = current[element];\n }\n\n if (current === undefined) {\n return defaultValue;\n }\n\n return current;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAkaA,SAAgB,SACd,QACA,MACA,cACK;AACL,KAAI,WAAW,KACb,QAAO;AAGT,SAAQ,OAAO,MAAf;EACE,KAAK,UAAU;GACb,MAAM,SAAS,OAAO;AAEtB,OAAI,WAAW,QAAW;AACxB,QAAI,UAAU,KAAK,CACjB,QAAO,SAAS,QAAQ,OAAO,KAAK,EAAE,aAAa;AAErD,WAAO;;AAGT,UAAO;;EAET,KAAK;EACL,KAAK,UAAU;AACb,OAAI,SAAS,KAAK,CAChB,QAAO,YAAY,KAAK;GAG1B,MAAM,SAAS,MAAM,QAAQ,KAAK,GAC9B,SACA,OAAO;AACX,OAAI,WAAW,OACb,QAAO;AAGT,UAAO;;EAOT,SAAS;AACP,OAAI,MAAM,QAAQ,KAAK,CACrB,QAAO,YAAY,QAAQ,MAAM,aAAa;AAGhD,UAAO,OAAO,GAAG,MAAM,SAAS,EAAE,GAAG,GAAG,OAAO,OAAO,KAAK;GAE3D,MAAM,SAAS,OAAO;AAEtB,OAAI,WAAW,OACb,QAAO;AAGT,UAAO;;;;AAKb,SAAS,YACP,QACA,MACA,cACK;AACL,KAAI,KAAK,WAAW,EAClB,QAAO;CAGT,IAAI,UAAU;AAEd,MAAK,MAAM,WAAW,MAAM;AAC1B,MAAI,YAAY,KACd,QAAO;AAGT,YAAU,QAAQ;;AAGpB,KAAI,YAAY,OACd,QAAO;AAGT,QAAO"}
1
+ {"version":3,"file":"get-field.mjs","names":[],"sources":["../src/get-field.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 { toStringKey } from \"@stryke/convert\";\nimport { isDeepKey, isNumber } from \"@stryke/type-checks\";\nimport { toPath } from \"./to-path\";\n\n/**\n * See the definition of `@types/lodash`.\n */\ntype GetIndexedField<T, K> = K extends keyof T\n ? T[K]\n : K extends `${number}`\n ? \"length\" extends keyof T\n ? number extends T[\"length\"]\n ? number extends keyof T\n ? T[number]\n : undefined\n : undefined\n : undefined\n : undefined;\n\ntype FieldWithPossiblyUndefined<T, Key> =\n | GetField<Exclude<T, undefined>, Key>\n | Extract<T, undefined>;\n\ntype IndexedFieldWithPossiblyUndefined<T, Key> =\n | GetIndexedField<Exclude<T, undefined>, Key>\n | Extract<T, undefined>;\n\nexport type GetField<T, P> = P extends `${infer Left}.${infer Right}`\n ? Left extends keyof Exclude<T, undefined>\n ?\n | FieldWithPossiblyUndefined<Exclude<T, undefined>[Left], Right>\n | Extract<T, undefined>\n : Left extends `${infer FieldKey}[${infer IndexKey}]`\n ? FieldKey extends keyof T\n ? FieldWithPossiblyUndefined<\n IndexedFieldWithPossiblyUndefined<T[FieldKey], IndexKey>,\n Right\n >\n : undefined\n : undefined\n : P extends keyof T\n ? T[P]\n : P extends `${infer FieldKey}[${infer IndexKey}]`\n ? FieldKey extends keyof T\n ? IndexedFieldWithPossiblyUndefined<T[FieldKey], IndexKey>\n : undefined\n : IndexedFieldWithPossiblyUndefined<T, P>;\n\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K - The type of the key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value.\n */\nexport function getField<T extends object, K extends keyof T>(\n object: T,\n path: K | readonly [K]\n): T[K];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K - The type of the key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value or undefined.\n */\nexport function getField<T extends object, K extends keyof T>(\n object: T | null | undefined,\n path: K | readonly [K]\n): T[K] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K - The type of the key in the object.\n * @typeParam D - The type of the default value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value or default value.\n */\nexport function getField<T extends object, K extends keyof T, D>(\n object: T | null | undefined,\n path: K | readonly [K],\n defaultValue: D\n): Exclude<T[K], undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1]\n>(object: T, path: readonly [K1, K2]): T[K1][K2];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value or undefined.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1]\n>(object: T | null | undefined, path: readonly [K1, K2]): T[K1][K2] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam D - The type of the default value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value or default value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n D\n>(\n object: T | null | undefined,\n path: readonly [K1, K2],\n defaultValue: D\n): Exclude<T[K1][K2], undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam K3 - The type of the third key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2]\n>(object: T, path: readonly [K1, K2, K3]): T[K1][K2][K3];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam K3 - The type of the third key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value or undefined.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2]\n>(\n object: T | null | undefined,\n path: readonly [K1, K2, K3]\n): T[K1][K2][K3] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam K3 - The type of the third key in the object.\n * @typeParam D - The type of the default value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value or default value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2],\n D\n>(\n object: T | null | undefined,\n path: readonly [K1, K2, K3],\n defaultValue: D\n): Exclude<T[K1][K2][K3], undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam K3 - The type of the third key in the object.\n * @typeParam K4 - The type of the fourth key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2],\n K4 extends keyof T[K1][K2][K3]\n>(object: T, path: readonly [K1, K2, K3, K4]): T[K1][K2][K3][K4];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam K3 - The type of the third key in the object.\n * @typeParam K4 - The type of the fourth key in the object.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value or undefined.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2],\n K4 extends keyof T[K1][K2][K3]\n>(\n object: T | null | undefined,\n path: readonly [K1, K2, K3, K4]\n): T[K1][K2][K3][K4] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam K1 - The type of the first key in the object.\n * @typeParam K2 - The type of the second key in the object.\n * @typeParam K3 - The type of the third key in the object.\n * @typeParam K4 - The type of the fourth key in the object.\n * @typeParam D - The type of the default value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value or default value.\n */\nexport function getField<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2],\n K4 extends keyof T[K1][K2][K3],\n D\n>(\n object: T | null | undefined,\n path: readonly [K1, K2, K3, K4],\n defaultValue: D\n): Exclude<T[K1][K2][K3][K4], undefined> | D;\n/**\n * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value.\n */\nexport function getField<T>(object: Record<number, T>, path: number): T;\n/**\n * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value or undefined.\n */\nexport function getField<T>(\n object: Record<number, T> | null | undefined,\n path: number\n): T | undefined;\n/**\n * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the value.\n * @typeParam D - The type of the default value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value or default value.\n */\nexport function getField<T, D>(\n object: Record<number, T> | null | undefined,\n path: number,\n defaultValue: D\n): T | D;\n/**\n * Retrieves the value at a given path from a null or undefined object, returning the default value.\n *\n * @typeParam D - The type of the default value.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The default value.\n */\nexport function getField<D>(\n object: null | undefined,\n path: PropertyKey,\n defaultValue: D\n): D;\n\n/**\n * Retrieves the value at a given path from a null or undefined object, returning undefined.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n */\nexport function getField(\n object: null | undefined,\n path: PropertyKey\n): undefined;\n\n/**\n * Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam P - The type of the path.\n *\n * @param data - The object to query.\n * @param path - The path of the property to get.\n * @returns The resolved value, or any if path is a general string.\n */\nexport function getField<T, P extends string>(\n data: T,\n path: P\n): string extends P ? any : GetField<T, P>;\n/**\n * Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @typeParam T - The type of the object.\n * @typeParam P - The type of the path.\n * @typeParam D - The type of the default value.\n *\n * @param data - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value or default value.\n */\nexport function getField<T, P extends string, D = GetField<T, P>>(\n data: T,\n path: P,\n defaultValue: D\n): Exclude<GetField<T, P>, null | undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value.\n */\nexport function getField(\n object: unknown,\n path: PropertyKey | readonly PropertyKey[],\n defaultValue?: unknown\n): any;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @param defaultValue - The value returned if the resolved value is undefined.\n * @returns The resolved value.\n */\nexport function getField(\n object: any,\n path: PropertyKey | readonly PropertyKey[],\n defaultValue?: any\n): any {\n if (object === null) {\n return defaultValue;\n }\n\n switch (typeof path) {\n case \"string\": {\n const result = object[path];\n\n if (result === undefined) {\n if (isDeepKey(path)) {\n return getField(object, toPath(path), defaultValue);\n }\n return defaultValue;\n }\n\n return result;\n }\n case \"number\":\n case \"symbol\": {\n if (isNumber(path)) {\n path = toStringKey(path);\n }\n\n const result = Array.isArray(path)\n ? undefined\n : object[path as PropertyKey];\n if (result === undefined) {\n return defaultValue;\n }\n\n return result;\n }\n case \"bigint\":\n case \"boolean\":\n case \"undefined\":\n case \"object\":\n case \"function\":\n default: {\n if (Array.isArray(path)) {\n return getWithPath(object, path, defaultValue);\n }\n\n path = Object.is(path?.valueOf(), -0) ? \"-0\" : String(path);\n\n const result = object[path];\n\n if (result === undefined) {\n return defaultValue;\n }\n\n return result;\n }\n }\n}\n\nfunction getWithPath(\n object: any,\n path: readonly PropertyKey[],\n defaultValue?: any\n): any {\n if (path.length === 0) {\n return defaultValue;\n }\n\n let current = object;\n\n for (const element of path) {\n if (current === null) {\n return defaultValue;\n }\n\n current = current[element];\n }\n\n if (current === undefined) {\n return defaultValue;\n }\n\n return current;\n}\n"],"mappings":";;;;;;;;;;;;;AAkaA,SAAgB,SACd,QACA,MACA,cACK;AACL,KAAI,WAAW,KACb,QAAO;AAGT,SAAQ,OAAO,MAAf;EACE,KAAK,UAAU;GACb,MAAM,SAAS,OAAO;AAEtB,OAAI,WAAW,QAAW;AACxB,QAAI,UAAU,KAAK,CACjB,QAAO,SAAS,QAAQ,OAAO,KAAK,EAAE,aAAa;AAErD,WAAO;;AAGT,UAAO;;EAET,KAAK;EACL,KAAK,UAAU;AACb,OAAI,SAAS,KAAK,CAChB,QAAO,YAAY,KAAK;GAG1B,MAAM,SAAS,MAAM,QAAQ,KAAK,GAC9B,SACA,OAAO;AACX,OAAI,WAAW,OACb,QAAO;AAGT,UAAO;;EAOT,SAAS;AACP,OAAI,MAAM,QAAQ,KAAK,CACrB,QAAO,YAAY,QAAQ,MAAM,aAAa;AAGhD,UAAO,OAAO,GAAG,MAAM,SAAS,EAAE,GAAG,GAAG,OAAO,OAAO,KAAK;GAE3D,MAAM,SAAS,OAAO;AAEtB,OAAI,WAAW,OACb,QAAO;AAGT,UAAO;;;;AAKb,SAAS,YACP,QACA,MACA,cACK;AACL,KAAI,KAAK,WAAW,EAClB,QAAO;CAGT,IAAI,UAAU;AAEd,MAAK,MAAM,WAAW,MAAM;AAC1B,MAAI,YAAY,KACd,QAAO;AAGT,YAAU,QAAQ;;AAGpB,KAAI,YAAY,OACd,QAAO;AAGT,QAAO"}
@@ -1,8 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
2
 
4
3
  //#region src/get-ordered-by.ts
5
- var get_ordered_by_exports = /* @__PURE__ */ require_runtime.__exportAll({ getOrderedBy: () => getOrderedBy });
6
4
  /**
7
5
  * Sorts an array of objects based on multiple properties and their corresponding order directions.
8
6
  *
@@ -54,10 +52,4 @@ function getOrderedBy(collection, keys, orders) {
54
52
  }
55
53
 
56
54
  //#endregion
57
- exports.getOrderedBy = getOrderedBy;
58
- Object.defineProperty(exports, 'get_ordered_by_exports', {
59
- enumerable: true,
60
- get: function () {
61
- return get_ordered_by_exports;
62
- }
63
- });
55
+ exports.getOrderedBy = getOrderedBy;
@@ -1,7 +1,4 @@
1
- import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
2
-
3
1
  //#region src/get-ordered-by.ts
4
- var get_ordered_by_exports = /* @__PURE__ */ __exportAll({ getOrderedBy: () => getOrderedBy });
5
2
  /**
6
3
  * Sorts an array of objects based on multiple properties and their corresponding order directions.
7
4
  *
@@ -53,5 +50,5 @@ function getOrderedBy(collection, keys, orders) {
53
50
  }
54
51
 
55
52
  //#endregion
56
- export { getOrderedBy, get_ordered_by_exports };
53
+ export { getOrderedBy };
57
54
  //# sourceMappingURL=get-ordered-by.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-ordered-by.mjs","names":[],"sources":["../src/get-ordered-by.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\ntype Order = \"asc\" | \"desc\";\n\n/**\n * Sorts an array of objects based on multiple properties and their corresponding order directions.\n *\n * @remarks\n * This function takes an array of objects, an array of keys to sort by, and an array of order directions.\n * It returns the sorted array, ordering by each key according to its corresponding direction\n * ('asc' for ascending or 'desc' for descending). If values for a key are equal,\n * it moves to the next key to determine the order.\n *\n * @example\n * ```typescript\n * // Sort an array of objects by 'user' in ascending order and 'age' in descending order.\n * const users = [\n * { user: 'fred', age: 48 },\n * { user: 'barney', age: 34 },\n * { user: 'fred', age: 40 },\n * { user: 'barney', age: 36 },\n * ];\n * const result = orderBy(users, ['user', 'age'], ['asc', 'desc']);\n * // result will be:\n * // [\n * // { user: 'barney', age: 36 },\n * // { user: 'barney', age: 34 },\n * // { user: 'fred', age: 48 },\n * // { user: 'fred', age: 40 },\n * // ]\n * ```\n *\n * @param collection - The array of objects to be sorted.\n * @param keys - An array of keys (properties) by which to sort.\n * @param orders - An array of order directions ('asc' for ascending or 'desc' for descending).\n * @returns The sorted array.\n */\nexport function getOrderedBy<T>(\n collection: T[],\n keys: (keyof T)[],\n orders: Order[]\n): T[] {\n const compareValues = (a: T[keyof T], b: T[keyof T], order: Order) => {\n if (a < b) {\n return order === \"asc\" ? -1 : 1;\n }\n if (a > b) {\n return order === \"asc\" ? 1 : -1;\n }\n return 0;\n };\n\n const effectiveOrders = keys.map(\n (_, index) => orders[index] ?? orders.at(-1)\n );\n\n return [...collection].sort((a, b) => {\n for (const [i, key] of keys.entries()) {\n const order = effectiveOrders[i];\n const result = compareValues(a[key], b[key], order!);\n if (result !== 0) {\n return result;\n }\n }\n return 0;\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDA,SAAgB,aACd,YACA,MACA,QACK;CACL,MAAM,iBAAiB,GAAe,GAAe,UAAiB;AACpE,MAAI,IAAI,EACN,QAAO,UAAU,QAAQ,KAAK;AAEhC,MAAI,IAAI,EACN,QAAO,UAAU,QAAQ,IAAI;AAE/B,SAAO;;CAGT,MAAM,kBAAkB,KAAK,KAC1B,GAAG,UAAU,OAAO,UAAU,OAAO,GAAG,GAAG,CAC7C;AAED,QAAO,CAAC,GAAG,WAAW,CAAC,MAAM,GAAG,MAAM;AACpC,OAAK,MAAM,CAAC,GAAG,QAAQ,KAAK,SAAS,EAAE;GACrC,MAAM,QAAQ,gBAAgB;GAC9B,MAAM,SAAS,cAAc,EAAE,MAAM,EAAE,MAAM,MAAO;AACpD,OAAI,WAAW,EACb,QAAO;;AAGX,SAAO;GACP"}
1
+ {"version":3,"file":"get-ordered-by.mjs","names":[],"sources":["../src/get-ordered-by.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\ntype Order = \"asc\" | \"desc\";\n\n/**\n * Sorts an array of objects based on multiple properties and their corresponding order directions.\n *\n * @remarks\n * This function takes an array of objects, an array of keys to sort by, and an array of order directions.\n * It returns the sorted array, ordering by each key according to its corresponding direction\n * ('asc' for ascending or 'desc' for descending). If values for a key are equal,\n * it moves to the next key to determine the order.\n *\n * @example\n * ```typescript\n * // Sort an array of objects by 'user' in ascending order and 'age' in descending order.\n * const users = [\n * { user: 'fred', age: 48 },\n * { user: 'barney', age: 34 },\n * { user: 'fred', age: 40 },\n * { user: 'barney', age: 36 },\n * ];\n * const result = orderBy(users, ['user', 'age'], ['asc', 'desc']);\n * // result will be:\n * // [\n * // { user: 'barney', age: 36 },\n * // { user: 'barney', age: 34 },\n * // { user: 'fred', age: 48 },\n * // { user: 'fred', age: 40 },\n * // ]\n * ```\n *\n * @param collection - The array of objects to be sorted.\n * @param keys - An array of keys (properties) by which to sort.\n * @param orders - An array of order directions ('asc' for ascending or 'desc' for descending).\n * @returns The sorted array.\n */\nexport function getOrderedBy<T>(\n collection: T[],\n keys: (keyof T)[],\n orders: Order[]\n): T[] {\n const compareValues = (a: T[keyof T], b: T[keyof T], order: Order) => {\n if (a < b) {\n return order === \"asc\" ? -1 : 1;\n }\n if (a > b) {\n return order === \"asc\" ? 1 : -1;\n }\n return 0;\n };\n\n const effectiveOrders = keys.map(\n (_, index) => orders[index] ?? orders.at(-1)\n );\n\n return [...collection].sort((a, b) => {\n for (const [i, key] of keys.entries()) {\n const order = effectiveOrders[i];\n const result = compareValues(a[key], b[key], order!);\n if (result !== 0) {\n return result;\n }\n }\n return 0;\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDA,SAAgB,aACd,YACA,MACA,QACK;CACL,MAAM,iBAAiB,GAAe,GAAe,UAAiB;AACpE,MAAI,IAAI,EACN,QAAO,UAAU,QAAQ,KAAK;AAEhC,MAAI,IAAI,EACN,QAAO,UAAU,QAAQ,IAAI;AAE/B,SAAO;;CAGT,MAAM,kBAAkB,KAAK,KAC1B,GAAG,UAAU,OAAO,UAAU,OAAO,GAAG,GAAG,CAC7C;AAED,QAAO,CAAC,GAAG,WAAW,CAAC,MAAM,GAAG,MAAM;AACpC,OAAK,MAAM,CAAC,GAAG,QAAQ,KAAK,SAAS,EAAE;GACrC,MAAM,QAAQ,gBAAgB;GAC9B,MAAM,SAAS,cAAc,EAAE,MAAM,EAAE,MAAM,MAAO;AACpD,OAAI,WAAW,EACb,QAAO;;AAGX,SAAO;GACP"}
@@ -1,11 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
2
 
4
3
  //#region src/get-unique.ts
5
- var get_unique_exports = /* @__PURE__ */ require_runtime.__exportAll({
6
- getUnique: () => getUnique,
7
- getUniqueBy: () => getUniqueBy
8
- });
9
4
  /**
10
5
  * Returns an array of unique values from the given array.
11
6
  *
@@ -40,10 +35,4 @@ function getUniqueBy(arr, mapper = (item) => item) {
40
35
 
41
36
  //#endregion
42
37
  exports.getUnique = getUnique;
43
- exports.getUniqueBy = getUniqueBy;
44
- Object.defineProperty(exports, 'get_unique_exports', {
45
- enumerable: true,
46
- get: function () {
47
- return get_unique_exports;
48
- }
49
- });
38
+ exports.getUniqueBy = getUniqueBy;
@@ -1,10 +1,4 @@
1
- import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
2
-
3
1
  //#region src/get-unique.ts
4
- var get_unique_exports = /* @__PURE__ */ __exportAll({
5
- getUnique: () => getUnique,
6
- getUniqueBy: () => getUniqueBy
7
- });
8
2
  /**
9
3
  * Returns an array of unique values from the given array.
10
4
  *
@@ -38,5 +32,5 @@ function getUniqueBy(arr, mapper = (item) => item) {
38
32
  }
39
33
 
40
34
  //#endregion
41
- export { getUnique, getUniqueBy, get_unique_exports };
35
+ export { getUnique, getUniqueBy };
42
36
  //# sourceMappingURL=get-unique.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-unique.mjs","names":[],"sources":["../src/get-unique.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 * Returns an array of unique values from the given array.\n *\n * @param arr - The array to get unique values from.\n * @returns An array of unique values.\n */\nexport const getUnique = <T = any>(arr: T[]): T[] => {\n return [...new Set(arr)];\n};\n\n/**\n * Returns a new array containing only the unique elements from the original array,\n * based on the values returned by the mapper function.\n *\n * @example\n * ```ts\n * uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);\n * // [1.2, 2.1, 3.2, 5.7, 7.19]\n * ```\n *\n * @param arr - The array to process.\n * @param mapper - The function used to convert the array elements.\n * @returns A new array containing only the unique elements from the original array, based on the values returned by the mapper function.\n */\nexport function getUniqueBy<T, U>(\n arr: readonly T[],\n mapper: (item: T) => U = item => item as unknown as U\n): T[] {\n const map = new Map<U, T>();\n\n for (const item of arr) {\n const key = mapper(item);\n\n if (!map.has(key)) {\n map.set(key, item);\n }\n }\n\n return [...map.values()];\n}\n"],"mappings":";;;;;;;;;;;;;AAwBA,MAAa,aAAsB,QAAkB;AACnD,QAAO,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC;;;;;;;;;;;;;;;;AAiB1B,SAAgB,YACd,KACA,UAAyB,SAAQ,MAC5B;CACL,MAAM,sBAAM,IAAI,KAAW;AAE3B,MAAK,MAAM,QAAQ,KAAK;EACtB,MAAM,MAAM,OAAO,KAAK;AAExB,MAAI,CAAC,IAAI,IAAI,IAAI,CACf,KAAI,IAAI,KAAK,KAAK;;AAItB,QAAO,CAAC,GAAG,IAAI,QAAQ,CAAC"}
1
+ {"version":3,"file":"get-unique.mjs","names":[],"sources":["../src/get-unique.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 * Returns an array of unique values from the given array.\n *\n * @param arr - The array to get unique values from.\n * @returns An array of unique values.\n */\nexport const getUnique = <T = any>(arr: T[]): T[] => {\n return [...new Set(arr)];\n};\n\n/**\n * Returns a new array containing only the unique elements from the original array,\n * based on the values returned by the mapper function.\n *\n * @example\n * ```ts\n * uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);\n * // [1.2, 2.1, 3.2, 5.7, 7.19]\n * ```\n *\n * @param arr - The array to process.\n * @param mapper - The function used to convert the array elements.\n * @returns A new array containing only the unique elements from the original array, based on the values returned by the mapper function.\n */\nexport function getUniqueBy<T, U>(\n arr: readonly T[],\n mapper: (item: T) => U = item => item as unknown as U\n): T[] {\n const map = new Map<U, T>();\n\n for (const item of arr) {\n const key = mapper(item);\n\n if (!map.has(key)) {\n map.set(key, item);\n }\n }\n\n return [...map.values()];\n}\n"],"mappings":";;;;;;;AAwBA,MAAa,aAAsB,QAAkB;AACnD,QAAO,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC;;;;;;;;;;;;;;;;AAiB1B,SAAgB,YACd,KACA,UAAyB,SAAQ,MAC5B;CACL,MAAM,sBAAM,IAAI,KAAW;AAE3B,MAAK,MAAM,QAAQ,KAAK;EACtB,MAAM,MAAM,OAAO,KAAK;AAExB,MAAI,CAAC,IAAI,IAAI,IAAI,CACf,KAAI,IAAI,KAAK,KAAK;;AAItB,QAAO,CAAC,GAAG,IAAI,QAAQ,CAAC"}
package/dist/identity.cjs CHANGED
@@ -1,8 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
2
 
4
3
  //#region src/identity.ts
5
- var identity_exports = /* @__PURE__ */ require_runtime.__exportAll({ identity: () => identity });
6
4
  /**
7
5
  * Returns the input value unchanged.
8
6
  *
@@ -21,10 +19,4 @@ function identity(x) {
21
19
  }
22
20
 
23
21
  //#endregion
24
- exports.identity = identity;
25
- Object.defineProperty(exports, 'identity_exports', {
26
- enumerable: true,
27
- get: function () {
28
- return identity_exports;
29
- }
30
- });
22
+ exports.identity = identity;
package/dist/identity.mjs CHANGED
@@ -1,7 +1,4 @@
1
- import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
2
-
3
1
  //#region src/identity.ts
4
- var identity_exports = /* @__PURE__ */ __exportAll({ identity: () => identity });
5
2
  /**
6
3
  * Returns the input value unchanged.
7
4
  *
@@ -20,5 +17,5 @@ function identity(x) {
20
17
  }
21
18
 
22
19
  //#endregion
23
- export { identity, identity_exports };
20
+ export { identity };
24
21
  //# sourceMappingURL=identity.mjs.map