umt 2.13.0 → 2.15.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 (199) 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/ultraNumberSort.js +8 -3
  6. package/module/Array/ultraNumberSort.js.map +1 -1
  7. package/module/Array/zip.js +21 -5
  8. package/module/Array/zip.js.map +1 -1
  9. package/module/Array/zipLongest.js +23 -4
  10. package/module/Array/zipLongest.js.map +1 -1
  11. package/module/Crypto/decodeBase32.js +3 -2
  12. package/module/Crypto/decodeBase32.js.map +1 -1
  13. package/module/Crypto/decodeBase58.js +6 -4
  14. package/module/Crypto/decodeBase58.js.map +1 -1
  15. package/module/Crypto/encodeBase32.js +11 -6
  16. package/module/Crypto/encodeBase32.js.map +1 -1
  17. package/module/Crypto/encodeBase58.js +5 -2
  18. package/module/Crypto/encodeBase58.js.map +1 -1
  19. package/module/DataStructure/priorityQueue.js +8 -1
  20. package/module/DataStructure/priorityQueue.js.map +1 -1
  21. package/module/IP/ipToBinaryString.js +3 -1
  22. package/module/IP/ipToBinaryString.js.map +1 -1
  23. package/module/IP/longToIp.d.ts +1 -1
  24. package/module/IP/longToIp.js +2 -7
  25. package/module/IP/longToIp.js.map +1 -1
  26. package/module/Math/addition.js +4 -11
  27. package/module/Math/addition.js.map +1 -1
  28. package/module/Math/multiplication.js +14 -6
  29. package/module/Math/multiplication.js.map +1 -1
  30. package/module/Math/nCr.js +6 -2
  31. package/module/Math/nCr.js.map +1 -1
  32. package/module/Math/standardDeviation.js +12 -7
  33. package/module/Math/standardDeviation.js.map +1 -1
  34. package/module/Math/subtract.js +5 -9
  35. package/module/Math/subtract.js.map +1 -1
  36. package/module/Object/deepClone.d.ts +10 -0
  37. package/module/Object/deepClone.js +16 -6
  38. package/module/Object/deepClone.js.map +1 -1
  39. package/module/Object/getObjectsCommon.d.ts +10 -0
  40. package/module/Object/getObjectsCommon.js +10 -0
  41. package/module/Object/getObjectsCommon.js.map +1 -1
  42. package/module/Object/getObjectsDiff.d.ts +10 -0
  43. package/module/Object/getObjectsDiff.js +17 -6
  44. package/module/Object/getObjectsDiff.js.map +1 -1
  45. package/module/Object/has.d.ts +10 -0
  46. package/module/Object/has.js +10 -0
  47. package/module/Object/has.js.map +1 -1
  48. package/module/Object/index.d.ts +4 -0
  49. package/module/Object/index.js +4 -0
  50. package/module/Object/index.js.map +1 -1
  51. package/module/Object/keyBy.d.ts +10 -0
  52. package/module/Object/keyBy.js +10 -0
  53. package/module/Object/keyBy.js.map +1 -1
  54. package/module/Object/mapKeys.d.ts +10 -0
  55. package/module/Object/mapKeys.js +12 -1
  56. package/module/Object/mapKeys.js.map +1 -1
  57. package/module/Object/mapValues.d.ts +10 -0
  58. package/module/Object/mapValues.js +10 -0
  59. package/module/Object/mapValues.js.map +1 -1
  60. package/module/Object/merge.d.ts +10 -0
  61. package/module/Object/merge.js +17 -1
  62. package/module/Object/merge.js.map +1 -1
  63. package/module/Object/mergeDeep.d.ts +10 -0
  64. package/module/Object/mergeDeep.js +29 -15
  65. package/module/Object/mergeDeep.js.map +1 -1
  66. package/module/Object/pickDeep.d.ts +10 -0
  67. package/module/Object/pickDeep.js +10 -5
  68. package/module/Object/pickDeep.js.map +1 -1
  69. package/module/Object/removePrototype.d.ts +15 -0
  70. package/module/Object/removePrototype.js +25 -0
  71. package/module/Object/removePrototype.js.map +1 -0
  72. package/module/Object/removePrototypeDeep.d.ts +11 -0
  73. package/module/Object/removePrototypeDeep.js +60 -0
  74. package/module/Object/removePrototypeDeep.js.map +1 -0
  75. package/module/Object/removePrototypeMap.d.ts +9 -0
  76. package/module/Object/removePrototypeMap.js +13 -0
  77. package/module/Object/removePrototypeMap.js.map +1 -0
  78. package/module/Object/removePrototypeMapDeep.d.ts +9 -0
  79. package/module/Object/removePrototypeMapDeep.js +13 -0
  80. package/module/Object/removePrototypeMapDeep.js.map +1 -0
  81. package/module/String/escapeHtml.js +11 -2
  82. package/module/String/escapeHtml.js.map +1 -1
  83. package/module/String/formatString/applyFormatter.js +5 -5
  84. package/module/String/formatString/applyFormatter.js.map +1 -1
  85. package/module/String/formatString/getValue.js +3 -1
  86. package/module/String/formatString/getValue.js.map +1 -1
  87. package/module/String/levenshteinDistance.js +41 -24
  88. package/module/String/levenshteinDistance.js.map +1 -1
  89. package/module/String/slugify.js +7 -5
  90. package/module/String/slugify.js.map +1 -1
  91. package/module/String/trimEndCharacters.js +3 -1
  92. package/module/String/trimEndCharacters.js.map +1 -1
  93. package/module/String/trimStartCharacters.js +3 -1
  94. package/module/String/trimStartCharacters.js.map +1 -1
  95. package/module/String/unescapeHtml.d.ts +1 -1
  96. package/module/String/unescapeHtml.js +48 -4
  97. package/module/String/unescapeHtml.js.map +1 -1
  98. package/module/Tool/parseJson.js +13 -1
  99. package/module/Tool/parseJson.js.map +1 -1
  100. package/module/URL/buildUrl.js +4 -0
  101. package/module/URL/buildUrl.js.map +1 -1
  102. package/module/URL/parseQueryString.js +4 -0
  103. package/module/URL/parseQueryString.js.map +1 -1
  104. package/module/Validate/isDeepEqual.js +7 -5
  105. package/module/Validate/isDeepEqual.js.map +1 -1
  106. package/module/Validate/isPrimeNumber.js +12 -2
  107. package/module/Validate/isPrimeNumber.js.map +1 -1
  108. package/module/Validate/object/index.d.ts +2 -0
  109. package/module/Validate/object/index.js +2 -0
  110. package/module/Validate/object/index.js.map +1 -1
  111. package/module/Validate/object/intersection.d.ts +10 -0
  112. package/module/Validate/object/intersection.js +25 -0
  113. package/module/Validate/object/intersection.js.map +1 -0
  114. package/module/Validate/object/optional.d.ts +6 -0
  115. package/module/Validate/object/optional.js +6 -0
  116. package/module/Validate/object/optional.js.map +1 -1
  117. package/module/Validate/object/union.d.ts +9 -0
  118. package/module/Validate/object/union.js +27 -0
  119. package/module/Validate/object/union.js.map +1 -0
  120. package/module/Validate/parseEmail.js +6 -0
  121. package/module/Validate/parseEmail.js.map +1 -1
  122. package/module/Validate/string/uuid.d.ts +1 -5
  123. package/module/Validate/string/uuid.js +19 -2
  124. package/module/Validate/string/uuid.js.map +1 -1
  125. package/module/es5/Array/arraysJoin.js +20 -2
  126. package/module/es5/Array/sum.js +38 -4
  127. package/module/es5/Array/ultraNumberSort.js +31 -45
  128. package/module/es5/Array/zip.js +23 -17
  129. package/module/es5/Array/zipLongest.js +27 -14
  130. package/module/es5/Crypto/decodeBase32.js +11 -2
  131. package/module/es5/Crypto/decodeBase58.js +13 -6
  132. package/module/es5/Crypto/encodeBase32.js +12 -6
  133. package/module/es5/Crypto/encodeBase58.js +6 -2
  134. package/module/es5/DataStructure/priorityQueue.js +8 -3
  135. package/module/es5/IP/ipToBinaryString.js +2 -2
  136. package/module/es5/IP/longToIp.d.ts +1 -1
  137. package/module/es5/IP/longToIp.js +2 -13
  138. package/module/es5/Math/addition.js +4 -13
  139. package/module/es5/Math/multiplication.js +37 -6
  140. package/module/es5/Math/nCr.js +7 -2
  141. package/module/es5/Math/standardDeviation.js +25 -10
  142. package/module/es5/Math/subtract.js +12 -9
  143. package/module/es5/Object/deepClone.d.ts +10 -0
  144. package/module/es5/Object/deepClone.js +16 -6
  145. package/module/es5/Object/getObjectsCommon.d.ts +10 -0
  146. package/module/es5/Object/getObjectsCommon.js +10 -0
  147. package/module/es5/Object/getObjectsDiff.d.ts +10 -0
  148. package/module/es5/Object/getObjectsDiff.js +32 -17
  149. package/module/es5/Object/has.d.ts +10 -0
  150. package/module/es5/Object/has.js +10 -0
  151. package/module/es5/Object/index.d.ts +4 -0
  152. package/module/es5/Object/index.js +44 -0
  153. package/module/es5/Object/keyBy.d.ts +10 -0
  154. package/module/es5/Object/keyBy.js +10 -0
  155. package/module/es5/Object/mapKeys.d.ts +10 -0
  156. package/module/es5/Object/mapKeys.js +12 -1
  157. package/module/es5/Object/mapValues.d.ts +10 -0
  158. package/module/es5/Object/mapValues.js +10 -0
  159. package/module/es5/Object/merge.d.ts +10 -0
  160. package/module/es5/Object/merge.js +19 -1
  161. package/module/es5/Object/mergeDeep.d.ts +10 -0
  162. package/module/es5/Object/mergeDeep.js +34 -18
  163. package/module/es5/Object/pickDeep.d.ts +10 -0
  164. package/module/es5/Object/pickDeep.js +10 -3
  165. package/module/es5/Object/removePrototype.d.ts +15 -0
  166. package/module/es5/Object/removePrototype.js +31 -0
  167. package/module/es5/Object/removePrototypeDeep.d.ts +11 -0
  168. package/module/es5/Object/removePrototypeDeep.js +81 -0
  169. package/module/es5/Object/removePrototypeMap.d.ts +9 -0
  170. package/module/es5/Object/removePrototypeMap.js +20 -0
  171. package/module/es5/Object/removePrototypeMapDeep.d.ts +9 -0
  172. package/module/es5/Object/removePrototypeMapDeep.js +20 -0
  173. package/module/es5/String/escapeHtml.js +12 -3
  174. package/module/es5/String/formatString/applyFormatter.js +5 -5
  175. package/module/es5/String/formatString/getValue.js +4 -1
  176. package/module/es5/String/levenshteinDistance.js +43 -28
  177. package/module/es5/String/slugify.js +8 -1
  178. package/module/es5/String/trimEndCharacters.js +3 -1
  179. package/module/es5/String/trimStartCharacters.js +3 -1
  180. package/module/es5/String/unescapeHtml.d.ts +1 -1
  181. package/module/es5/String/unescapeHtml.js +46 -4
  182. package/module/es5/Tool/parseJson.js +14 -1
  183. package/module/es5/URL/buildUrl.js +4 -0
  184. package/module/es5/URL/parseQueryString.js +4 -0
  185. package/module/es5/Validate/isDeepEqual.js +48 -39
  186. package/module/es5/Validate/isPrimeNumber.js +14 -2
  187. package/module/es5/Validate/object/index.d.ts +2 -0
  188. package/module/es5/Validate/object/index.js +22 -0
  189. package/module/es5/Validate/object/intersection.d.ts +10 -0
  190. package/module/es5/Validate/object/intersection.js +34 -0
  191. package/module/es5/Validate/object/optional.d.ts +6 -0
  192. package/module/es5/Validate/object/optional.js +6 -0
  193. package/module/es5/Validate/object/union.d.ts +9 -0
  194. package/module/es5/Validate/object/union.js +36 -0
  195. package/module/es5/Validate/parseEmail.js +8 -0
  196. package/module/es5/Validate/string/uuid.d.ts +1 -5
  197. package/module/es5/Validate/string/uuid.js +24 -2
  198. package/package.json +33 -28
  199. package/module/es5/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Creates a new array of objects with prototype polluting properties removed
