es-toolkit 1.26.1 → 1.27.0-dev.874

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 (109) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/_chunk/{sumBy-RVppiV.js → rangeRight-w3WrXN.js} +2 -14
  3. package/dist/_chunk/{toMerged-wNz52b.js → toMerged-CPY8Ug.js} +7 -1
  4. package/dist/_chunk/{upperFirst-BUECmK.js → upperFirst-DK_rTF.js} +23 -23
  5. package/dist/_chunk/{zipWith-Dkv3D1.js → zipWith-Bb2eZI.js} +19 -5
  6. package/dist/array/at.mjs +7 -2
  7. package/dist/array/index.d.mts +1 -0
  8. package/dist/array/index.d.ts +1 -0
  9. package/dist/array/index.js +2 -1
  10. package/dist/array/index.mjs +1 -0
  11. package/dist/array/isSubsetWith.d.mts +33 -0
  12. package/dist/array/isSubsetWith.d.ts +33 -0
  13. package/dist/array/isSubsetWith.mjs +7 -0
  14. package/dist/array/without.mjs +3 -2
  15. package/dist/array/zip.mjs +6 -1
  16. package/dist/browser.global.js +1 -1
  17. package/dist/browser.global.js.map +1 -1
  18. package/dist/compat/_internal/flattenArrayLike.mjs +17 -0
  19. package/dist/compat/_internal/isPrototype.mjs +7 -0
  20. package/dist/compat/_internal/toArray.mjs +5 -0
  21. package/dist/compat/array/chunk.mjs +2 -1
  22. package/dist/compat/array/difference.mjs +2 -1
  23. package/dist/compat/array/differenceBy.d.mts +82 -0
  24. package/dist/compat/array/differenceBy.d.ts +82 -0
  25. package/dist/compat/array/differenceBy.mjs +20 -0
  26. package/dist/compat/array/drop.mjs +2 -1
  27. package/dist/compat/array/dropRight.mjs +2 -1
  28. package/dist/compat/array/dropWhile.mjs +2 -1
  29. package/dist/compat/array/findLastIndex.mjs +2 -1
  30. package/dist/compat/array/forEach.d.mts +106 -0
  31. package/dist/compat/array/forEach.d.ts +106 -0
  32. package/dist/compat/array/forEach.mjs +21 -0
  33. package/dist/compat/array/head.mjs +2 -1
  34. package/dist/compat/array/last.mjs +2 -1
  35. package/dist/compat/array/sample.mjs +2 -1
  36. package/dist/compat/array/tail.mjs +2 -1
  37. package/dist/compat/array/take.mjs +2 -1
  38. package/dist/compat/array/takeRight.mjs +2 -1
  39. package/dist/compat/array/union.d.mts +30 -0
  40. package/dist/compat/array/union.d.ts +30 -0
  41. package/dist/compat/array/union.mjs +11 -0
  42. package/dist/compat/array/uniqBy.d.mts +60 -0
  43. package/dist/compat/array/uniqBy.d.ts +60 -0
  44. package/dist/compat/array/uniqBy.mjs +25 -0
  45. package/dist/compat/array/unzip.d.mts +16 -0
  46. package/dist/compat/array/unzip.d.ts +16 -0
  47. package/dist/compat/array/unzip.mjs +14 -0
  48. package/dist/compat/array/zip.d.mts +134 -0
  49. package/dist/compat/array/zip.d.ts +134 -0
  50. package/dist/compat/array/zip.mjs +11 -0
  51. package/dist/compat/index.d.mts +15 -8
  52. package/dist/compat/index.d.ts +15 -8
  53. package/dist/compat/index.js +312 -104
  54. package/dist/compat/index.mjs +15 -8
  55. package/dist/compat/math/sum.d.mts +37 -0
  56. package/dist/compat/math/sum.d.ts +37 -0
  57. package/dist/compat/math/sum.mjs +7 -0
  58. package/dist/compat/math/sumBy.d.mts +64 -0
  59. package/dist/compat/math/sumBy.d.ts +64 -0
  60. package/dist/compat/math/sumBy.mjs +20 -0
  61. package/dist/compat/predicate/isEmpty.d.mts +78 -0
  62. package/dist/compat/predicate/isEmpty.d.ts +78 -0
  63. package/dist/compat/predicate/isEmpty.mjs +33 -0
  64. package/dist/compat/string/replace.d.mts +17 -0
  65. package/dist/compat/string/replace.d.ts +17 -0
  66. package/dist/compat/string/replace.mjs +10 -0
  67. package/dist/compat/string/startCase.mjs +4 -4
  68. package/dist/compat/util/iteratee.d.mts +44 -0
  69. package/dist/compat/util/iteratee.d.ts +44 -0
  70. package/dist/compat/util/iteratee.mjs +28 -0
  71. package/dist/compat/util/toPath.mjs +56 -25
  72. package/dist/index.d.mts +3 -0
  73. package/dist/index.d.ts +3 -0
  74. package/dist/index.js +17 -14
  75. package/dist/index.mjs +3 -0
  76. package/dist/math/index.js +19 -11
  77. package/dist/math/range.mjs +1 -4
  78. package/dist/math/rangeRight.mjs +1 -4
  79. package/dist/math/sumBy.mjs +5 -4
  80. package/dist/object/cloneDeep.mjs +1 -1
  81. package/dist/object/findKey.d.mts +21 -0
  82. package/dist/object/findKey.d.ts +21 -0
  83. package/dist/object/findKey.mjs +6 -0
  84. package/dist/object/index.d.mts +1 -0
  85. package/dist/object/index.d.ts +1 -0
  86. package/dist/object/index.js +2 -1
  87. package/dist/object/index.mjs +1 -0
  88. package/dist/object/mapKeys.d.mts +4 -5
  89. package/dist/object/mapKeys.d.ts +4 -5
  90. package/dist/object/mergeWith.d.mts +1 -1
  91. package/dist/object/mergeWith.d.ts +1 -1
  92. package/dist/object/toMerged.d.mts +1 -1
  93. package/dist/object/toMerged.d.ts +1 -1
  94. package/dist/string/camelCase.mjs +4 -4
  95. package/dist/string/constantCase.mjs +3 -3
  96. package/dist/string/index.d.mts +1 -0
  97. package/dist/string/index.d.ts +1 -0
  98. package/dist/string/index.js +3 -2
  99. package/dist/string/index.mjs +1 -0
  100. package/dist/string/kebabCase.mjs +3 -3
  101. package/dist/string/lowerCase.mjs +3 -3
  102. package/dist/string/pascalCase.mjs +3 -3
  103. package/dist/string/snakeCase.mjs +3 -3
  104. package/dist/string/startCase.mjs +4 -4
  105. package/dist/string/upperCase.mjs +5 -5
  106. package/dist/string/words.d.mts +20 -0
  107. package/dist/string/words.d.ts +20 -0
  108. package/dist/string/{_internal/getWords.mjs → words.mjs} +2 -2
  109. package/package.json +1 -1
