umt 2.14.0 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/module/Array/arraysJoin.js +9 -1
  2. package/module/Array/arraysJoin.js.map +1 -1
  3. package/module/Array/sum.js +35 -2
  4. package/module/Array/sum.js.map +1 -1
  5. package/module/Array/zip.js +21 -5
  6. package/module/Array/zip.js.map +1 -1
  7. package/module/Array/zipLongest.js +23 -4
  8. package/module/Array/zipLongest.js.map +1 -1
  9. package/module/Crypto/decodeBase32.js.map +1 -1
  10. package/module/Crypto/decodeBase58.js +1 -2
  11. package/module/Crypto/decodeBase58.js.map +1 -1
  12. package/module/Crypto/encodeBase32.js +11 -6
  13. package/module/Crypto/encodeBase32.js.map +1 -1
  14. package/module/DataStructure/priorityQueue.js +8 -1
  15. package/module/DataStructure/priorityQueue.js.map +1 -1
  16. package/module/IP/ipToBinaryString.js +3 -1
  17. package/module/IP/ipToBinaryString.js.map +1 -1
  18. package/module/IP/longToIp.d.ts +1 -1
  19. package/module/IP/longToIp.js +2 -7
  20. package/module/IP/longToIp.js.map +1 -1
  21. package/module/Math/addition.js +4 -11
  22. package/module/Math/addition.js.map +1 -1
  23. package/module/Math/multiplication.js +14 -6
  24. package/module/Math/multiplication.js.map +1 -1
  25. package/module/Math/nCr.js +6 -2
  26. package/module/Math/nCr.js.map +1 -1
  27. package/module/Math/standardDeviation.js +12 -7
  28. package/module/Math/standardDeviation.js.map +1 -1
  29. package/module/Math/subtract.js +5 -9
  30. package/module/Math/subtract.js.map +1 -1
  31. package/module/Object/deepClone.d.ts +10 -0
  32. package/module/Object/deepClone.js +16 -9
  33. package/module/Object/deepClone.js.map +1 -1
  34. package/module/Object/getObjectsCommon.d.ts +10 -0
  35. package/module/Object/getObjectsCommon.js +10 -0
  36. package/module/Object/getObjectsCommon.js.map +1 -1
  37. package/module/Object/getObjectsDiff.d.ts +10 -0
  38. package/module/Object/getObjectsDiff.js +17 -6
  39. package/module/Object/getObjectsDiff.js.map +1 -1
  40. package/module/Object/has.d.ts +10 -0
  41. package/module/Object/has.js +13 -2
  42. package/module/Object/has.js.map +1 -1
  43. package/module/Object/index.d.ts +4 -0
  44. package/module/Object/index.js +4 -0
  45. package/module/Object/index.js.map +1 -1
  46. package/module/Object/keyBy.d.ts +10 -0
  47. package/module/Object/keyBy.js +10 -0
  48. package/module/Object/keyBy.js.map +1 -1
  49. package/module/Object/mapKeys.d.ts +10 -0
  50. package/module/Object/mapKeys.js +12 -1
  51. package/module/Object/mapKeys.js.map +1 -1
  52. package/module/Object/mapValues.d.ts +10 -0
  53. package/module/Object/mapValues.js +10 -0
  54. package/module/Object/mapValues.js.map +1 -1
  55. package/module/Object/merge.d.ts +10 -0
  56. package/module/Object/merge.js +17 -1
  57. package/module/Object/merge.js.map +1 -1
  58. package/module/Object/mergeDeep.d.ts +10 -0
  59. package/module/Object/mergeDeep.js +29 -15
  60. package/module/Object/mergeDeep.js.map +1 -1
  61. package/module/Object/pick.d.ts +10 -0
  62. package/module/Object/pick.js +10 -0
  63. package/module/Object/pick.js.map +1 -1
  64. package/module/Object/pickDeep.d.ts +10 -0
  65. package/module/Object/pickDeep.js +10 -5
  66. package/module/Object/pickDeep.js.map +1 -1
  67. package/module/Object/removePrototype.d.ts +15 -0
  68. package/module/Object/removePrototype.js +25 -0
  69. package/module/Object/removePrototype.js.map +1 -0
  70. package/module/Object/removePrototypeDeep.d.ts +11 -0
  71. package/module/Object/removePrototypeDeep.js +60 -0
  72. package/module/Object/removePrototypeDeep.js.map +1 -0
  73. package/module/Object/removePrototypeMap.d.ts +9 -0
  74. package/module/Object/removePrototypeMap.js +13 -0
  75. package/module/Object/removePrototypeMap.js.map +1 -0
  76. package/module/Object/removePrototypeMapDeep.d.ts +9 -0
  77. package/module/Object/removePrototypeMapDeep.js +13 -0
  78. package/module/Object/removePrototypeMapDeep.js.map +1 -0
  79. package/module/String/escapeHtml.js +11 -2
  80. package/module/String/escapeHtml.js.map +1 -1
  81. package/module/String/formatString/applyFormatter.js +5 -5
  82. package/module/String/formatString/applyFormatter.js.map +1 -1
  83. package/module/String/formatString/getValue.js +3 -1
  84. package/module/String/formatString/getValue.js.map +1 -1
  85. package/module/String/levenshteinDistance.js +41 -24
  86. package/module/String/levenshteinDistance.js.map +1 -1
  87. package/module/String/slugify.js +7 -5
  88. package/module/String/slugify.js.map +1 -1
  89. package/module/String/trimEndCharacters.js +3 -1
  90. package/module/String/trimEndCharacters.js.map +1 -1
  91. package/module/String/trimStartCharacters.js +3 -1
  92. package/module/String/trimStartCharacters.js.map +1 -1
  93. package/module/String/unescapeHtml.d.ts +1 -1
  94. package/module/String/unescapeHtml.js +48 -4
  95. package/module/String/unescapeHtml.js.map +1 -1
  96. package/module/Tool/parseJson.js +13 -1
  97. package/module/Tool/parseJson.js.map +1 -1
  98. package/module/URL/buildUrl.js +4 -0
  99. package/module/URL/buildUrl.js.map +1 -1
  100. package/module/URL/parseQueryString.js +4 -0
  101. package/module/URL/parseQueryString.js.map +1 -1
  102. package/module/Validate/isDeepEqual.js +7 -5
  103. package/module/Validate/isDeepEqual.js.map +1 -1
  104. package/module/Validate/isPrimeNumber.js +12 -2
  105. package/module/Validate/isPrimeNumber.js.map +1 -1
  106. package/module/Validate/object/index.d.ts +2 -0
  107. package/module/Validate/object/index.js +2 -0
  108. package/module/Validate/object/index.js.map +1 -1
  109. package/module/Validate/object/intersection.d.ts +10 -0
  110. package/module/Validate/object/intersection.js +25 -0
  111. package/module/Validate/object/intersection.js.map +1 -0
  112. package/module/Validate/object/optional.d.ts +6 -0
  113. package/module/Validate/object/optional.js +6 -0
  114. package/module/Validate/object/optional.js.map +1 -1
  115. package/module/Validate/object/union.d.ts +9 -0
  116. package/module/Validate/object/union.js +27 -0
  117. package/module/Validate/object/union.js.map +1 -0
  118. package/module/Validate/parseEmail.js +6 -0
  119. package/module/Validate/parseEmail.js.map +1 -1
  120. package/module/Validate/string/uuid.d.ts +1 -5
  121. package/module/Validate/string/uuid.js +19 -2
  122. package/module/Validate/string/uuid.js.map +1 -1
  123. package/module/es5/Array/arraysJoin.js +20 -2
  124. package/module/es5/Array/sum.js +38 -4
  125. package/module/es5/Array/zip.js +23 -17
  126. package/module/es5/Array/zipLongest.js +27 -14
  127. package/module/es5/Crypto/decodeBase58.js +1 -2
  128. package/module/es5/Crypto/encodeBase32.js +12 -6
  129. package/module/es5/DataStructure/priorityQueue.js +8 -3
  130. package/module/es5/IP/ipToBinaryString.js +2 -2
  131. package/module/es5/IP/longToIp.d.ts +1 -1
  132. package/module/es5/IP/longToIp.js +2 -13
  133. package/module/es5/Math/addition.js +4 -13
  134. package/module/es5/Math/multiplication.js +37 -6
  135. package/module/es5/Math/nCr.js +7 -2
  136. package/module/es5/Math/standardDeviation.js +25 -10
  137. package/module/es5/Math/subtract.js +12 -9
  138. package/module/es5/Object/deepClone.d.ts +10 -0
  139. package/module/es5/Object/deepClone.js +16 -9
  140. package/module/es5/Object/getObjectsCommon.d.ts +10 -0
  141. package/module/es5/Object/getObjectsCommon.js +10 -0
  142. package/module/es5/Object/getObjectsDiff.d.ts +10 -0
  143. package/module/es5/Object/getObjectsDiff.js +32 -17
  144. package/module/es5/Object/has.d.ts +10 -0
  145. package/module/es5/Object/has.js +11 -7
  146. package/module/es5/Object/index.d.ts +4 -0
  147. package/module/es5/Object/index.js +44 -0
  148. package/module/es5/Object/keyBy.d.ts +10 -0
  149. package/module/es5/Object/keyBy.js +10 -0
  150. package/module/es5/Object/mapKeys.d.ts +10 -0
  151. package/module/es5/Object/mapKeys.js +12 -1
  152. package/module/es5/Object/mapValues.d.ts +10 -0
  153. package/module/es5/Object/mapValues.js +10 -0
  154. package/module/es5/Object/merge.d.ts +10 -0
  155. package/module/es5/Object/merge.js +19 -1
  156. package/module/es5/Object/mergeDeep.d.ts +10 -0
  157. package/module/es5/Object/mergeDeep.js +34 -18
  158. package/module/es5/Object/pick.d.ts +10 -0
  159. package/module/es5/Object/pick.js +10 -0
  160. package/module/es5/Object/pickDeep.d.ts +10 -0
  161. package/module/es5/Object/pickDeep.js +10 -3
  162. package/module/es5/Object/removePrototype.d.ts +15 -0
  163. package/module/es5/Object/removePrototype.js +31 -0
  164. package/module/es5/Object/removePrototypeDeep.d.ts +11 -0
  165. package/module/es5/Object/removePrototypeDeep.js +81 -0
  166. package/module/es5/Object/removePrototypeMap.d.ts +9 -0
  167. package/module/es5/Object/removePrototypeMap.js +20 -0
  168. package/module/es5/Object/removePrototypeMapDeep.d.ts +9 -0
  169. package/module/es5/Object/removePrototypeMapDeep.js +20 -0
  170. package/module/es5/String/escapeHtml.js +12 -3
  171. package/module/es5/String/formatString/applyFormatter.js +5 -5
  172. package/module/es5/String/formatString/getValue.js +4 -1
  173. package/module/es5/String/levenshteinDistance.js +43 -28
  174. package/module/es5/String/slugify.js +8 -1
  175. package/module/es5/String/trimEndCharacters.js +3 -1
  176. package/module/es5/String/trimStartCharacters.js +3 -1
  177. package/module/es5/String/unescapeHtml.d.ts +1 -1
  178. package/module/es5/String/unescapeHtml.js +46 -4
  179. package/module/es5/Tool/parseJson.js +14 -1
  180. package/module/es5/URL/buildUrl.js +4 -0
  181. package/module/es5/URL/parseQueryString.js +4 -0
  182. package/module/es5/Validate/isDeepEqual.js +48 -39
  183. package/module/es5/Validate/isPrimeNumber.js +14 -2
  184. package/module/es5/Validate/object/index.d.ts +2 -0
  185. package/module/es5/Validate/object/index.js +22 -0
  186. package/module/es5/Validate/object/intersection.d.ts +10 -0
  187. package/module/es5/Validate/object/intersection.js +34 -0
  188. package/module/es5/Validate/object/optional.d.ts +6 -0
  189. package/module/es5/Validate/object/optional.js +6 -0
  190. package/module/es5/Validate/object/union.d.ts +9 -0
  191. package/module/es5/Validate/object/union.js +36 -0
  192. package/module/es5/Validate/parseEmail.js +8 -0
  193. package/module/es5/Validate/string/uuid.d.ts +1 -5
  194. package/module/es5/Validate/string/uuid.js +24 -2
  195. package/package.json +19 -19
  196. package/module/es5/tsconfig.tsbuildinfo +0 -1
