es-toolkit 1.18.0 → 1.19.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 (157) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/_chunk/{rest-CXt9w3.js → curry-BmwJrK.js} +21 -0
  3. package/dist/_chunk/{isWeakSet-CogETi.js → isWeakSet-E_VMwB.js} +9 -3
  4. package/dist/_chunk/range-BXlMmn.js +68 -0
  5. package/dist/_chunk/{toMerged-DN1PPP.js → toMerged-Bzkqyz.js} +28 -46
  6. package/dist/_chunk/{zipWith-CYaH1Y.js → zipWith-B-5AMf.js} +1 -1
  7. package/dist/array/forEachRight.d.mts +23 -0
  8. package/dist/array/forEachRight.d.ts +23 -0
  9. package/dist/array/groupBy.mjs +1 -1
  10. package/dist/array/index.js +1 -1
  11. package/dist/array/orderBy.d.mts +1 -1
  12. package/dist/array/orderBy.d.ts +1 -1
  13. package/dist/array/sortBy.d.mts +1 -1
  14. package/dist/array/sortBy.d.ts +1 -1
  15. package/dist/array/unzip.d.mts +1 -1
  16. package/dist/array/unzip.d.ts +1 -1
  17. package/dist/array/zipObject.d.mts +1 -1
  18. package/dist/array/zipObject.d.ts +1 -1
  19. package/dist/browser.global.js +1 -1
  20. package/dist/browser.global.js.map +1 -1
  21. package/dist/compat/_internal/decimalAdjust.mjs +19 -0
  22. package/dist/compat/_internal/isDeepKey.mjs +1 -3
  23. package/dist/compat/_internal/normalizeForCase.mjs +5 -4
  24. package/dist/compat/_internal/toKey.mjs +2 -7
  25. package/dist/compat/array/flatten.d.mts +1 -1
  26. package/dist/compat/array/flatten.d.ts +1 -1
  27. package/dist/compat/array/flattenDepth.d.mts +1 -1
  28. package/dist/compat/array/flattenDepth.d.ts +1 -1
  29. package/dist/compat/array/indexOf.d.mts +1 -1
  30. package/dist/compat/array/indexOf.d.ts +1 -1
  31. package/dist/compat/array/orderBy.d.mts +1 -1
  32. package/dist/compat/array/orderBy.d.ts +1 -1
  33. package/dist/compat/array/orderBy.mjs +1 -1
  34. package/dist/compat/array/size.d.mts +1 -1
  35. package/dist/compat/array/size.d.ts +1 -1
  36. package/dist/compat/array/sortBy.d.mts +1 -1
  37. package/dist/compat/array/sortBy.d.ts +1 -1
  38. package/dist/compat/array/zipObjectDeep.d.mts +1 -1
  39. package/dist/compat/array/zipObjectDeep.d.ts +1 -1
  40. package/dist/compat/index.d.mts +20 -7
  41. package/dist/compat/index.d.ts +20 -7
  42. package/dist/compat/index.js +459 -137
  43. package/dist/compat/index.mjs +20 -7
  44. package/dist/compat/math/ceil.d.mts +15 -0
  45. package/dist/compat/math/ceil.d.ts +15 -0
  46. package/dist/compat/math/ceil.mjs +7 -0
  47. package/dist/compat/math/floor.d.mts +15 -0
  48. package/dist/compat/math/floor.d.ts +15 -0
  49. package/dist/compat/math/floor.mjs +7 -0
  50. package/dist/compat/math/round.d.mts +15 -0
  51. package/dist/compat/math/round.d.ts +15 -0
  52. package/dist/compat/math/round.mjs +7 -0
  53. package/dist/compat/object/fromPairs.d.mts +2 -2
  54. package/dist/compat/object/fromPairs.d.ts +2 -2
  55. package/dist/compat/object/get.d.mts +12 -12
  56. package/dist/compat/object/get.d.ts +12 -12
  57. package/dist/compat/object/get.mjs +54 -17
  58. package/dist/compat/object/has.mjs +1 -1
  59. package/dist/compat/object/mergeWith.mjs +14 -2
  60. package/dist/compat/object/omit.d.mts +34 -0
  61. package/dist/compat/object/omit.d.ts +34 -0
  62. package/dist/compat/object/omit.mjs +33 -0
  63. package/dist/compat/object/pick.d.mts +47 -0
  64. package/dist/compat/object/pick.d.ts +47 -0
  65. package/dist/compat/object/pick.mjs +38 -0
  66. package/dist/compat/object/set.mjs +1 -1
  67. package/dist/compat/object/unset.d.mts +20 -0
  68. package/dist/compat/object/unset.d.ts +20 -0
  69. package/dist/compat/object/unset.mjs +68 -0
  70. package/dist/compat/predicate/isInteger.d.mts +17 -0
  71. package/dist/compat/predicate/isInteger.d.ts +17 -0
  72. package/dist/compat/predicate/isInteger.mjs +5 -0
  73. package/dist/compat/predicate/isMatch.mjs +44 -4
  74. package/dist/compat/predicate/isNil.mjs +5 -0
  75. package/dist/compat/predicate/isObject.d.mts +4 -4
  76. package/dist/compat/predicate/isObject.d.ts +4 -4
  77. package/dist/compat/predicate/isSafeInteger.d.mts +20 -0
  78. package/dist/compat/predicate/isSafeInteger.d.ts +20 -0
  79. package/dist/compat/predicate/isSafeInteger.mjs +5 -0
  80. package/dist/compat/predicate/matchesProperty.mjs +12 -1
  81. package/dist/compat/string/kebabCase.d.mts +17 -0
  82. package/dist/compat/string/kebabCase.d.ts +17 -0
  83. package/dist/compat/string/kebabCase.mjs +9 -0
  84. package/dist/compat/string/lowerCase.d.mts +17 -0
  85. package/dist/compat/string/lowerCase.d.ts +17 -0
  86. package/dist/compat/string/lowerCase.mjs +8 -0
  87. package/dist/compat/string/snakeCase.d.mts +17 -0
  88. package/dist/compat/string/snakeCase.d.ts +17 -0
  89. package/dist/compat/string/snakeCase.mjs +8 -0
  90. package/dist/compat/string/startCase.d.mts +16 -0
  91. package/dist/compat/string/startCase.d.ts +16 -0
  92. package/dist/compat/string/startCase.mjs +8 -0
  93. package/dist/compat/string/trim.d.mts +16 -0
  94. package/dist/compat/string/trim.d.ts +16 -0
  95. package/dist/compat/string/trim.mjs +25 -0
  96. package/dist/compat/string/trimEnd.d.mts +17 -0
  97. package/dist/compat/string/trimEnd.d.ts +17 -0
  98. package/dist/compat/string/trimEnd.mjs +25 -0
  99. package/dist/compat/string/trimStart.d.mts +17 -0
  100. package/dist/compat/string/trimStart.d.ts +17 -0
  101. package/dist/compat/string/trimStart.mjs +25 -0
  102. package/dist/compat/util/toPath.d.mts +20 -0
  103. package/dist/compat/util/toPath.d.ts +20 -0
  104. package/dist/compat/util/toPath.mjs +37 -0
  105. package/dist/compat/util/toString.d.mts +19 -0
  106. package/dist/compat/util/toString.d.ts +19 -0
  107. package/dist/compat/util/toString.mjs +15 -0
  108. package/dist/function/curry.d.mts +127 -0
  109. package/dist/function/curry.d.ts +127 -0
  110. package/dist/function/curry.mjs +21 -0
  111. package/dist/function/index.d.mts +1 -0
  112. package/dist/function/index.d.ts +1 -0
  113. package/dist/function/index.js +15 -14
  114. package/dist/function/index.mjs +1 -0
  115. package/dist/index.d.mts +6 -0
  116. package/dist/index.d.ts +6 -0
  117. package/dist/index.js +40 -33
  118. package/dist/index.mjs +6 -0
  119. package/dist/math/index.js +8 -66
  120. package/dist/object/clone.mjs +28 -25
  121. package/dist/object/index.js +19 -3
  122. package/dist/object/pick.d.mts +1 -1
  123. package/dist/object/pick.d.ts +1 -1
  124. package/dist/predicate/index.d.mts +1 -0
  125. package/dist/predicate/index.d.ts +1 -0
  126. package/dist/predicate/index.js +6 -5
  127. package/dist/predicate/index.mjs +1 -0
  128. package/dist/predicate/isDate.d.mts +16 -0
  129. package/dist/predicate/isDate.d.ts +16 -0
  130. package/dist/predicate/isDate.mjs +5 -0
  131. package/dist/predicate/isNotNil.mjs +1 -1
  132. package/dist/string/capitalize.d.mts +1 -0
  133. package/dist/string/capitalize.d.ts +1 -0
  134. package/dist/string/index.d.mts +4 -0
  135. package/dist/string/index.d.ts +4 -0
  136. package/dist/string/index.js +65 -0
  137. package/dist/string/index.mjs +4 -0
  138. package/dist/string/startCase.d.mts +1 -1
  139. package/dist/string/startCase.d.ts +1 -1
  140. package/dist/string/trim.d.mts +15 -0
  141. package/dist/string/trim.d.ts +15 -0
  142. package/dist/string/trim.mjs +11 -0
  143. package/dist/string/trimEnd.d.mts +16 -0
  144. package/dist/string/trimEnd.d.ts +16 -0
  145. package/dist/string/trimEnd.mjs +22 -0
  146. package/dist/string/trimStart.d.mts +16 -0
  147. package/dist/string/trimStart.d.ts +16 -0
  148. package/dist/string/trimStart.mjs +22 -0
  149. package/dist/string/upperCase.d.mts +17 -0
  150. package/dist/string/upperCase.d.ts +17 -0
  151. package/dist/string/upperCase.mjs +15 -0
  152. package/package.json +1 -1
  153. package/dist/compat/_internal/isArrayMatch.mjs +0 -24
  154. package/dist/compat/_internal/isMapMatch.mjs +0 -18
  155. package/dist/compat/_internal/isSetMatch.mjs +0 -13
  156. package/dist/compat/_internal/toPath.mjs +0 -40
  157. package/dist/_chunk/{isTypedArray-Dsrnb1.js → isPlainObject-BIekvL.js} +8 -8