@@ -1,6 +1,5 @@
1
1
  export { at } from '../array/at.mjs';
2
2
  export { countBy } from '../array/countBy.mjs';
3
- export { differenceBy } from '../array/differenceBy.mjs';
4
3
  export { differenceWith } from '../array/differenceWith.mjs';
5
4
  export { flatMap } from '../array/flatMap.mjs';
6
5
  export { flatMapDeep } from '../array/flatMapDeep.mjs';
@@ -9,6 +8,7 @@ export { groupBy } from '../array/groupBy.mjs';
9
8
  export { initial } from '../array/initial.mjs';
10
9
  export { intersectionWith } from '../array/intersectionWith.mjs';
11
10
  export { isSubset } from '../array/isSubset.mjs';
11
+ export { isSubsetWith } from '../array/isSubsetWith.mjs';
12
12
  export { keyBy } from '../array/keyBy.mjs';
13
13
  export { maxBy } from '../array/maxBy.mjs';
14
14
  export { minBy } from '../array/minBy.mjs';
@@ -19,17 +19,13 @@ export { shuffle } from '../array/shuffle.mjs';
19
19
  export { takeRightWhile } from '../array/takeRightWhile.mjs';
20
20
  export { takeWhile } from '../array/takeWhile.mjs';
21
21
  export { toFilled } from '../array/toFilled.mjs';
22
- export { union } from '../array/union.mjs';
23
22
  export { unionBy } from '../array/unionBy.mjs';
24
23
  export { unionWith } from '../array/unionWith.mjs';
25
- export { uniqBy } from '../array/uniqBy.mjs';
26
24
  export { uniqWith } from '../array/uniqWith.mjs';
27
- export { unzip } from '../array/unzip.mjs';
28
25
  export { unzipWith } from '../array/unzipWith.mjs';
29
26
  export { xor } from '../array/xor.mjs';
30
27
  export { xorBy } from '../array/xorBy.mjs';
31
28
  export { xorWith } from '../array/xorWith.mjs';
32
- export { zip } from '../array/zip.mjs';
33
29
  export { zipObject } from '../array/zipObject.mjs';
34
30
  export { zipWith } from '../array/zipWith.mjs';
35
31
  export { AbortError } from '../error/AbortError.mjs';