3
+ * from each item.
4
+ *
5
+ * @param objects - The objects to remove the prototype polluting properties
6
+ * from.
7
+ * @returns A new array with shallowly sanitized objects.
8
+ */
9
+ export declare const removePrototypeMap: <T extends Record<string, unknown>>(objects: readonly T[]) => Omit<T, "__proto__" | "constructor" | "prototype">[];
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.removePrototypeMap = void 0;
7
+ var _removePrototype = require("../Object/removePrototype");
8
+ /**
9
+ * Creates a new array of objects with prototype polluting properties removed
10
+ * from each item.
11
+ *
12
+ * @param objects - The objects to remove the prototype polluting properties
13
+ * from.
14
+ * @returns A new array with shallowly sanitized objects.
15
+ */
16
+ var removePrototypeMap = exports.removePrototypeMap = function removePrototypeMap(objects) {
17
+ return objects.map(function (object) {
18
+ return (0, _removePrototype.removePrototype)(object);
19
+ });
20
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Creates a new array of objects with prototype polluting properties removed
3
+ * recursively from each item.
4
+ *
5
+ * @param objects - The objects to remove the prototype polluting properties
6
+ * from recursively.
7
+ * @returns A new array with deeply sanitized objects.
8
+ */
9
+ export declare const removePrototypeMapDeep: <T extends Record<string, unknown>>(objects: readonly T[]) => T[];
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.removePrototypeMapDeep = void 0;
7
+ var _removePrototypeDeep = require("../Object/removePrototypeDeep");
8
+ /**
9
+ * Creates a new array of objects with prototype polluting properties removed
10
+ * recursively from each item.
11
+ *
12
+ * @param objects - The objects to remove the prototype polluting properties
13
+ * from recursively.
14
+ * @returns A new array with deeply sanitized objects.
15
+ */
16
+ var removePrototypeMapDeep = exports.removePrototypeMapDeep = function removePrototypeMapDeep(objects) {
17
+ return objects.map(function (object) {
18
+ return (0, _removePrototypeDeep.removePrototypeDeep)(object);
19
+ });
20
+ };
@@ -5,14 +5,23 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.escapeHtml = void 0;
7
7
  /**
8
- * HTML entities map for escaping
8
+ * HTML entities map for escaping.
9
+ *
10
+ * Security: The backtick (`) is included because it can be used as an HTML
11
+ * attribute delimiter in older browsers (e.g. IE), enabling XSS via
12
+ * constructs like <img src=`javascript:alert(1)`>. The forward slash (/)
13
+ * is included per OWASP XSS prevention recommendations to mitigate tag-
14
+ * closing injection (e.g. "</script>") when user input is embedded inside
15
+ * HTML elements.
9
16
  */
10
17
  var htmlEscapeMap = {
11
18
  "&": "&amp;",
12
19
  "<": "&lt;",
13
20
  ">": "&gt;",
14
21
  '"': "&quot;",
15
- "'": "&#39;"
22
+ "'": "&#39;",
23
+ "`": "&#x60;",
24
+ "/": "&#x2F;"
16
25
  };
17
26
 
18
27
  /**
@@ -21,7 +30,7 @@ var htmlEscapeMap = {
21
30
  * @returns The escaped string
22
31
  */
23
32
  var escapeHtml = exports.escapeHtml = function escapeHtml(string_) {
24
- return string_.replaceAll(/["&'<>]/g, function (match) {
33
+ return string_.replaceAll(/["&'/<>`]/g, function (match) {
25
34
  return htmlEscapeMap[match];
26
35
  });
27
36
  };
@@ -61,7 +61,7 @@ function applyFormatter(value, formatterString, formatters) {
61
61
  */
62
62
  function parseArguments(argumentsString) {
63
63
  var arguments_ = [];
64
- var current = "";
64
+ var chars = [];
65
65
  var inQuotes = false;
66
66
  var quoteChar = "";
67
67
  var _iterator = _createForOfIteratorHelper(argumentsString),
@@ -80,12 +80,12 @@ function parseArguments(argumentsString) {
80
80
  continue;
81
81
  }
82
82
  if (!inQuotes && _char === ",") {
83
- var _trimmed = current.trim();
83
+ var _trimmed = chars.join("").trim();
84
84
  arguments_.push(_trimmed === "" ? " " : _trimmed);
85
- current = "";
85
+ chars.length = 0;
86
86
  continue;
87
87
  }
88
- current += _char;
88
+ chars.push(_char);
89
89
  }
90
90
 
91
91
  // Handle last argument
@@ -94,7 +94,7 @@ function parseArguments(argumentsString) {
94
94
  } finally {
95
95
  _iterator.f();
96
96
  }
97
- var trimmed = current.trim();
97
+ var trimmed = chars.join("").trim();
98
98
  arguments_.push(trimmed === "" ? " " : trimmed);
99
99
  return arguments_;
100
100
  }
@@ -12,6 +12,9 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
12
12
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
13
13
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
14
14
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
15
+ // Pre-compiled regex pattern for array index notation to avoid recompilation per path segment
16
+ var ARRAY_INDEX_PATTERN = /^(.+?)\[(-?\d+)]$/;
17
+
15
18
  /**
16
19
  * Retrieves a value from an object using a dot-notation path with array index support.
17
20
  *
@@ -46,7 +49,7 @@ function getValue(object, path) {
46
49
  try {
47
50
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
48
51
  var part = _step.value;
49
- var arrayMatch = /^(.+?)\[(-?\d+)]$/.exec(part);
52
+ var arrayMatch = ARRAY_INDEX_PATTERN.exec(part);
50
53
  if (arrayMatch) {
51
54
  var _arrayMatch = _slicedToArray(arrayMatch, 3),
52
55
  key = _arrayMatch[1],
@@ -11,52 +11,67 @@ exports.levenshteinDistance = void 0;
11
11
  * @param string2 - Second string to compare
12
12
  * @returns The Levenshtein distance
13
13
  */
14
- var _levenshteinDistance = exports.levenshteinDistance = function levenshteinDistance(string1, string2) {
14
+ var levenshteinDistance = exports.levenshteinDistance = function levenshteinDistance(string1, string2) {
15
15
  if (string1 === string2) {
16
16
  return 0;
17
17
  }
18
- var length1 = string1.length;
19
- var length2 = string2.length;
20
- if (length1 === 0) {
21
- return length2;
18
+ var _short = string1;
19
+ var _long = string2;
20
+ var shortLength = _short.length;
21
+ var longLength = _long.length;
22
+ if (shortLength === 0) {
23
+ return longLength;
22
24
  }
23
- if (length2 === 0) {
24
- return length1;
25
+ if (longLength === 0) {
26
+ return shortLength;
25
27
  }
26
28
 
27
- // Ensure string1 is the shorter string to minimize space complexity to O(min(N, M))
28
- if (length1 > length2) {
29
- return _levenshteinDistance(string2, string1);
29
+ // Ensure short is the shorter string to minimize space complexity to O(min(N, M))
30
+ if (shortLength > longLength) {
31
+ _short = string2;
32
+ _long = string1;
33
+ shortLength = _short.length;
34
+ longLength = _long.length;
30
35
  }
31
36
 
32
37
  // Create a single row array to store distances
33
38
  // We only need the current row and the previous diagonal value
34
39
  var row = Array.from({
35
- length: length1 + 1
40
+ length: shortLength + 1
36
41
  });
37
42
 
38
- // Initialize first row (0 to length1)
39
- for (var index = 0; index <= length1; index++) {
43
+ // Initialize first row (0 to shortLength)
44
+ for (var index = 0; index <= shortLength; index++) {
40
45
  row[index] = index;
41
46
  }
42
47
 
43
- // Iterate through each character of string2
44
- for (var _index = 1; _index <= length2; _index++) {
45
- var previousDiagonal = row[0]; // Stores the value of matrix[i-1][j-1]
46
- row[0] = _index; // Update first element for the new row (matrix[0][j])
48
+ // Iterate through each character of the longer string (rows)
49
+ for (var rowIndex = 1; rowIndex <= longLength; rowIndex++) {
50
+ var previousDiagonal = row[0];
51
+ row[0] = rowIndex;
47
52
 
48
- var char2 = string2[_index - 1];
49
- for (var _index2 = 1; _index2 <= length1; _index2++) {
50
- var temporary = row[_index2]; // Store current value to become prevDiagonal for next iteration
51
- var cost = string1[_index2 - 1] === char2 ? 0 : 1;
52
- row[_index2] = Math.min(row[_index2] + 1,
53
- // deletion (value from previous row, same column)
54
- row[_index2 - 1] + 1,
55
- // insertion (value from current row, previous column)
56
- previousDiagonal + cost // substitution (value from previous row, previous column)
57
- );
53
+ // eslint-disable-next-line unicorn/prefer-code-point
54
+ var charCode = _long.charCodeAt(rowIndex - 1);
55
+ for (var colIndex = 1; colIndex <= shortLength; colIndex++) {
56
+ var temporary = row[colIndex];
57
+ // eslint-disable-next-line unicorn/prefer-code-point
58
+ var cost = _short.charCodeAt(colIndex - 1) === charCode ? 0 : 1;
59
+
60
+ // Inline min of three values instead of Math.min() call to avoid
61
+ // function-call overhead in this hot loop
62
+ var deletion = row[colIndex] + 1;
63
+ var insertion = row[colIndex - 1] + 1;
64
+ var substitution = previousDiagonal + cost;
65
+ var value = deletion;
66
+ if (insertion < value) {
67
+ value = insertion;
68
+ }
69
+ if (substitution < value) {
70
+ value = substitution;
71
+ }
72
+ row[colIndex] = value;
58
73
  previousDiagonal = temporary;
59
74
  }
60
75
  }
61
- return row[length1];
76
+ return row[shortLength];
62
77
  };
@@ -14,5 +14,12 @@ exports.slugify = void 0;
14
14
  * slugify("Japanese: こんにちは"); // "japanese"
15
15
  */
16
16
  var slugify = exports.slugify = function slugify(string_) {
17
- return string_.normalize("NFD").replaceAll(/[\u0300-\u036F]/g, "").toLowerCase().replaceAll(/[^\s\w-]/g, "-").replaceAll(/\s+/g, "-").replaceAll(/_+/g, "-").replaceAll(/-+/g, "-").replaceAll(/^-+|-+$/g, "");
17
+ return string_.normalize("NFD")
18
+ // Strip combining diacritical marks (e.g. accents)
19
+ .replaceAll(/[\u0300-\u036F]/g, "").toLowerCase()
20
+ // Consolidate non-word chars, whitespace, and underscores into a single
21
+ // hyphen in one pass instead of three separate regex scans
22
+ .replaceAll(/[^\w-]+|_+/g, "-")
23
+ // Collapse consecutive hyphens and strip leading/trailing hyphens
24
+ .replaceAll(/-+/g, "-").replaceAll(/^-|-$/g, "");
18
25
  };
@@ -18,8 +18,10 @@ exports.trimEndCharacters = void 0;
18
18
  * ```
19
19
  */
20
20
  var trimEndCharacters = exports.trimEndCharacters = function trimEndCharacters(string_, chars) {
21
+ // Use Set for O(1) character lookups instead of O(m) string.includes()
22
+ var charSet = new Set(chars);
21
23
  var endIndex = string_.length - 1;
22
- while (endIndex >= 0 && chars.includes(string_[endIndex])) {
24
+ while (endIndex >= 0 && charSet.has(string_[endIndex])) {
23
25
  endIndex--;
24
26
  }
25
27
  return string_.slice(0, endIndex + 1);
@@ -18,8 +18,10 @@ exports.trimStartCharacters = void 0;
18
18
  * ```
19
19
  */
20
20
  var trimStartCharacters = exports.trimStartCharacters = function trimStartCharacters(string_, chars) {
21
+ // Use Set for O(1) character lookups instead of O(m) string.includes()
22
+ var charSet = new Set(chars);
21
23
  var startIndex = 0;
22
- while (startIndex < string_.length && chars.includes(string_[startIndex])) {
24
+ while (startIndex < string_.length && charSet.has(string_[startIndex])) {
23
25
  startIndex++;
24
26
  }
25
27
  return string_.slice(startIndex);
@@ -5,7 +5,7 @@
5
5
  * @example
6
6
  * ```typescript
7
7
  * unescapeHtml("&lt;script&gt;alert(&quot;Hello&quot;);&lt;/script&gt;");
8
- * // Returns: "<script>alert("Hello");</script>"
8
+ * // Returns: "<script>alert(\"Hello\");</script>"
9
9
  *
10
10
  * unescapeHtml("Tom &amp; Jerry");
11
11
  * // Returns: "Tom & Jerry"
@@ -19,6 +19,34 @@ var htmlUnescapeMap = {
19
19
  "&#x3D;": "="
20
20
  };
21
21
 
22
+ /**
23
+ * Security: Checks whether a numeric code point is safe to decode.
24
+ * Rejects NULL (0), C0 control chars (1-31 except TAB 9, LF 10, CR 13),
25
+ * DEL (127), C1 control chars (128-159), lone surrogates (0xD800-0xDFFF),
26
+ * and values beyond the Unicode maximum (>0x10FFFF).
27
+ */
28
+ var isSafeCodePoint = function isSafeCodePoint(codePoint) {
29
+ if (codePoint > 0x10ffff) {
30
+ return false;
31
+ }
32
+ if (codePoint === 0) {
33
+ return false;
34
+ }
35
+ if (codePoint >= 0xd800 && codePoint <= 0xdfff) {
36
+ return false;
37
+ }
38
+ if (codePoint <= 0x1f && codePoint !== 0x09 && codePoint !== 0x0a && codePoint !== 0x0d) {
39
+ return false;
40
+ }
41
+ if (codePoint === 0x7f) {
42
+ return false;
43
+ }
44
+ if (codePoint >= 0x80 && codePoint <= 0x9f) {
45
+ return false;
46
+ }
47
+ return true;
48
+ };
49
+
22
50
  /**
23
51
  * Unescapes HTML entities in a string
24
52
  * @param string_ - The string to unescape
@@ -26,7 +54,7 @@ var htmlUnescapeMap = {
26
54
  * @example
27
55
  * ```typescript
28
56
  * unescapeHtml("&lt;script&gt;alert(&quot;Hello&quot;);&lt;/script&gt;");
29
- * // Returns: "<script>alert("Hello");</script>"
57
+ * // Returns: "<script>alert(\"Hello\");</script>"
30
58
  *
31
59
  * unescapeHtml("Tom &amp; Jerry");
32
60
  * // Returns: "Tom & Jerry"
@@ -36,15 +64,29 @@ var htmlUnescapeMap = {
36
64
  * ```
37
65
  */
38
66
  var unescapeHtml = exports.unescapeHtml = function unescapeHtml(string_) {
39
- var entityRegex = /&(?:amp|lt|gt|quot|#39|#x27|#x2F|#x60|#x3D);|&#(\d*);|&#x([\dA-Fa-f]*);/g;
67
+ var entityRegex = /&(?:amp|lt|gt|quot|#39|#x27|#x2F|#x60|#x3D);|&#(\d{1,7});|&#x([\dA-Fa-f]{1,6});/g;
40
68
  return string_.replaceAll(entityRegex, function (match, dec, hex) {
41
69
  if (dec !== undefined) {
42
70
  var codePoint = Number.parseInt(dec, 10);
43
- return Number.isNaN(codePoint) ? match : String.fromCodePoint(codePoint);
71
+ // Security: reject dangerous code points to prevent injection attacks.
72
+ // NULL bytes (0) enable null-byte injection that can truncate strings in
73
+ // downstream systems. C0 control chars (1-31 except TAB/LF/CR) and the
74
+ // DEL char (127) can break parsers. C1 control chars (128-159) are
75
+ // invalid in HTML. Surrogate code points (0xD800-0xDFFF) produce
76
+ // malformed strings. Out-of-range values (>0x10FFFF) are not valid
77
+ // Unicode. Leave these entity references unmodified rather than decoding
78
+ // them into potentially dangerous characters.
79
+ if (!isSafeCodePoint(codePoint)) {
80
+ return match;
81
+ }
82
+ return String.fromCodePoint(codePoint);
44
83
  }
45
84
  if (hex !== undefined) {
46
85
  var _codePoint = Number.parseInt(hex, 16);
47
- return Number.isNaN(_codePoint) ? match : String.fromCodePoint(_codePoint);
86
+ if (!isSafeCodePoint(_codePoint)) {
87
+ return match;
88
+ }
89
+ return String.fromCodePoint(_codePoint);
48
90
  }
49
91
  return htmlUnescapeMap[match];
50
92
  });
@@ -4,6 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.parseJson = void 0;
7
+ // Security: Keys that must be stripped during JSON parsing to prevent
8
+ // prototype pollution. If an attacker controls the JSON input, they can
9
+ // embed keys like "__proto__" which, when the parsed object is later
10
+ // spread or merged (e.g. via Object.assign, spread operator, or any
11
+ // deep-merge utility), can overwrite properties on Object.prototype
12
+ // and affect all objects in the runtime.
13
+ var DANGEROUS_KEYS = new Set(["__proto__", "constructor", "prototype"]);
14
+
7
15
  /**
8
16
  * Parses a JSON string into a typed JavaScript value
9
17
  * @template T The expected type of the parsed value (defaults to unknown)
@@ -12,5 +20,10 @@ exports.parseJson = void 0;
12
20
  * @throws {SyntaxError} If the JSON string is invalid
13
21
  */
14
22
  var parseJson = exports.parseJson = function parseJson(json) {
15
- return JSON.parse(json);
23
+ return JSON.parse(json, function (key, value) {
24
+ if (DANGEROUS_KEYS.has(key)) {
25
+ return;
26
+ }
27
+ return value;
28
+ });
16
29
  };
@@ -25,6 +25,10 @@ var buildUrl = exports.buildUrl = function buildUrl(base) {
25
25
  var url = new URL(base);
26
26
  for (var _i = 0, _Object$keys = Object.keys(parameters); _i < _Object$keys.length; _i++) {
27
27
  var key = _Object$keys[_i];
28
+ // Prevent prototype pollution by rejecting dangerous keys
29
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
30
+ continue;
31
+ }
28
32
  url.searchParams.append(key, parameters[key]);
29
33
  }
30
34
  return url.toString();
@@ -46,6 +46,10 @@ var parseQueryString = exports.parseQueryString = function parseQueryString(quer
46
46
  var _step$value = _slicedToArray(_step.value, 2),
47
47
  key = _step$value[0],
48
48
  value = _step$value[1];
49
+ // Prevent prototype pollution by rejecting dangerous keys
50
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
51
+ continue;
52
+ }
49
53
  result[key] = value;
50
54
  }
51
55
  } catch (err) {
@@ -4,10 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.isDeepEqual = isDeepEqual;
7
- function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
8
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
- function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
10
- function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
11
7
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
12
8
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
9
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
@@ -93,19 +89,32 @@ function isDeepEqual(a, b) {
93
89
  _iterator.f();
94
90
  }
95
91
  } else {
96
- var yCopy = _toConsumableArray(y);
92
+ // Performance: Use Set<number> to track matched indices instead of
93
+ // splice(), avoiding O(n) array shifts per removal (O(n²) → O(n)).
94
+ var usedIndices = new Set();
97
95
  var _iterator2 = _createForOfIteratorHelper(x),
98
96
  _step2;
99
97
  try {
100
98
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
101
99
  var itemX = _step2.value;
102
100
  var found = false;
103
- for (var _index = 0; _index < yCopy.length; _index++) {
104
- if (compare(itemX, yCopy[_index])) {
105
- yCopy.splice(_index, 1);
106
- found = true;
107
- break;
101
+ var _iterator3 = _createForOfIteratorHelper(y.entries()),
102
+ _step3;
103
+ try {
104
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
105
+ var _step3$value = _slicedToArray(_step3.value, 2),
106
+ _index = _step3$value[0],
107
+ itemY = _step3$value[1];
108
+ if (!usedIndices.has(_index) && compare(itemX, itemY)) {
109
+ usedIndices.add(_index);
110
+ found = true;
111
+ break;
112
+ }
108
113
  }
114
+ } catch (err) {
115
+ _iterator3.e(err);
116
+ } finally {
117
+ _iterator3.f();
109
118
  }
110
119
  if (!found) {
111
120
  return false;
@@ -116,7 +125,7 @@ function isDeepEqual(a, b) {
116
125
  } finally {
117
126
  _iterator2.f();
118
127
  }
119
- return yCopy.length === 0;
128
+ return usedIndices.size === y.length;
120
129
  }
121
130
  return true;
122
131
  }
@@ -124,35 +133,35 @@ function isDeepEqual(a, b) {
124
133
  if (x.size !== y.size) {
125
134
  return false;
126
135
  }
127
- var _iterator3 = _createForOfIteratorHelper(x),
128
- _step3;
136
+ var _iterator4 = _createForOfIteratorHelper(x),
137
+ _step4;
129
138
  try {
130
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
131
- var item = _step3.value;
139
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
140
+ var item = _step4.value;
132
141
  var _found = false;
133
- var _iterator4 = _createForOfIteratorHelper(y),
134
- _step4;
142
+ var _iterator5 = _createForOfIteratorHelper(y),
143
+ _step5;
135
144
  try {
136
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
137
- var otherItem = _step4.value;
145
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
146
+ var otherItem = _step5.value;
138
147
  if (compare(item, otherItem)) {
139
148
  _found = true;
140
149
  break;
141
150
  }
142
151
  }
143
152
  } catch (err) {
144
- _iterator4.e(err);
153
+ _iterator5.e(err);
145
154
  } finally {
146
- _iterator4.f();
155
+ _iterator5.f();
147
156
  }
148
157
  if (!_found) {
149
158
  return false;
150
159
  }
151
160
  }
152
161
  } catch (err) {
153
- _iterator3.e(err);
162
+ _iterator4.e(err);
154
163
  } finally {
155
- _iterator3.f();
164
+ _iterator4.f();
156
165
  }
157
166
  return true;
158
167
  }
@@ -160,39 +169,39 @@ function isDeepEqual(a, b) {
160
169
  if (x.size !== y.size) {
161
170
  return false;
162
171
  }
163
- var _iterator5 = _createForOfIteratorHelper(x),
164
- _step5;
172
+ var _iterator6 = _createForOfIteratorHelper(x),
173
+ _step6;
165
174
  try {
166
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
167
- var _step5$value = _slicedToArray(_step5.value, 2),
168
- key = _step5$value[0],
169
- value = _step5$value[1];
175
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
176
+ var _step6$value = _slicedToArray(_step6.value, 2),
177
+ key = _step6$value[0],
178
+ value = _step6$value[1];
170
179
  var _found2 = false;
171
- var _iterator6 = _createForOfIteratorHelper(y),
172
- _step6;
180
+ var _iterator7 = _createForOfIteratorHelper(y),
181
+ _step7;
173
182
  try {
174
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
175
- var _step6$value = _slicedToArray(_step6.value, 2),
176
- otherKey = _step6$value[0],
177
- otherValue = _step6$value[1];
183
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
184
+ var _step7$value = _slicedToArray(_step7.value, 2),
185
+ otherKey = _step7$value[0],
186
+ otherValue = _step7$value[1];
178
187
  if (compare(key, otherKey) && compare(value, otherValue)) {
179
188
  _found2 = true;
180
189
  break;
181
190
  }
182
191
  }
183
192
  } catch (err) {
184
- _iterator6.e(err);
193
+ _iterator7.e(err);
185
194
  } finally {
186
- _iterator6.f();
195
+ _iterator7.f();
187
196
  }
188
197
  if (!_found2) {
189
198
  return false;
190
199
  }
191
200
  }
192
201
  } catch (err) {
193
- _iterator5.e(err);
202
+ _iterator6.e(err);
194
203
  } finally {
195
- _iterator5.f();
204
+ _iterator6.f();
196
205
  }
197
206
  return true;
198
207
  }
@@ -18,8 +18,20 @@ var isPrimeNumber = exports.isPrimeNumber = function isPrimeNumber(n) {
18
18
  if (n <= 1 || !Number.isInteger(n)) {
19
19
  return false;
20
20
  }
21
- for (var index = 2; index <= Math.sqrt(n); index++) {
22
- if (n % index === 0) {
21
+
22
+ // Handle small primes and eliminate even numbers / multiples of 3 early
23
+ if (n <= 3) {
24
+ return true;
25
+ }
26
+ if (n % 2 === 0 || n % 3 === 0) {
27
+ return false;
28
+ }
29
+
30
+ // Performance: only test divisors of the form 6k +/- 1.
31
+ // All primes > 3 are of this form, so we skip ~2/3 of candidates
32
+ // compared to the naive loop that checks every integer from 2 to sqrt(n).
33
+ for (var index = 5; index * index <= n; index += 6) {
34
+ if (n % index === 0 || n % (index + 2) === 0) {
23
35
  return false;
24
36
  }
25
37
  }
@@ -1,2 +1,4 @@
1
1
  export * from "./core";
2
+ export * from "./intersection";
2
3
  export * from "./optional";
4
+ export * from "./union";
@@ -14,6 +14,17 @@ Object.keys(_core).forEach(function (key) {
14
14
  }
15
15
  });
16
16
  });
17
+ var _intersection = require("./intersection");
18
+ Object.keys(_intersection).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _intersection[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function get() {
24
+ return _intersection[key];
25
+ }
26
+ });
27
+ });
17
28
  var _optional = require("./optional");
18
29
  Object.keys(_optional).forEach(function (key) {
19
30
  if (key === "default" || key === "__esModule") return;
@@ -24,4 +35,15 @@ Object.keys(_optional).forEach(function (key) {
24
35
  return _optional[key];
25
36
  }
26
37
  });
38
+ });
39
+ var _union = require("./union");
40
+ Object.keys(_union).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _union[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function get() {
46
+ return _union[key];
47
+ }
48
+ });
27
49
  });