@@ -11,6 +11,16 @@
11
11
  * @param {...Record<string, unknown>[]} objects - Additional objects to compare.
12
12
  * @returns {Partial<T>} Object containing only the key-value pairs shared by all inputs.
13
13
  *
14
+ * @remarks
15
+ * **Prototype pollution warning:** This function does not filter out
16
+ * prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
17
+ * If processing user-controlled input, sanitize with the appropriate
18
+ * `removePrototype*` helper before calling this function:
19
+ * - `removePrototype` — shallow sanitization of a single object
20
+ * - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
21
+ * - `removePrototypeMap` — shallow sanitization of an array of objects
22
+ * - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
23
+ *
14
24
  * @example
15
25
  * ```typescript
16
26
  * getObjectsCommon({ a: 1, b: 2 }, { a: 1, c: 3 });
@@ -12,6 +12,16 @@ import { isPlainObject } from "../Object/isPlainObject";
12
12
  * @param {...Record<string, unknown>[]} objects - Additional objects to compare.
13
13
  * @returns {Partial<T>} Object containing only the key-value pairs shared by all inputs.
14
14
  *
15
+ * @remarks
16
+ * **Prototype pollution warning:** This function does not filter out
17
+ * prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
18
+ * If processing user-controlled input, sanitize with the appropriate
19
+ * `removePrototype*` helper before calling this function:
20
+ * - `removePrototype` — shallow sanitization of a single object
21
+ * - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
22
+ * - `removePrototypeMap` — shallow sanitization of an array of objects
23
+ * - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
24
+ *
15
25
  * @example
16
26
  * ```typescript