@@ -50,10 +46,9 @@ export { medianBy } from '../math/medianBy.mjs';
50
46
  export { randomInt } from '../math/randomInt.mjs';
51
47
  export { range } from '../math/range.mjs';
52
48
  export { rangeRight } from '../math/rangeRight.mjs';
53
- export { sum } from '../math/sum.mjs';
54
- export { sumBy } from '../math/sumBy.mjs';
55
49
  export { clone } from '../object/clone.mjs';
56
50
  export { isPrimitive } from '../predicate/isPrimitive.mjs';
51
+ export { findKey } from '../object/findKey.mjs';
57
52
  export { flattenObject } from '../object/flattenObject.mjs';
58
53
  export { invert } from '../object/invert.mjs';
59
54
  export { isObjectLike } from './predicate/isObjectLike.mjs';
@@ -74,6 +69,7 @@ export { delay } from '../promise/delay.mjs';
74
69
  export { timeout } from '../promise/timeout.mjs';
75
70
  export { withTimeout } from '../promise/withTimeout.mjs';
76
71
  export { capitalize } from '../string/capitalize.mjs';
72
+ export { words } from '../string/words.mjs';
77
73
  export { constantCase } from '../string/constantCase.mjs';
78
74
  export { deburr } from '../string/deburr.mjs';
79
75
  export { escapeRegExp } from '../string/escapeRegExp.mjs';
@@ -87,6 +83,7 @@ export { chunk } from './array/chunk.mjs';
87
83
  export { compact } from './array/compact.mjs';
88
84
  export { concat } from './array/concat.mjs';
89
85
  export { difference } from './array/difference.mjs';
86
+ export { differenceBy } from './array/differenceBy.mjs';
90
87
  export { drop } from './array/drop.mjs';
91
88
  export { dropRight } from './array/dropRight.mjs';
92
89
  export { dropRightWhile } from './array/dropRightWhile.mjs';
@@ -100,6 +97,7 @@ export { findLastIndex } from './array/findLastIndex.mjs';
100
97
  export { flatten } from './array/flatten.mjs';
101
98
  export { flattenDeep } from './array/flattenDeep.mjs';
102
99
  export { flattenDepth } from './array/flattenDepth.mjs';
100
+ export { forEach as each, forEach } from './array/forEach.mjs';
103
101
  export { head as first, head } from './array/head.mjs';
104
102
  export { includes } from './array/includes.mjs';
105
103
  export { indexOf } from './array/indexOf.mjs';
@@ -116,8 +114,12 @@ export { sortBy } from './array/sortBy.mjs';
116
114
  export { tail } from './array/tail.mjs';
117
115
  export { take } from './array/take.mjs';
118
116
  export { takeRight } from './array/takeRight.mjs';
117
+ export { union } from './array/union.mjs';
119
118
  export { uniq } from './array/uniq.mjs';
119
+ export { uniqBy } from './array/uniqBy.mjs';
120
+ export { unzip } from './array/unzip.mjs';
120
121
  export { without } from './array/without.mjs';
122
+ export { zip } from './array/zip.mjs';
121
123
  export { zipObjectDeep } from './array/zipObjectDeep.mjs';
122
124
  export { ary } from './function/ary.mjs';
123
125
  export { attempt } from './function/attempt.mjs';
@@ -144,6 +146,8 @@ export { min } from './math/min.mjs';
144
146
  export { parseInt } from './math/parseInt.mjs';
145
147
  export { random } from './math/random.mjs';
146
148
  export { round } from './math/round.mjs';
149
+ export { sum } from './math/sum.mjs';
150
+ export { sumBy } from './math/sumBy.mjs';
147
151
  export { cloneDeep } from './object/cloneDeep.mjs';
148
152
  export { defaults } from './object/defaults.mjs';
149
153
  export { fromPairs } from './object/fromPairs.mjs';
@@ -169,6 +173,7 @@ export { isArrayLike } from './predicate/isArrayLike.mjs';
169
173
  export { isArrayLikeObject } from './predicate/isArrayLikeObject.mjs';
170
174
  export { isBoolean } from './predicate/isBoolean.mjs';
171
175
  export { isDate } from './predicate/isDate.mjs';
176
+ export { isEmpty } from './predicate/isEmpty.mjs';
172
177
  export { isEqualWith } from './predicate/isEqualWith.mjs';
173
178
  export { isError } from './predicate/isError.mjs';
174
179
  export { isFinite } from './predicate/isFinite.mjs';
@@ -199,16 +204,18 @@ export { pad } from './string/pad.mjs';
199
204
  export { padEnd } from './string/padEnd.mjs';
200
205
  export { padStart } from './string/padStart.mjs';