@@ -30,6 +30,18 @@ function kebabCase(str) {
30
30
  return words.map(word => word.toLowerCase()).join('-');
31
31
  }
32
32
 
33
+ function upperCase(str) {
34
+ const words = getWords(str);
35
+ let result = '';
36
+ for (let i = 0; i < words.length; i++) {
37
+ result += words[i].toUpperCase();
38
+ if (i < words.length - 1) {
39
+ result += ' ';
40
+ }
41
+ }
42
+ return result;
43
+ }
44
+
33
45
  function lowerCase(str) {
34
46
  const words = getWords(str);
35
47
  return words.map(word => word.toLowerCase()).join(' ');
@@ -57,6 +69,55 @@ function pascalCase(str) {
57
69
  return words.map(word => capitalize(word)).join('');
58
70
  }
59
71
 
72
+ function trimStart(str, chars) {
73
+ if (chars === undefined) {
74
+ return str.trimStart();
75
+ }
76
+ let startIndex = 0;
77
+ switch (typeof chars) {
78
+ case 'string': {
79
+ while (startIndex < str.length && str[startIndex] === chars) {
80
+ startIndex++;
81
+ }
82
+ break;
83
+ }
84
+ case 'object': {
85
+ while (startIndex < str.length && chars.includes(str[startIndex])) {
86
+ startIndex++;
87
+ }
88
+ }
89
+ }
90
+ return str.substring(startIndex);
91
+ }
92
+
93
+ function trimEnd(str, chars) {
94
+ if (chars === undefined) {
95
+ return str.trimEnd();
96
+ }
97
+ let endIndex = str.length;
98
+ switch (typeof chars) {
99
+ case 'string': {
100
+ while (endIndex > 0 && str[endIndex - 1] === chars) {
101
+ endIndex--;
102
+ }
103
+ break;
104
+ }
105
+ case 'object': {
106
+ while (endIndex > 0 && chars.includes(str[endIndex - 1])) {
107
+ endIndex--;
108
+ }
109
+ }
110
+ }
111
+ return str.substring(0, endIndex);
112
+ }
113
+
114
+ function trim(str, chars) {
115
+ if (chars === undefined) {
116
+ return str.trim();
117
+ }
118
+ return trimStart(trimEnd(str, chars), chars);
119
+ }
120
+
60
121
  function upperFirst(str) {
61
122
  return str.substring(0, 1).toUpperCase() + str.substring(1);
62
123
  }
@@ -151,5 +212,9 @@ exports.pad = pad;
151
212
  exports.pascalCase = pascalCase;
152
213
  exports.snakeCase = snakeCase;
153
214
  exports.startCase = startCase;
215
+ exports.trim = trim;
216
+ exports.trimEnd = trimEnd;
217
+ exports.trimStart = trimStart;
154
218
  exports.unescape = unescape;
219
+ exports.upperCase = upperCase;
155
220
  exports.upperFirst = upperFirst;
@@ -1,10 +1,14 @@
1
1
  export { camelCase } from './camelCase.mjs';
2
2
  export { snakeCase } from './snakeCase.mjs';
3
3
  export { kebabCase } from './kebabCase.mjs';
4
+ export { upperCase } from './upperCase.mjs';
4
5
  export { lowerCase } from './lowerCase.mjs';
5
6
  export { startCase } from './startCase.mjs';
6
7
  export { capitalize } from './capitalize.mjs';
7
8
  export { pascalCase } from './pascalCase.mjs';
9
+ export { trim } from './trim.mjs';
10
+ export { trimStart } from './trimStart.mjs';
11
+ export { trimEnd } from './trimEnd.mjs';
8
12
  export { upperFirst } from './upperFirst.mjs';
9
13
  export { lowerFirst } from './lowerFirst.mjs';
10
14
  export { deburr } from './deburr.mjs';
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * @example
9
9
  * const result1 = startCase('hello world'); // result will be 'Hello World'
10
- * const result2 = startCase('HELLO WORLD'); // result will be 'Hello World'
10
+ * const result2 = startCase('HELLO WORLD'); // result will be 'HELLO WORLD'
11
11
  * const result3 = startCase('hello-world'); // result will be 'Hello World'
12
12
  * const result4 = startCase('hello_world'); // result will be 'Hello World'
13
13
  */
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * @example
9
9
  * const result1 = startCase('hello world'); // result will be 'Hello World'
10
- * const result2 = startCase('HELLO WORLD'); // result will be 'Hello World'
10
+ * const result2 = startCase('HELLO WORLD'); // result will be 'HELLO WORLD'
11
11
  * const result3 = startCase('hello-world'); // result will be 'Hello World'
12
12
  * const result4 = startCase('hello_world'); // result will be 'Hello World'
13
13
  */
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Removes leading and trailing whitespace or specified characters from a string.
3
+ *
4
+ * @param {string} str - The string from which characters will be trimmed.
5
+ * @param {string | string[]} chars - The character(s) to remove from the string. Can be a single character or an array of characters.
6
+ * @returns {string} - The resulting string after the specified characters have been removed.
7
+ *
8
+ * @example
9
+ * trim(" hello "); // "hello"
10
+ * trim("--hello--", "-"); // "hello"
11
+ * trim("##hello##", ["#", "o"]); // "hell"
12
+ */
13
+ declare function trim(str: string, chars?: string | string[]): string;
14
+
15
+ export { trim };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Removes leading and trailing whitespace or specified characters from a string.
3
+ *
4
+ * @param {string} str - The string from which characters will be trimmed.
5
+ * @param {string | string[]} chars - The character(s) to remove from the string. Can be a single character or an array of characters.
6
+ * @returns {string} - The resulting string after the specified characters have been removed.
7
+ *
8
+ * @example
9
+ * trim(" hello "); // "hello"
10
+ * trim("--hello--", "-"); // "hello"
11
+ * trim("##hello##", ["#", "o"]); // "hell"
12
+ */
13
+ declare function trim(str: string, chars?: string | string[]): string;
14
+
15
+ export { trim };
@@ -0,0 +1,11 @@
1
+ import { trimStart } from './trimStart.mjs';
2
+ import { trimEnd } from './trimEnd.mjs';
3
+
4
+ function trim(str, chars) {
5
+ if (chars === undefined) {
6
+ return str.trim();
7
+ }
8
+ return trimStart(trimEnd(str, chars), chars);
9
+ }
10
+
11
+ export { trim };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Removes trailing whitespace or specified characters from a string.
3
+ *
4
+ * @param {string} str - The string from which trailing characters will be trimmed.
5
+ * @param {string | string[]} chars - The character(s) to remove from the end of the string.
6
+ * @returns {string} - The resulting string after the specified trailing character has been removed.
7
+ *
8
+ * @example
9
+ * const trimmedStr1 = trimEnd('hello---', '-') // returns 'hello'
10
+ * const trimmedStr2 = trimEnd('123000', '0') // returns '123'
11
+ * const trimmedStr3 = trimEnd('abcabcabc', 'c') // returns 'abcabcab'
12
+ * const trimmedStr4 = trimEnd('trimmedxxx', 'x') // returns 'trimmed'
13
+ */
14
+ declare function trimEnd(str: string, chars?: string | string[]): string;
15
+
16
+ export { trimEnd };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Removes trailing whitespace or specified characters from a string.
3
+ *
4
+ * @param {string} str - The string from which trailing characters will be trimmed.
5
+ * @param {string | string[]} chars - The character(s) to remove from the end of the string.
6
+ * @returns {string} - The resulting string after the specified trailing character has been removed.
7
+ *
8
+ * @example
9
+ * const trimmedStr1 = trimEnd('hello---', '-') // returns 'hello'
10
+ * const trimmedStr2 = trimEnd('123000', '0') // returns '123'
11
+ * const trimmedStr3 = trimEnd('abcabcabc', 'c') // returns 'abcabcab'
12
+ * const trimmedStr4 = trimEnd('trimmedxxx', 'x') // returns 'trimmed'
13
+ */
14
+ declare function trimEnd(str: string, chars?: string | string[]): string;
15
+
16
+ export { trimEnd };
@@ -0,0 +1,22 @@
1
+ function trimEnd(str, chars) {
2
+ if (chars === undefined) {
3
+ return str.trimEnd();
4
+ }
5
+ let endIndex = str.length;
6
+ switch (typeof chars) {
7
+ case 'string': {
8
+ while (endIndex > 0 && str[endIndex - 1] === chars) {
9
+ endIndex--;
10
+ }
11
+ break;
12
+ }
13
+ case 'object': {
14
+ while (endIndex > 0 && chars.includes(str[endIndex - 1])) {
15
+ endIndex--;
16
+ }
17
+ }
18
+ }
19
+ return str.substring(0, endIndex);
20
+ }
21
+
22
+ export { trimEnd };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Removes leading whitespace or specified characters from a string.
3
+ *
4
+ * @param {string} str - The string from which leading characters will be trimmed.
5
+ * @param {string | string[]} chars - The character(s) to remove from the end of the string.
6
+ * @returns {string} - The resulting string after the specified leading character has been removed.
7
+ *
8
+ * @example
9
+ * const trimmedStr1 = trimStart('---hello', '-') // returns 'hello'
10
+ * const trimmedStr2 = trimStart('000123', '0') // returns '123'
11
+ * const trimmedStr3 = trimStart('abcabcabc', 'a') // returns 'bcabcabc'
12
+ * const trimmedStr4 = trimStart('xxxtrimmed', 'x') // returns 'trimmed'
13
+ */
14
+ declare function trimStart(str: string, chars?: string | string[]): string;
15
+
16
+ export { trimStart };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Removes leading whitespace or specified characters from a string.
3
+ *
4
+ * @param {string} str - The string from which leading characters will be trimmed.
5
+ * @param {string | string[]} chars - The character(s) to remove from the end of the string.
6
+ * @returns {string} - The resulting string after the specified leading character has been removed.
7
+ *
8
+ * @example
9
+ * const trimmedStr1 = trimStart('---hello', '-') // returns 'hello'
10
+ * const trimmedStr2 = trimStart('000123', '0') // returns '123'
11
+ * const trimmedStr3 = trimStart('abcabcabc', 'a') // returns 'bcabcabc'
12
+ * const trimmedStr4 = trimStart('xxxtrimmed', 'x') // returns 'trimmed'
13
+ */
14
+ declare function trimStart(str: string, chars?: string | string[]): string;
15
+
16
+ export { trimStart };
@@ -0,0 +1,22 @@
1
+ function trimStart(str, chars) {
2
+ if (chars === undefined) {
3
+ return str.trimStart();
4
+ }
5
+ let startIndex = 0;
6
+ switch (typeof chars) {
7
+ case 'string': {
8
+ while (startIndex < str.length && str[startIndex] === chars) {
9
+ startIndex++;
10
+ }
11
+ break;
12
+ }
13
+ case 'object': {
14
+ while (startIndex < str.length && chars.includes(str[startIndex])) {
15
+ startIndex++;
16
+ }
17
+ }
18
+ }
19
+ return str.substring(startIndex);
20
+ }
21
+
22
+ export { trimStart };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Converts a string to upper case.
3
+ *
4
+ * Upper case is the naming convention in which each word is written in uppercase and separated by an space ( ) character.
5
+ *
6
+ * @param {string} str - The string that is to be changed to upper case.
7
+ * @returns {string} - The converted string to upper case.
8
+ *
9
+ * @example
10
+ * const convertedStr1 = upperCase('camelCase') // returns 'CAMEL CASE'
11
+ * const convertedStr2 = upperCase('some whitespace') // returns 'SOME WHITESPACE'
12
+ * const convertedStr3 = upperCase('hyphen-text') // returns 'HYPHEN TEXT'
13
+ * const convertedStr4 = upperCase('HTTPRequest') // returns 'HTTP REQUEST'
14
+ */
15
+ declare function upperCase(str: string): string;
16
+
17
+ export { upperCase };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Converts a string to upper case.
3
+ *
4
+ * Upper case is the naming convention in which each word is written in uppercase and separated by an space ( ) character.
5
+ *
6
+ * @param {string} str - The string that is to be changed to upper case.
7
+ * @returns {string} - The converted string to upper case.
8
+ *
9
+ * @example
10
+ * const convertedStr1 = upperCase('camelCase') // returns 'CAMEL CASE'
11
+ * const convertedStr2 = upperCase('some whitespace') // returns 'SOME WHITESPACE'
12
+ * const convertedStr3 = upperCase('hyphen-text') // returns 'HYPHEN TEXT'
13
+ * const convertedStr4 = upperCase('HTTPRequest') // returns 'HTTP REQUEST'
14
+ */
15
+ declare function upperCase(str: string): string;
16
+
17
+ export { upperCase };
@@ -0,0 +1,15 @@
1
+ import { getWords } from './_internal/getWords.mjs';
2
+
3
+ function upperCase(str) {
4
+ const words = getWords(str);
5
+ let result = '';
6
+ for (let i = 0; i < words.length; i++) {
7
+ result += words[i].toUpperCase();
8
+ if (i < words.length - 1) {
9
+ result += ' ';
10
+ }
11
+ }
12
+ return result;
13
+ }
14
+
15
+ export { upperCase };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "es-toolkit",
3
3
  "description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
4
- "version": "1.18.0",
4
+ "version": "1.19.0",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {
@@ -1,24 +0,0 @@
1
- import { isMatch } from '../predicate/isMatch.mjs';
2
-
3
- function isArrayMatch(target, source) {
4
- if (source.length === 0) {
5
- return true;
6
- }
7
- if (!Array.isArray(target)) {
8
- return false;
9
- }
10
- const countedIndex = new Set();
11
- for (let i = 0; i < source.length; i++) {
12
- const sourceItem = source[i];
13
- const index = target.findIndex((targetItem, index) => {
14
- return isMatch(targetItem, sourceItem) && !countedIndex.has(index);
15
- });
16
- if (index === -1) {
17
- return false;
18
- }
19
- countedIndex.add(index);
20
- }
21
- return true;
22
- }
23
-
24
- export { isArrayMatch };
@@ -1,18 +0,0 @@
1
- import { isMatch } from '../predicate/isMatch.mjs';
2
-
3
- function isMapMatch(target, source) {
4
- if (source.size === 0) {
5
- return true;
6
- }
7
- if (!(target instanceof Map)) {
8
- return false;
9
- }
10
- for (const [key, value] of source.entries()) {
11
- if (!isMatch(target.get(key), value)) {
12
- return false;
13
- }
14
- }
15
- return true;
16
- }
17
-
18
- export { isMapMatch };
@@ -1,13 +0,0 @@
1
- import { isArrayMatch } from './isArrayMatch.mjs';
2
-
3
- function isSetMatch(target, source) {
4
- if (source.size === 0) {
5
- return true;
6
- }
7
- if (!(target instanceof Set)) {
8
- return false;
9
- }
10
- return isArrayMatch([...target], [...source]);
11
- }
12
-
13
- export { isSetMatch };
@@ -1,40 +0,0 @@
1
- function toPath(deepKey) {
2
- const ESCAPE_REGEXP = /\\(\\)?/g;
3
- const PROPERTY_REGEXP = RegExp('[^.[\\]]+' +
4
- '|' +
5
- '\\[(?:' +
6
- '([^"\'][^[]*)' +
7
- '|' +
8
- '(["\'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2' +
9
- ')\\]' +
10
- '|' +
11
- '(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))', 'g');
12
- const result = [];
13
- if (deepKey[0] === '.') {
14
- result.push('');
15
- }
16
- let match;
17
- let lastIndex = 0;
18
- while ((match = PROPERTY_REGEXP.exec(deepKey)) !== null) {
19
- let key = match[0];
20
- const expr = match[1];
21
- const quote = match[2];
22
- const substr = match[3];
23
- if (quote) {
24
- key = substr.replace(ESCAPE_REGEXP, '$1');
25
- }
26
- else if (expr) {
27
- key = expr;
28
- }
29
- result.push(key);
30
- if (PROPERTY_REGEXP.lastIndex === lastIndex) {
31
- PROPERTY_REGEXP.lastIndex++;
32
- }
33
- else {
34
- lastIndex = PROPERTY_REGEXP.lastIndex;
35
- }
36
- }
37
- return result;
38
- }
39
-
40
- export { toPath };
@@ -1,5 +1,13 @@
1
1
  'use strict';
2
2
 
3
+ function isTypedArray(x) {
4
+ return ArrayBuffer.isView(x) && !(x instanceof DataView);
5
+ }
6
+
7
+ function isPrimitive(value) {
8
+ return value == null || (typeof value !== 'object' && typeof value !== 'function');
9
+ }
10
+
3
11
  function isPlainObject(object) {
4
12
  if (typeof object !== 'object') {
5
13
  return false;
@@ -20,14 +28,6 @@ function isPlainObject(object) {
20
28
  return Object.getPrototypeOf(object) === proto;
21
29
  }
22
30
 
23
- function isPrimitive(value) {
24
- return value == null || (typeof value !== 'object' && typeof value !== 'function');
25
- }
26
-
27
- function isTypedArray(x) {
28
- return ArrayBuffer.isView(x) && !(x instanceof DataView);
29
- }
30
-
31
31
  exports.isPlainObject = isPlainObject;
32
32
  exports.isPrimitive = isPrimitive;
33
33
  exports.isTypedArray = isTypedArray;