17
27
  * getObjectsCommon({ a: 1, b: 2 }, { a: 1, c: 3 });
@@ -1 +1 @@
1
- {"version":3,"file":"getObjectsCommon.js","sourceRoot":"","sources":["../../src/Object/getObjectsCommon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;GA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AC,QAAQ,EAAE,CAAC;YACd,SAAS;QACX,CAAC;QAED,IAAI,eAAe,EAAE,CAAC;YACpB,MAAM,MAAM,GAAG,gBAAgB,CAC7B,KAAgC,EAChC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAA4B,CAAC,CACjE,CAAC;YAEF,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAClC,MAAkC,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;YACpD,CAAC;QACH,CAAC;aAAM,CAAC;YACL,MAAkC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACnD,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
@@ -13,6 +13,16 @@
13
13
  * @param {...Record<string, unknown>[]} objects - Additional objects to compare.
14
14
  * @returns {Partial<T>} Object containing only key-value pairs unique to one input.
15
15
  *
16
+ * @remarks
17
+ * **Prototype pollution warning:** This function does not filter out
18
+ * prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
19
+ * If processing user-controlled input, sanitize with the appropriate
20
+ * `removePrototype*` helper before calling this function:
21
+ * - `removePrototype` — shallow sanitization of a single object
22
+ * - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
23
+ * - `removePrototypeMap` — shallow sanitization of an array of objects
24
+ * - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
25
+ *
16
26
  * @example
17
27
  * ```typescript
18
28
  * getObjectsDiff({ a: 1, b: 2 }, { b: 2, c: 3 });
@@ -14,6 +14,16 @@ import { isPlainObject } from "../Object/isPlainObject";
14
14
  * @param {...Record<string, unknown>[]} objects - Additional objects to compare.
15
15
  * @returns {Partial<T>} Object containing only key-value pairs unique to one input.
16
16
  *
17
+ * @remarks
18
+ * **Prototype pollution warning:** This function does not filter out
19
+ * prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
20
+ * If processing user-controlled input, sanitize with the appropriate
21
+ * `removePrototype*` helper before calling this function:
22
+ * - `removePrototype` — shallow sanitization of a single object
23
+ * - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
24
+ * - `removePrototypeMap` — shallow sanitization of an array of objects
25
+ * - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
26
+ *
17
27
  * @example
18
28
  * ```typescript
19
29
  * getObjectsDiff({ a: 1, b: 2 }, { b: 2, c: 3 });
@@ -58,13 +68,14 @@ export const getObjectsDiff = (object, ...objects) => {
58
68
  }
59
69
  let lastUniqueValue;
60
70
  let hasUnique = false;
71
+ // Count occurrences in a single pass using a Map — O(n) instead of O(n²).
72
+ // Map keys use SameValueZero which matches === for all values except NaN,
73
+ // an acceptable trade-off for object-diff use cases.
74
+ const valueCounts = new Map();
61
75
  for (const value of values) {
62
- let count = 0;
63
- for (const other of values) {
64
- if (value === other) {
65
- count++;
66
- }
67
- }
76
+ valueCounts.set(value, (valueCounts.get(value) ?? 0) + 1);
77
+ }
78
+ for (const [value, count] of valueCounts) {
68
79
  if (count === 1) {
69
80
  lastUniqueValue = value;
70
81
  hasUnique = true;
@@ -1 +1 @@
1
- {"version":3,"file":"getObjectsDiff.js","sourceRoot":"","sources":["../../src/Object/getObjectsDiff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,MAAS,EACT,GAAG,OAAkC,EACzB,EAAE;IACd,MAAM,UAAU,GAAG,CAAC,MAAiC,EAAE,GAAG,OAAO,CAAC,CAAC;IAEnE,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,EAAE,GAAG,MAAM,EAAE,CAAC;IACvB,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC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,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,WAAW,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAC5D,CAAC;QACD,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,WAAW,EAAE,CAAC;YACzC,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;gBAChB,eAAe,GAAG,KAAK,CAAC;gBACxB,SAAS,GAAG,IAAI,CAAC;YACnB,CAAC;QACH,CAAC;QAED,IAAI,SAAS,EAAE,CAAC;YACb,MAAkC,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC;QAC7D,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
@@ -6,6 +6,16 @@
6
6
  * @example has({ a: { b: 1 } }, "a.b"); // true
7
7
  * has({ a: { b: 1 } }, ["a", "b"]); // true
8
8
  * has({ a: { b: 1 } }, "a.c"); // false
9
+ *
10
+ * @remarks
11
+ * **Prototype pollution warning:** This function does not filter out
12
+ * prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
13
+ * If processing user-controlled input, sanitize with the appropriate
14
+ * `removePrototype*` helper before calling this function:
15
+ * - `removePrototype` — shallow sanitization of a single object
16
+ * - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
17
+ * - `removePrototypeMap` — shallow sanitization of an array of objects
18
+ * - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
9
19
  */
10
20
  export declare const has: <T extends {
11
21
  [key: string]: unknown;
@@ -6,12 +6,23 @@
6
6
  * @example has({ a: { b: 1 } }, "a.b"); // true
7
7
  * has({ a: { b: 1 } }, ["a", "b"]); // true
8
8
  * has({ a: { b: 1 } }, "a.c"); // false
9
+ *
10
+ * @remarks
11
+ * **Prototype pollution warning:** This function does not filter out
12
+ * prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
13
+ * If processing user-controlled input, sanitize with the appropriate
14
+ * `removePrototype*` helper before calling this function:
15
+ * - `removePrototype` — shallow sanitization of a single object
16
+ * - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
17
+ * - `removePrototypeMap` — shallow sanitization of an array of objects
18
+ * - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
9
19
  */
10
20
  export const has = (object, path) => {
11
21
  const localPath = typeof path === "string" ? path.split(".") : path;
12
- let current = { ...object };
22
+ let current = object;
13
23
  for (const key of localPath) {
14
- if (current == null || !Object.hasOwn(current, key)) {
24
+ if (current == null ||
25
+ !Object.hasOwn(current, key)) {
15
26
  return false;
16
27
  }
17
28
  current = current[key];
@@ -1 +1 @@
1
- {"version":3,"file":"has.js","sourceRoot":"","sources":["../../src/Object/has.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,CACjB,MAAS,EACT,IAAuB,EACd,EAAE;IACX,MAAM,SAAS,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACpE,IAAI,OAAO,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;IAC5B,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;QAC5B,IAAI,OAAO,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC;YACpD,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,GAAG,OAAO,CAAC,GAAG,CAAM,CAAC;IAC9B,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
1
+ {"version":3,"file":"has.js","sourceRoot":"","sources":["../../src/Object/has.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,CACjB,MAAS,EACT,IAAuB,EACd,EAAE;IACX,MAAM,SAAS,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACpE,IAAI,OAAO,GAAY,MAAM,CAAC;IAC9B,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;QAC5B,IACE,OAAO,IAAI,IAAI;YACf,CAAC,MAAM,CAAC,MAAM,CAAC,OAAkC,EAAE,GAAG,CAAC,EACvD,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,GAAI,OAAmC,CAAC,GAAG,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
@@ -12,3 +12,7 @@ export * from "./mergeDeep";
12
12
  export * from "./omit";
13
13
  export * from "./pick";
14
14
  export * from "./pickDeep";
15
+ export * from "./removePrototype";
16
+ export * from "./removePrototypeDeep";
17
+ export * from "./removePrototypeMap";
18
+ export * from "./removePrototypeMapDeep";
@@ -12,4 +12,8 @@ export * from "./mergeDeep";
12
12
  export * from "./omit";
13
13
  export * from "./pick";
14
14
  export * from "./pickDeep";
15
+ export * from "./removePrototype";
16
+ export * from "./removePrototypeDeep";
17
+ export * from "./removePrototypeMap";
18
+ export * from "./removePrototypeMapDeep";
15
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Object/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Object/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC"}
@@ -5,6 +5,16 @@ type Iteratee<T> = IterateeFunction<T> | keyof T;
5
5
  * Creates an object composed of keys generated from the results of running each element of collection through iteratee
6
6
  * @param collection The collection to iterate over
7
7
  * @param iteratee The iteratee function or property name to generate the key
8
+ *
9
+ * @remarks
10
+ * **Prototype pollution warning:** This function does not filter out
11
+ * prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
12
+ * If processing user-controlled input, sanitize with the appropriate
13
+ * `removePrototype*` helper before calling this function:
14
+ * - `removePrototype` — shallow sanitization of a single object
15
+ * - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
16
+ * - `removePrototypeMap` — shallow sanitization of an array of objects
17
+ * - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
8
18
  */
9
19
  export declare function keyBy<T>(collection: T[] | Record<PropertyName, T>, iteratee?: Iteratee<T>): Record<PropertyName, T>;
10
20
  export {};
@@ -2,6 +2,16 @@
2
2
  * Creates an object composed of keys generated from the results of running each element of collection through iteratee
3
3
  * @param collection The collection to iterate over
4
4
  * @param iteratee The iteratee function or property name to generate the key
5
+ *
6
+ * @remarks
7
+ * **Prototype pollution warning:** This function does not filter out
8
+ * prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
9
+ * If processing user-controlled input, sanitize with the appropriate
10
+ * `removePrototype*` helper before calling this function:
11
+ * - `removePrototype` — shallow sanitization of a single object
12
+ * - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
13
+ * - `removePrototypeMap` — shallow sanitization of an array of objects
14
+ * - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
5
15
  */
6
16
  export function keyBy(collection, iteratee) {
7
17
  const getKey = normalizeIteratee(iteratee);
@@ -1 +1 @@
1
- {"version":3,"file":"keyBy.js","sourceRoot":"","sources":["../../src/Object/keyBy.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,MAAM,UAAU,KAAK,CACnB,UAAyC,EACzC,QAAsB;IAEtB,MAAM,MAAM,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC3C,MAAM,MAAM,GAA4B,EAAE,CAAC;IAE3C,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC;YAC/B,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;YAC1B,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACtB,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9C,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC1B,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACtB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,SAAS,iBAAiB,CAAI,QAAsB;IAClD,IAAI,CAAC,QAAQ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AAO,CAAC,MAAS,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAiB,CAAC;AACzD,CAAC"}
@@ -6,6 +6,16 @@
6
6
  * @param function_ - The function invoked per key. Receives (value, key).
7
7
  * @returns A new object with transformed keys.
8
8
  *
9
+ * @remarks
10
+ * **Prototype pollution warning:** This function does not filter out
11
+ * prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
12
+ * If processing user-controlled input, sanitize with the appropriate
13
+ * `removePrototype*` helper before calling this function:
14
+ * - `removePrototype` — shallow sanitization of a single object
15
+ * - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
16
+ * - `removePrototypeMap` — shallow sanitization of an array of objects
17
+ * - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
18
+ *
9
19
  * @example
10
20
  * ```typescript
11
21
  * mapKeys({ a: 1, b: 2 }, (_value, key) => key.toUpperCase());
@@ -6,6 +6,16 @@
6
6
  * @param function_ - The function invoked per key. Receives (value, key).
7
7
  * @returns A new object with transformed keys.
8
8
  *
9
+ * @remarks
10
+ * **Prototype pollution warning:** This function does not filter out
11
+ * prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
12
+ * If processing user-controlled input, sanitize with the appropriate
13
+ * `removePrototype*` helper before calling this function:
14
+ * - `removePrototype` — shallow sanitization of a single object
15
+ * - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
16
+ * - `removePrototypeMap` — shallow sanitization of an array of objects
17
+ * - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
18
+ *
9
19
  * @example
10
20
  * ```typescript
11
21
  * mapKeys({ a: 1, b: 2 }, (_value, key) => key.toUpperCase());
@@ -20,7 +30,8 @@ export const mapKeys = (object, function_) => {
20
30
  while (index < length) {
21
31
  const key = keys[index];
22
32
  const value = object[key];
23
- result[function_(value, key)] = value;
33
+ const newKey = function_(value, key);
34
+ result[newKey] = value;
24
35
  index += 1;
25
36
  }
26
37
  return result;
@@ -1 +1 @@
1
- {"version":3,"file":"mapKeys.js","sourceRoot":"","sources":["../../src/Object/mapKeys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,MAAS,EACT,SAAqD,EACzB,EAAE;IAC9B,MAAM,MAAM,GAA+B,EAAE,CAAC;IAC9C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC3B,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,OAAO,KAAK,GAAG,MAAM,EAAE,CAAC;QACtB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QACxB,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAe,CAAC;QACxC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QACtC,KAAK,IAAI,CAAC,CAAC;IACb,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
1
+ {"version":3,"file":"mapKeys.js","sourceRoot":"","sources":["../../src/Object/mapKeys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,MAAS,EACT,SAAqD,EACzB,EAAE;IAC9B,MAAM,MAAM,GAA+B,EAAE,CAAC;IAC9C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC3B,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,OAAO,KAAK,GAAG,MAAM,EAAE,CAAC;QACtB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QACxB,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAe,CAAC;QACxC,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACrC,MAAM,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;QACvB,KAAK,IAAI,CAAC,CAAC;IACb,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
@@ -6,6 +6,16 @@
6
6
  * @param function_ - The function invoked per value. Receives (value, key).
7
7
  * @returns A new object with transformed values.
8
8
  *
9
+ * @remarks
10
+ * **Prototype pollution warning:** This function does not filter out
11
+ * prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
12
+ * If processing user-controlled input, sanitize with the appropriate
13
+ * `removePrototype*` helper before calling this function:
14
+ * - `removePrototype` — shallow sanitization of a single object
15
+ * - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
16
+ * - `removePrototypeMap` — shallow sanitization of an array of objects
17
+ * - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
18
+ *
9
19
  * @example
10
20
  * ```typescript
11
21
  * mapValues({ a: 1, b: 2 }, (value) => value * 2);
@@ -6,6 +6,16 @@
6
6
  * @param function_ - The function invoked per value. Receives (value, key).
7
7
  * @returns A new object with transformed values.
8
8
  *
9
+ * @remarks
10
+ * **Prototype pollution warning:** This function does not filter out
11
+ * prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
12
+ * If processing user-controlled input, sanitize with the appropriate
13
+ * `removePrototype*` helper before calling this function:
14
+ * - `removePrototype` — shallow sanitization of a single object
15
+ * - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
16
+ * - `removePrototypeMap` — shallow sanitization of an array of objects
17
+ * - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
18
+ *
9
19
  * @example
10
20
  * ```typescript
11
21
  * mapValues({ a: 1, b: 2 }, (value) => value * 2);
@@ -1 +1 @@
1
- {"version":3,"file":"mapValues.js","sourceRoot":"","sources":["../../src/Object/mapValues.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,MAAS,EACT,SAAgD,EAC5B,EAAE;IACtB,MAAM,MAAM,GAAG,EAAuB,CAAC;IACvC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC3B,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,OAAO,KAAK,GAAG,MAAM,EAAE,CAAC;QACtB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QACxB,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAe,EAAE,GAAG,CAAC,CAAC;QACxD,KAAK,IAAI,CAAC,CAAC;IACb,CAAC;IAED,OAAO,MAA4B,CAAC;AACtC,CAAC,CAAC"}
1
+ {"version":3,"file":"mapValues.js","sourceRoot":"","sources":["../../src/Object/mapValues.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,MAAS,EACT,SAAgD,EAC5B,EAAE;IACtB,MAAM,MAAM,GAAG,EAAuB,CAAC;IACvC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC3B,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,OAAO,KAAK,GAAG,MAAM,EAAE,CAAC;QACtB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QACxB,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAe,EAAE,GAAG,CAAC,CAAC;QACxD,KAAK,IAAI,CAAC,CAAC;IACb,CAAC;IAED,OAAO,MAA4B,CAAC;AACtC,CAAC,CAAC"}
@@ -4,5 +4,15 @@ import type { UnionToIntersection } from "../types/logic/unionToIntersection";
4
4
  * @param target - The target object to merge into
5
5
  * @param sources - The source objects to merge from
6
6
  * @returns The merged object
7
+ *
8
+ * @remarks
9
+ * **Prototype pollution warning:** This function does not filter out
10
+ * prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
11
+ * If processing user-controlled input, sanitize with the appropriate
12
+ * `removePrototype*` helper before calling this function:
13
+ * - `removePrototype` — shallow sanitization of a single object
14
+ * - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
15
+ * - `removePrototypeMap` — shallow sanitization of an array of objects
16
+ * - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
7
17
  */
8
18
  export declare const merge: <T extends Record<string, unknown>, U extends Record<string, unknown>[]>(target: T, ...sources: U) => T & UnionToIntersection<U[number]>;
@@ -3,8 +3,24 @@
3
3
  * @param target - The target object to merge into
4
4
  * @param sources - The source objects to merge from
5
5
  * @returns The merged object
6
+ *
7
+ * @remarks
8
+ * **Prototype pollution warning:** This function does not filter out
9
+ * prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
10
+ * If processing user-controlled input, sanitize with the appropriate
11
+ * `removePrototype*` helper before calling this function:
12
+ * - `removePrototype` — shallow sanitization of a single object
13
+ * - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
14
+ * - `removePrototypeMap` — shallow sanitization of an array of objects
15
+ * - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
6
16
  */
7
17
  export const merge = (target, ...sources) => {
8
- return Object.assign({}, target, ...sources);
18
+ const result = {};
19
+ for (const object of [target, ...sources]) {
20
+ for (const key of Object.keys(object)) {
21
+ result[key] = object[key];
22
+ }
23
+ }
24
+ return result;
9
25
  };
10
26
  //# sourceMappingURL=merge.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"merge.js","sourceRoot":"","sources":["../../src/Object/merge.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAInB,MAAS,EACT,GAAG,OAAU,EACuB,EAAE;IACtC,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC;AAC/C,CAAC,CAAC"}
1
+ {"version":3,"file":"merge.js","sourceRoot":"","sources":["../../src/Object/merge.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAInB,MAAS,EACT,GAAG,OAAU,EACuB,EAAE;IACtC,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,KAAK,MAAM,MAAM,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC;QAC1C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACtC,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IACD,OAAO,MAA4C,CAAC;AACtD,CAAC,CAAC"}
@@ -4,5 +4,15 @@ import type { UnionToIntersection } from "../types/logic/unionToIntersection";
4
4
  * @param target - The target object to merge into
5
5
  * @param sources - The source objects to merge from
6
6
  * @returns The deeply merged object
7
+ *
8
+ * @remarks
9
+ * **Prototype pollution warning:** This function does not filter out
10
+ * prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
11
+ * If processing user-controlled input, sanitize with the appropriate
12
+ * `removePrototype*` helper before calling this function:
13
+ * - `removePrototype` — shallow sanitization of a single object
14
+ * - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
15
+ * - `removePrototypeMap` — shallow sanitization of an array of objects
16
+ * - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
7
17
  */
8
18
  export declare const mergeDeep: <T extends Record<string, unknown>, U extends Record<string, unknown>[]>(target: T, ...sources: U) => T & UnionToIntersection<U[number]>;
@@ -1,32 +1,46 @@
1
1
  import { isPlainObject } from "../Object/isPlainObject";
2
- /**
3
- * Deeply merges multiple objects into a single object
4
- * @param target - The target object to merge into
5
- * @param sources - The source objects to merge from
6
- * @returns The deeply merged object
7
- */
8
- export const mergeDeep = (target, ...sources) => {
9
- if (sources.length === 0) {
2
+ // Performance: use an index parameter instead of Array.shift() to advance
3
+ // through sources. shift() is O(n) because it re-indexes every remaining
4
+ // element, making the overall merge O(n²) in the number of sources.
5
+ // An index makes each step O(1) and avoids mutating the sources array.
6
+ const mergeDeepInternal = (target, sources, depth, sourceIndex = 0) => {
7
+ if (sourceIndex >= sources.length) {
10
8
  return target;
11
9
  }
12
- const source = sources.shift();
10
+ const source = sources[sourceIndex];
13
11
  if (isPlainObject(target) && isPlainObject(source)) {
14
12
  const result = { ...target };
15
13
  for (const key in source) {
16
- if (key === "__proto__" || key === "constructor" || key === "prototype") {
17
- continue;
18
- }
19
14
  if (Object.hasOwn(source, key)) {
20
15
  const sourceValue = source[key];
21
16
  const targetValue = result[key];
22
17
  result[key] =
23
18
  isPlainObject(targetValue) && isPlainObject(sourceValue)
24
- ? mergeDeep(targetValue, sourceValue)
19
+ ? mergeDeepInternal(targetValue, [sourceValue], depth + 1)
25
20
  : sourceValue;
26
21
  }
27
22
  }
28
- return mergeDeep(result, ...sources);
23
+ return mergeDeepInternal(result, sources, depth + 1, sourceIndex + 1);
29
24
  }
30
- return mergeDeep(source, ...sources);
25
+ return mergeDeepInternal(source, sources, depth + 1, sourceIndex + 1);
26
+ };
27
+ /**
28
+ * Deeply merges multiple objects into a single object
29
+ * @param target - The target object to merge into
30
+ * @param sources - The source objects to merge from
31
+ * @returns The deeply merged object
32
+ *
33
+ * @remarks
34
+ * **Prototype pollution warning:** This function does not filter out
35
+ * prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
36
+ * If processing user-controlled input, sanitize with the appropriate
37
+ * `removePrototype*` helper before calling this function:
38
+ * - `removePrototype` — shallow sanitization of a single object
39
+ * - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
40
+ * - `removePrototypeMap` — shallow sanitization of an array of objects
41
+ * - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
42
+ */
43
+ export const mergeDeep = (target, ...sources) => {
44
+ return mergeDeepInternal(target, sources, 0);
31
45
  };
32
46
  //# sourceMappingURL=mergeDeep.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mergeDeep.js","sourceRoot":"","sources":["../../src/Object/mergeDeep.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAIvB,MAAS,EACT,GAAG,OAAU,EACuB,EAAE;IACtC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,MAA4C,CAAC;IACtD,CAAC;IAED,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAE/B,IAAI,aAAa,CAAC,MAAM,CAAC,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;QACnD,MAAM,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;QAE7B,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YACzB,IAAI,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,aAAa,IAAI,GAAG,KAAK,WAAW,EAAE,CAAC;gBACxE,SAAS;YACX,CAAC;YAED,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;gBAC/B,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;gBAChC,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;gBAE/B,MAAkC,CAAC,GAAG,CAAC;oBACtC,aAAa,CAAC,WAAW,CAAC,IAAI,aAAa,CAAC,WAAW,CAAC;wBACtD,CAAC,CAAC,SAAS,CAAC,WAAW,EAAE,WAAW,CAAC;wBACrC,CAAC,CAAC,WAAW,CAAC;YACpB,CAAC;QACH,CAAC;QAED,OA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,KAAK,GAAG,CAAC,EACT,WAAW,GAAG,CAAC,CACsB,CAAC;IAC1C,CAAC;IAED,OAAO,iBAAiB,CACtB,MAAW,EACX,OAAuB,EACvB,KAAK,GAAG,CAAC,EACT,WAAW,GAAG,CAAC,CACsB,CAAC;AAC1C,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAIvB,MAAS,EACT,GAAG,OAAU,EACuB,EAAE;IACtC,OAAO,iBAAiB,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;AAC/C,CAAC,CAAC"}
@@ -7,6 +7,16 @@
7
7
  * @param {...K[]} keys - The property keys to extract.
8
8
  * @returns {Pick<T, K>} A new object containing only the specified properties.
9
9
  *
10
+ * @remarks
11
+ * **Prototype pollution warning:** This function does not filter out
12
+ * prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
13
+ * If processing user-controlled input, sanitize with the appropriate
14
+ * `removePrototype*` helper before calling this function:
15
+ * - `removePrototype` — shallow sanitization of a single object
16
+ * - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
17
+ * - `removePrototypeMap` — shallow sanitization of an array of objects
18
+ * - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
19
+ *
10
20
  * @example
11
21
  * ```typescript
12
22
  * const user = { id: 1, name: 'Alice', age: 30 };
@@ -7,6 +7,16 @@
7
7
  * @param {...K[]} keys - The property keys to extract.
8
8
  * @returns {Pick<T, K>} A new object containing only the specified properties.
9
9
  *
10
+ * @remarks
11
+ * **Prototype pollution warning:** This function does not filter out
12
+ * prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
13
+ * If processing user-controlled input, sanitize with the appropriate
14
+ * `removePrototype*` helper before calling this function:
15
+ * - `removePrototype` — shallow sanitization of a single object
16
+ * - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
17
+ * - `removePrototypeMap` — shallow sanitization of an array of objects
18
+ * - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
19
+ *
10
20
  * @example
11
21
  * ```typescript
12
22
  * const user = { id: 1, name: 'Alice', age: 30 };
@@ -1 +1 @@
1
- {"version":3,"file":"pick.js","sourceRoot":"","sources":["../../src/Object/pick.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAClB,MAAS,EACT,GAAG,IAAS,EACA,EAAE;IACd,MAAM,MAAM,GAAG,EAAgB,CAAC;IAChC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
1
+ {"version":3,"file":"pick.js","sourceRoot":"","sources":["../../src/Object/pick.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAClB,MAAS,EACT,GAAG,IAAS,EACA,EAAE;IACd,MAAM,MAAM,GAAG,EAAgB,CAAC;IAChC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
@@ -9,6 +9,16 @@ import type { PickDeepKey } from "../types/object/pickDeepKey";
9
9
  * @param {...K[]} keys - Property keys to extract. Can use dot notation for nested properties.
10
10
  * @returns {PickDeep<T, K>} A new object containing only the specified properties.
11
11
  *
12
+ * @remarks
13
+ * **Prototype pollution warning:** This function does not filter out
14
+ * prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
15
+ * If processing user-controlled input, sanitize with the appropriate
16
+ * `removePrototype*` helper before calling this function:
17
+ * - `removePrototype` — shallow sanitization of a single object
18
+ * - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
19
+ * - `removePrototypeMap` — shallow sanitization of an array of objects
20
+ * - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
21
+ *
12
22
  * @example
13
23
  * ```typescript
14
24
  * const obj = { a: { b: { c: 1, d: 2 }, e: 3 }, f: 4 };
@@ -7,6 +7,16 @@
7
7
  * @param {...K[]} keys - Property keys to extract. Can use dot notation for nested properties.
8
8
  * @returns {PickDeep<T, K>} A new object containing only the specified properties.
9
9
  *
10
+ * @remarks
11
+ * **Prototype pollution warning:** This function does not filter out
12
+ * prototype-polluting keys (`__proto__`, `constructor`, `prototype`).
13
+ * If processing user-controlled input, sanitize with the appropriate
14
+ * `removePrototype*` helper before calling this function:
15
+ * - `removePrototype` — shallow sanitization of a single object
16
+ * - `removePrototypeDeep` — recursive sanitization of a single object (for deeply nested data)
17
+ * - `removePrototypeMap` — shallow sanitization of an array of objects
18
+ * - `removePrototypeMapDeep` — recursive sanitization of an array of objects (for deeply nested data)
19
+ *
10
20
  * @example
11
21
  * ```typescript
12
22
  * const obj = { a: { b: { c: 1, d: 2 }, e: 3 }, f: 4 };
@@ -24,11 +34,6 @@ export const pickDeep = (object, ...keys) => {
24
34
  // biome-ignore lint/suspicious/noExplicitAny: ignore
25
35
  let target = result;
26
36
  for (const [index, part] of parts.entries()) {
27
- if (part === "__proto__" ||
28
- part === "constructor" ||
29
- part === "prototype") {
30
- continue;
31
- }
32
37
  if (current && typeof current === "object" && part in current) {
33
38
  if (index === parts.length - 1) {
34
39
  target[part] = current[part];
@@ -1 +1 @@
1
- {"version":3,"file":"pickDeep.js","sourceRoot":"","sources":["../../src/Object/pickDeep.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAItB,MAAS,EACT,GAAG,IAAO,EACM,EAAE;IAClB,qDAAqD;IACrD,MAAM,MAAM,GAAQ,EAAE,CAAC;IAEvB,KAAK,MAAM,GAAG,IA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,GAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACzC,qDAAqD;QACrD,IAAI,OAAO,GAAQ,MAAM,CAAC;QAC1B,qDAAqD;QACrD,IAAI,MAAM,GAAQ,MAAM,CAAC;QAEzB,KAAK,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;YAC5C,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,IAAI,IAAI,OAAO,EAAE,CAAC;gBAC9D,IAAI,KAAK,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC/B,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;gBAC/B,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;oBAClC,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;oBACxB,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;gBACxB,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Creates a new object with the same properties as the given object, but with the prototype polluting properties removed.
3
+ * ("__proto__", "constructor", "prototype" are excluded from the shallow copy)
4
+ *
5
+ * @param object - The object to remove the prototype polluting properties from.
6
+ * @returns A new object with the prototype polluting properties removed.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * const obj = JSON.parse('{"__proto__":{"polluted":true},"a":1,"b":2}');
11
+ * const safeObj = removePrototype(obj);
12
+ * // safeObj is { a: 1, b: 2 } and "__proto__" is removed
13
+ * ```
14
+ */
15
+ export declare const removePrototype: <T extends Record<string, unknown>>(object: T) => Omit<T, "__proto__" | "constructor" | "prototype">;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Creates a new object with the same properties as the given object, but with the prototype polluting properties removed.
3
+ * ("__proto__", "constructor", "prototype" are excluded from the shallow copy)
4
+ *
5
+ * @param object - The object to remove the prototype polluting properties from.
6
+ * @returns A new object with the prototype polluting properties removed.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * const obj = JSON.parse('{"__proto__":{"polluted":true},"a":1,"b":2}');
11
+ * const safeObj = removePrototype(obj);
12
+ * // safeObj is { a: 1, b: 2 } and "__proto__" is removed
13
+ * ```
14
+ */
15
+ export const removePrototype = (object) => {
16
+ const result = Object.create(null);
17
+ const keys = Object.keys(object);
18
+ for (const key of keys) {
19
+ if (key !== "__proto__" && key !== "constructor" && key !== "prototype") {
20
+ result[key] = object[key];
21
+ }
22
+ }
23
+ return result;
24
+ };
25
+ //# sourceMappingURL=removePrototype.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removePrototype.js","sourceRoot":"","sources":["../../src/Object/removePrototype.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,MAAS,EAC2C,EAAE;IACtD,MAAM,MAAM,GAA4B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC5D,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEjC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,aAAa,IAAI,GAAG,KAAK,WAAW,EAAE,CAAC;YACxE,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IAED,OAAO,MAA4D,CAAC;AACtE,CAAC,CAAC"}