201
206
  export { repeat } from './string/repeat.mjs';
207
+ export { replace } from './string/replace.mjs';
202
208
  export { snakeCase } from './string/snakeCase.mjs';
203
209
  export { startCase } from './string/startCase.mjs';
204
210
  export { startsWith } from './string/startsWith.mjs';
205
- export { upperCase } from './string/upperCase.mjs';
206
211
  export { template, templateSettings } from './string/template.mjs';
207
212
  export { trim } from './string/trim.mjs';
208
213
  export { trimEnd } from './string/trimEnd.mjs';
209
214
  export { trimStart } from './string/trimStart.mjs';
215
+ export { upperCase } from './string/upperCase.mjs';
210
216
  export { constant } from './util/constant.mjs';
211
217
  export { defaultTo } from './util/defaultTo.mjs';
218
+ export { iteratee } from './util/iteratee.mjs';
212
219
  export { times } from './util/times.mjs';
213
220
  export { toFinite } from './util/toFinite.mjs';
214
221
  export { toInteger } from './util/toInteger.mjs';
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Computes the sum of the `number` values in `array`.
3
+ *
4
+ * @param {ArrayLike<number> | null | undefined} array - The array to iterate over.
5
+ * @returns {number} Returns the sum.
6
+ *
7
+ * @example
8
+ * sum([1, 2, 3]); // => 6
9
+ * sum(null); // => 0
10
+ * sum(undefined); // => 0
11
+ */
12
+ declare function sum(array: ArrayLike<number> | null | undefined): number;
13
+ /**
14
+ * Computes the sum of the `bigint` values in `array`.
15
+ *
16
+ * @param {ArrayLike<bigint>} array - The array to iterate over.
17
+ * @returns {bigint} Returns the sum.
18
+ *
19
+ * @example
20
+ * sum([1n, 2n, 3n]); // => 6n
21
+ */
22
+ declare function sum(array: ArrayLike<bigint>): bigint;
23
+ /**
24
+ * Computes the sum of the values in `array`.
25
+ *
26
+ * It does not coerce values to `number`.
27
+ *
28
+ * @param {ArrayLike<unknown> | null | undefined} array - The array to iterate over.
29
+ * @returns {unknown} Returns the sum.
30
+ *
31
+ * @example
32
+ * sum(["1", "2"]); // => "12"
33
+ * sum([1, undefined, 2]); // => 3
34
+ */
35
+ declare function sum(array: ArrayLike<unknown> | null | undefined): unknown;
36
+
37
+ export { sum };
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Computes the sum of the `number` values in `array`.
3
+ *
4
+ * @param {ArrayLike<number> | null | undefined} array - The array to iterate over.
5
+ * @returns {number} Returns the sum.
6
+ *
7
+ * @example
8
+ * sum([1, 2, 3]); // => 6
9
+ * sum(null); // => 0
10
+ * sum(undefined); // => 0
11
+ */
12
+ declare function sum(array: ArrayLike<number> | null | undefined): number;
13
+ /**
14
+ * Computes the sum of the `bigint` values in `array`.
15
+ *
16
+ * @param {ArrayLike<bigint>} array - The array to iterate over.
17
+ * @returns {bigint} Returns the sum.
18
+ *
19
+ * @example
20
+ * sum([1n, 2n, 3n]); // => 6n
21
+ */
22
+ declare function sum(array: ArrayLike<bigint>): bigint;
23
+ /**
24
+ * Computes the sum of the values in `array`.
25
+ *
26
+ * It does not coerce values to `number`.
27
+ *
28
+ * @param {ArrayLike<unknown> | null | undefined} array - The array to iterate over.
29
+ * @returns {unknown} Returns the sum.
30
+ *
31
+ * @example
32
+ * sum(["1", "2"]); // => "12"
33
+ * sum([1, undefined, 2]); // => 3
34
+ */
35
+ declare function sum(array: ArrayLike<unknown> | null | undefined): unknown;
36
+
37
+ export { sum };
@@ -0,0 +1,7 @@
1
+ import { sumBy } from './sumBy.mjs';
2
+
3
+ function sum(array) {
4
+ return sumBy(array);
5
+ }
6
+
7
+ export { sum };
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Computes the sum of the `number` values in `array`.
3
+ *
4
+ * @param {ArrayLike<number> | null | undefined} array - The array to iterate over.
5
+ * @returns {number} Returns the sum.
6
+ *
7
+ * @example
8
+ * sumBy([1, 2, 3]); // => 6
9
+ * sumBy(null); // => 0
10
+ * sumBy(undefined); // => 0
11
+ */
12
+ declare function sumBy(array: ArrayLike<number> | null | undefined): number;
13
+ /**
14
+ * Computes the sum of the `bigint` values in `array`.
15
+ *
16
+ * @param {ArrayLike<bigint>} array - The array to iterate over.
17
+ * @returns {bigint} Returns the sum.
18
+ *
19
+ * @example
20
+ * sumBy([1n, 2n, 3n]); // => 6n
21
+ */
22
+ declare function sumBy(array: ArrayLike<bigint>): bigint;
23
+ /**
24
+ * Computes the sum of the values in `array`.
25
+ *
26
+ * It does not coerce values to `number`.
27
+ *
28
+ * @param {ArrayLike<unknown> | null | undefined} array - The array to iterate over.
29
+ * @returns {unknown} Returns the sum.
30
+ *
31
+ * @example
32
+ * sumBy(["1", "2"]); // => "12"
33
+ * sumBy([1, undefined, 2]); // => 3
34
+ */
35
+ declare function sumBy(array: ArrayLike<unknown> | null | undefined): unknown;
36
+ /**
37
+ * Compmutes the sum of the `number` values that are returned by the `iteratee` function.
38
+ *
39
+ * @template T - The type of the array elements.
40
+ * @param {ArrayLike<T>} array - The array to iterate over.
41
+ * @param {(value: T) => number} iteratee - The function invoked per iteration.
42
+ * @returns {number} Returns the sum.
43
+ *
44
+ * @example
45
+ * sumBy([{ a: 1 }, { a: 2 }, { a: 3 }], object => object.a); // => 6
46
+ */
47
+ declare function sumBy<T>(array: ArrayLike<T>, iteratee: (value: T) => number): number;
48
+ /**
49
+ * Compmutes the sum of the `bigint` values that are returned by the `iteratee` function.
50
+ *
51
+ * NOTE: If the `array` is empty, the function returns `0`.
52
+ *
53
+ * @template T - The type of the array elements.
54
+ * @param {ArrayLike<T>} array - The array to iterate over.
55
+ * @param {(value: T) => bigint} iteratee - The function invoked per iteration.
56
+ * @returns {bigint | number} Returns the sum.
57
+ *
58
+ * @example
59
+ * sumBy([{ a: 1n }, { a: 2n }, { a: 3n }], object => object.a); // => 6n
60
+ * sumBy([], (item: { a: bigint }) => item.a); // => 0
61
+ */
62
+ declare function sumBy<T>(array: ArrayLike<T>, iteratee: (value: T) => bigint): bigint | number;
63
+
64
+ export { sumBy };
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Computes the sum of the `number` values in `array`.
3
+ *
4
+ * @param {ArrayLike<number> | null | undefined} array - The array to iterate over.
5
+ * @returns {number} Returns the sum.
6
+ *
7
+ * @example
8
+ * sumBy([1, 2, 3]); // => 6
9
+ * sumBy(null); // => 0
10
+ * sumBy(undefined); // => 0
11
+ */
12
+ declare function sumBy(array: ArrayLike<number> | null | undefined): number;
13
+ /**
14
+ * Computes the sum of the `bigint` values in `array`.
15
+ *
16
+ * @param {ArrayLike<bigint>} array - The array to iterate over.
17
+ * @returns {bigint} Returns the sum.
18
+ *
19
+ * @example
20
+ * sumBy([1n, 2n, 3n]); // => 6n
21
+ */
22
+ declare function sumBy(array: ArrayLike<bigint>): bigint;
23
+ /**
24
+ * Computes the sum of the values in `array`.
25
+ *
26
+ * It does not coerce values to `number`.
27
+ *
28
+ * @param {ArrayLike<unknown> | null | undefined} array - The array to iterate over.
29
+ * @returns {unknown} Returns the sum.
30
+ *
31
+ * @example
32
+ * sumBy(["1", "2"]); // => "12"
33
+ * sumBy([1, undefined, 2]); // => 3
34
+ */
35
+ declare function sumBy(array: ArrayLike<unknown> | null | undefined): unknown;
36
+ /**
37
+ * Compmutes the sum of the `number` values that are returned by the `iteratee` function.
38
+ *
39
+ * @template T - The type of the array elements.
40
+ * @param {ArrayLike<T>} array - The array to iterate over.
41
+ * @param {(value: T) => number} iteratee - The function invoked per iteration.
42
+ * @returns {number} Returns the sum.
43
+ *
44
+ * @example
45
+ * sumBy([{ a: 1 }, { a: 2 }, { a: 3 }], object => object.a); // => 6
46
+ */
47
+ declare function sumBy<T>(array: ArrayLike<T>, iteratee: (value: T) => number): number;
48
+ /**
49
+ * Compmutes the sum of the `bigint` values that are returned by the `iteratee` function.
50
+ *
51
+ * NOTE: If the `array` is empty, the function returns `0`.
52
+ *
53
+ * @template T - The type of the array elements.
54
+ * @param {ArrayLike<T>} array - The array to iterate over.
55
+ * @param {(value: T) => bigint} iteratee - The function invoked per iteration.
56
+ * @returns {bigint | number} Returns the sum.
57
+ *
58
+ * @example
59
+ * sumBy([{ a: 1n }, { a: 2n }, { a: 3n }], object => object.a); // => 6n
60
+ * sumBy([], (item: { a: bigint }) => item.a); // => 0
61
+ */
62
+ declare function sumBy<T>(array: ArrayLike<T>, iteratee: (value: T) => bigint): bigint | number;
63
+
64
+ export { sumBy };
@@ -0,0 +1,20 @@
1
+ import { iteratee } from '../util/iteratee.mjs';
2
+
3
+ function sumBy(array, iteratee$1) {
4
+ if (!array || !array.length) {
5
+ return 0;
6
+ }
7
+ if (iteratee$1 != null) {
8
+ iteratee$1 = iteratee(iteratee$1);
9
+ }
10
+ let result = iteratee$1 ? iteratee$1(array[0]) : array[0];
11
+ for (let i = 1; i < array.length; i++) {
12
+ const current = iteratee$1 ? iteratee$1(array[i]) : array[i];
13
+ if (current !== undefined) {
14
+ result += current;
15
+ }
16
+ }
17
+ return result;
18
+ }
19
+
20
+ export { sumBy };
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Checks if a given value is empty.
3
+ *
4
+ * @returns {true} Always returns true when no arguments are provided.
5
+ *
6
+ * @example
7
+ * isEmpty(); // true
8
+ */
9
+ declare function isEmpty(): true;
10
+ /**
11
+ * Checks if a given string is empty.
12
+ *
13
+ * @param {string} value - The string to check.
14
+ * @returns {boolean} `true` if the string is empty, `false` otherwise.
15
+ *
16
+ * @example
17
+ * isEmpty(""); // true
18
+ * isEmpty("hello"); // false
19
+ */
20
+ declare function isEmpty(value: string): value is '';
21
+ /**
22
+ * Checks if a given Map is empty.
23
+ *
24
+ * @param {Map<any, any>} value - The Map to check.
25
+ * @returns {boolean} `true` if the Map is empty, `false` otherwise.
26
+ *
27
+ * @example
28
+ * isEmpty(new Map()); // true
29
+ * isEmpty(new Map([["key", "value"]])); // false
30
+ */
31
+ declare function isEmpty(value: Map<any, any>): boolean;
32
+ /**
33
+ * Checks if a given Set is empty.
34
+ *
35
+ * @param {Set<any>} value - The Set to check.
36
+ * @returns {boolean} `true` if the Set is empty, `false` otherwise.
37
+ *
38
+ * @example
39
+ * isEmpty(new Set()); // true
40
+ * isEmpty(new Set([1, 2, 3])); // false
41
+ */
42
+ declare function isEmpty(value: Set<any>): boolean;
43
+ /**
44
+ * Checks if a given array is empty.
45
+ *
46
+ * @param {any[]} value - The array to check.
47
+ * @returns {boolean} `true` if the array is empty, `false` otherwise.
48
+ *
49
+ * @example
50
+ * isEmpty([]); // true
51
+ * isEmpty([1, 2, 3]); // false
52
+ */
53
+ declare function isEmpty(value: any[]): value is [];
54
+ /**
55
+ * Checks if a given object is empty.
56
+ *
57
+ * @param {T | null | undefined} value - The object to check.
58
+ * @returns {boolean} `true` if the object is empty, `false` otherwise.
59
+ *
60
+ * @example
61
+ * isEmpty({}); // true
62
+ * isEmpty({ a: 1 }); // false
63
+ */
64
+ declare function isEmpty<T extends Record<any, any>>(value: T | null | undefined): value is Record<keyof T, never> | null | undefined;
65
+ /**
66
+ * Checks if a given value is empty.
67
+ *
68
+ * @param {unknown} value - The value to check.
69
+ * @returns {boolean} `true` if the value is empty, `false` otherwise.
70
+ *
71
+ * @example
72
+ * isEmpty(null); // true
73
+ * isEmpty(undefined); // true
74
+ * isEmpty(42); // true
75
+ */
76
+ declare function isEmpty(value: unknown): boolean;
77
+
78
+ export { isEmpty };
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Checks if a given value is empty.
3
+ *
4
+ * @returns {true} Always returns true when no arguments are provided.
5
+ *
6
+ * @example
7
+ * isEmpty(); // true
8
+ */
9
+ declare function isEmpty(): true;
10
+ /**
11
+ * Checks if a given string is empty.
12
+ *
13
+ * @param {string} value - The string to check.
14
+ * @returns {boolean} `true` if the string is empty, `false` otherwise.
15
+ *
16
+ * @example
17
+ * isEmpty(""); // true
18
+ * isEmpty("hello"); // false
19
+ */
20
+ declare function isEmpty(value: string): value is '';
21
+ /**
22
+ * Checks if a given Map is empty.
23
+ *
24
+ * @param {Map<any, any>} value - The Map to check.
25
+ * @returns {boolean} `true` if the Map is empty, `false` otherwise.
26
+ *
27
+ * @example
28
+ * isEmpty(new Map()); // true
29
+ * isEmpty(new Map([["key", "value"]])); // false
30
+ */
31
+ declare function isEmpty(value: Map<any, any>): boolean;
32
+ /**
33
+ * Checks if a given Set is empty.
34
+ *
35
+ * @param {Set<any>} value - The Set to check.
36
+ * @returns {boolean} `true` if the Set is empty, `false` otherwise.
37
+ *
38
+ * @example
39
+ * isEmpty(new Set()); // true
40
+ * isEmpty(new Set([1, 2, 3])); // false
41
+ */
42
+ declare function isEmpty(value: Set<any>): boolean;
43
+ /**
44
+ * Checks if a given array is empty.
45
+ *
46
+ * @param {any[]} value - The array to check.
47
+ * @returns {boolean} `true` if the array is empty, `false` otherwise.
48
+ *
49
+ * @example
50
+ * isEmpty([]); // true
51
+ * isEmpty([1, 2, 3]); // false
52
+ */
53
+ declare function isEmpty(value: any[]): value is [];
54
+ /**
55
+ * Checks if a given object is empty.
56
+ *
57
+ * @param {T | null | undefined} value - The object to check.
58
+ * @returns {boolean} `true` if the object is empty, `false` otherwise.
59
+ *
60
+ * @example
61
+ * isEmpty({}); // true
62
+ * isEmpty({ a: 1 }); // false
63
+ */
64
+ declare function isEmpty<T extends Record<any, any>>(value: T | null | undefined): value is Record<keyof T, never> | null | undefined;
65
+ /**
66
+ * Checks if a given value is empty.
67
+ *
68
+ * @param {unknown} value - The value to check.
69
+ * @returns {boolean} `true` if the value is empty, `false` otherwise.
70
+ *
71
+ * @example
72
+ * isEmpty(null); // true
73
+ * isEmpty(undefined); // true
74
+ * isEmpty(42); // true
75
+ */
76
+ declare function isEmpty(value: unknown): boolean;
77
+
78
+ export { isEmpty };
@@ -0,0 +1,33 @@
1
+ import { isArguments } from './isArguments.mjs';
2
+ import { isArrayLike } from './isArrayLike.mjs';
3
+ import { isTypedArray } from './isTypedArray.mjs';
4
+ import { isPrototype } from '../_internal/isPrototype.mjs';
5
+
6
+ function isEmpty(value) {
7
+ if (value == null) {
8
+ return true;
9
+ }
10
+ if (isArrayLike(value)) {
11
+ if (typeof value.splice !== 'function' &&
12
+ typeof value !== 'string' &&
13
+ (typeof Buffer === 'undefined' || !Buffer.isBuffer(value)) &&
14
+ !isTypedArray(value) &&
15
+ !isArguments(value)) {
16
+ return false;
17
+ }
18
+ return value.length === 0;
19
+ }
20
+ if (typeof value === 'object') {
21
+ if (value instanceof Map || value instanceof Set) {
22
+ return value.size === 0;
23
+ }
24
+ const keys = Object.keys(value);
25
+ if (isPrototype(value)) {
26
+ return keys.filter(x => x !== 'constructor').length === 0;
27
+ }
28
+ return keys.length === 0;
29
+ }
30
+ return true;
31
+ }
32
+
33
+ export { isEmpty };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Replaces the matched pattern with the replacement string.
3
+ *
4
+ * @param {string} target - The target string.
5
+ * @param {string | RegExp} pattern - The pattern to match.
6
+ * @param {string | ((substring: string, ...args: any[]) => string)} replacement - The replacement string or a function that returns the replacement string.
7
+ * @returns {string} The new string with the matched pattern replaced.
8
+ *
9
+ * @example
10
+ * replace('abcde', 'de', '123'); // 'abc123'
11
+ * replace('abcde', /[bd]/g, '-'); // 'a-c-e'
12
+ * replace('abcde', 'de', substring => substring.toUpperCase()); // 'abcDE'
13
+ * replace('abcde', /[bd]/g, substring => substring.toUpperCase()); // 'aBcDe'
14
+ */
15
+ declare function replace(target: string | undefined, pattern: string | RegExp, replacement: string | ((substring: string, ...args: any[]) => string)): string;
16
+
17
+ export { replace };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Replaces the matched pattern with the replacement string.
3
+ *
4
+ * @param {string} target - The target string.
5
+ * @param {string | RegExp} pattern - The pattern to match.
6
+ * @param {string | ((substring: string, ...args: any[]) => string)} replacement - The replacement string or a function that returns the replacement string.
7
+ * @returns {string} The new string with the matched pattern replaced.
8
+ *
9
+ * @example
10
+ * replace('abcde', 'de', '123'); // 'abc123'
11
+ * replace('abcde', /[bd]/g, '-'); // 'a-c-e'
12
+ * replace('abcde', 'de', substring => substring.toUpperCase()); // 'abcDE'
13
+ * replace('abcde', /[bd]/g, substring => substring.toUpperCase()); // 'aBcDe'
14
+ */
15
+ declare function replace(target: string | undefined, pattern: string | RegExp, replacement: string | ((substring: string, ...args: any[]) => string)): string;
16
+
17
+ export { replace };
@@ -0,0 +1,10 @@
1
+ import { toString } from '../util/toString.mjs';
2
+
3
+ function replace(target = '', pattern, replacement) {
4
+ if (arguments.length < 3) {
5
+ return toString(target);
6
+ }
7
+ return toString(target).replace(pattern, replacement);
8
+ }
9
+
10
+ export { replace };
@@ -1,11 +1,11 @@
1
- import { getWords } from '../../string/_internal/getWords.mjs';
1
+ import { words } from '../../string/words.mjs';
2
2
  import { normalizeForCase } from '../_internal/normalizeForCase.mjs';
3
3
 
4
4
  function startCase(str) {
5
- const words = getWords(normalizeForCase(str).trim());
5
+ const words$1 = words(normalizeForCase(str).trim());
6
6
  let result = '';
7
- for (let i = 0; i < words.length; i++) {
8
- const word = words[i];
7
+ for (let i = 0; i < words$1.length; i++) {
8
+ const word = words$1[i];
9
9
  if (result) {
10
10
  result += ' ';
11
11
  }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Returns a `identity` function when `value` is `null` or `undefined`.
3
+ *
4
+ * @param {null} [value] - The value to convert to an iteratee.
5
+ * @returns {<T>(value: T) => T} - Returns a `identity` function.
6
+ *
7
+ * @example
8
+ * const func = iteratee();
9
+ * [{ a: 1 }, { a: 2 }, { a: 3 }].map(func) // => [{ a: 1 }, { a: 2 }, { a: 3 }]
10
+ */
11
+ declare function iteratee(value?: null): <T>(value: T) => T;
12
+ /**
13
+ * Returns a given `func` function when `value` is a `function`.
14
+ *
15
+ * @template {(...args: any[]) => unknown} F - The function type.
16
+ * @param {F} func - The function to return.
17
+ * @returns {F} - Returns the given function.
18
+ *
19
+ * @example
20
+ * const func = iteratee((object) => object.a);
21
+ * [{ a: 1 }, { a: 2 }, { a: 3 }].map(func) // => [1, 2, 3]
22
+ */
23
+ declare function iteratee<F extends (...args: any[]) => unknown>(func: F): F;
24
+ /**
25
+ * Creates a function that invokes `value` with the arguments of the created function.
26
+ *
27
+ * The created function returns the property value for a given element.
28
+ *
29
+ * @param {symbol | number | string | object} value - The value to convert to an iteratee.
30
+ * @returns {(...args: any[]) => any} - Returns the new iteratee function.
31
+ *
32
+ * @example
33
+ * const func = iteratee('a');
34
+ * [{ a: 1 }, { a: 2 }, { a: 3 }].map(func) // => [1, 2, 3]
35
+ *
36
+ * const func = iteratee({ a: 1 });
37
+ * [{ a: 1 }, { a: 2 }, { a: 3 }].find(func) // => { a: 1 }
38
+ *
39
+ * const func = iteratee(['a', 1]);
40
+ * [{ a: 1 }, { a: 2 }, { a: 3 }].find(func) // => { a: 1 }
41
+ */
42
+ declare function iteratee(value: symbol | number | string | object): (...args: any[]) => any;
43
+
44
+ export { iteratee };