es-toolkit 1.29.0 → 1.30.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 (134) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/_chunk/{rangeRight-w3WrXN.js → range-HnEIT7.js} +0 -17
  3. package/dist/_chunk/{zipWith-Bb2eZI.js → zipWith-nbzldx.js} +11 -10
  4. package/dist/array/index.d.mts +1 -0
  5. package/dist/array/index.d.ts +1 -0
  6. package/dist/array/index.js +12 -2
  7. package/dist/array/index.mjs +1 -0
  8. package/dist/array/pull.d.mts +19 -0
  9. package/dist/array/pull.d.ts +19 -0
  10. package/dist/array/pull.mjs +11 -0
  11. package/dist/browser.global.js +1 -1
  12. package/dist/browser.global.js.map +1 -1
  13. package/dist/compat/_internal/isIndex.mjs +2 -2
  14. package/dist/compat/_internal/isPrototype.mjs +1 -1
  15. package/dist/compat/array/differenceWith.d.mts +91 -0
  16. package/dist/compat/array/differenceWith.d.ts +91 -0
  17. package/dist/compat/array/differenceWith.mjs +19 -0
  18. package/dist/compat/array/map.d.mts +182 -0
  19. package/dist/compat/array/map.d.ts +182 -0
  20. package/dist/compat/array/map.mjs +21 -0
  21. package/dist/compat/array/nth.d.mts +14 -0
  22. package/dist/compat/array/nth.d.ts +14 -0
  23. package/dist/compat/array/nth.mjs +15 -0
  24. package/dist/compat/array/pull.d.mts +19 -0
  25. package/dist/compat/array/pull.d.ts +19 -0
  26. package/dist/compat/array/pull.mjs +8 -0
  27. package/dist/compat/array/takeRightWhile.d.mts +84 -0
  28. package/dist/compat/array/takeRightWhile.d.ts +84 -0
  29. package/dist/compat/array/takeRightWhile.mjs +15 -0
  30. package/dist/compat/function/after.d.mts +31 -0
  31. package/dist/compat/function/after.d.ts +31 -0
  32. package/dist/compat/function/after.mjs +15 -0
  33. package/dist/compat/function/delay.d.mts +29 -0
  34. package/dist/compat/function/delay.d.ts +29 -0
  35. package/dist/compat/function/delay.mjs +10 -0
  36. package/dist/compat/function/nthArg.d.mts +22 -0
  37. package/dist/compat/function/nthArg.d.ts +22 -0
  38. package/dist/compat/function/nthArg.mjs +9 -0
  39. package/dist/compat/index.d.mts +30 -13
  40. package/dist/compat/index.d.ts +30 -13
  41. package/dist/compat/index.js +369 -56
  42. package/dist/compat/index.mjs +31 -13
  43. package/dist/compat/math/range.d.mts +47 -0
  44. package/dist/compat/math/range.d.ts +47 -0
  45. package/dist/compat/math/range.mjs +26 -0
  46. package/dist/compat/math/rangeRight.d.mts +47 -0
  47. package/dist/compat/math/rangeRight.d.ts +47 -0
  48. package/dist/compat/math/rangeRight.mjs +26 -0
  49. package/dist/compat/math/sumBy.d.mts +2 -2
  50. package/dist/compat/math/sumBy.d.ts +2 -2
  51. package/dist/compat/object/findKey.d.mts +58 -0
  52. package/dist/compat/object/findKey.d.ts +58 -0
  53. package/dist/compat/object/findKey.mjs +30 -0
  54. package/dist/compat/object/keys.d.mts +22 -0
  55. package/dist/compat/object/keys.d.ts +22 -0
  56. package/dist/compat/object/keys.mjs +32 -0
  57. package/dist/compat/object/propertyOf.d.mts +22 -0
  58. package/dist/compat/object/propertyOf.d.ts +22 -0
  59. package/dist/compat/object/propertyOf.mjs +9 -0
  60. package/dist/compat/predicate/isArrayLike.d.mts +1 -1
  61. package/dist/compat/predicate/isArrayLike.d.ts +1 -1
  62. package/dist/compat/predicate/isArrayLikeObject.d.mts +1 -1
  63. package/dist/compat/predicate/isArrayLikeObject.d.ts +1 -1
  64. package/dist/compat/predicate/isElement.d.mts +1 -1
  65. package/dist/compat/predicate/isElement.d.ts +1 -1
  66. package/dist/compat/predicate/isFinite.d.mts +1 -1
  67. package/dist/compat/predicate/isFinite.d.ts +1 -1
  68. package/dist/compat/predicate/isNaN.d.mts +1 -1
  69. package/dist/compat/predicate/isNaN.d.ts +1 -1
  70. package/dist/compat/predicate/isObject.d.mts +1 -1
  71. package/dist/compat/predicate/isObject.d.ts +1 -1
  72. package/dist/compat/predicate/isObjectLike.d.mts +1 -1
  73. package/dist/compat/predicate/isObjectLike.d.ts +1 -1
  74. package/dist/compat/string/deburr.d.mts +22 -0
  75. package/dist/compat/string/deburr.d.ts +22 -0
  76. package/dist/compat/string/deburr.mjs +8 -0
  77. package/dist/compat/string/escapeRegExp.d.mts +14 -0
  78. package/dist/compat/string/escapeRegExp.d.ts +14 -0
  79. package/dist/compat/string/escapeRegExp.mjs +8 -0
  80. package/dist/compat/string/lowerFirst.d.mts +14 -0
  81. package/dist/compat/string/lowerFirst.d.ts +14 -0
  82. package/dist/compat/string/lowerFirst.mjs +8 -0
  83. package/dist/compat/string/toLower.d.mts +20 -0
  84. package/dist/compat/string/toLower.d.ts +20 -0
  85. package/dist/compat/string/toLower.mjs +7 -0
  86. package/dist/compat/string/unescape.d.mts +16 -0
  87. package/dist/compat/string/unescape.d.ts +16 -0
  88. package/dist/compat/string/unescape.mjs +8 -0
  89. package/dist/compat/string/upperFirst.d.mts +14 -0
  90. package/dist/compat/string/upperFirst.d.ts +14 -0
  91. package/dist/compat/string/upperFirst.mjs +8 -0
  92. package/dist/compat/util/invoke.d.mts +23 -0
  93. package/dist/compat/util/invoke.d.ts +23 -0
  94. package/dist/compat/util/invoke.mjs +48 -0
  95. package/dist/compat/util/lt.d.mts +15 -0
  96. package/dist/compat/util/lt.d.ts +15 -0
  97. package/dist/compat/util/lt.mjs +10 -0
  98. package/dist/compat/util/lte.d.mts +15 -0
  99. package/dist/compat/util/lte.d.ts +15 -0
  100. package/dist/compat/util/lte.mjs +10 -0
  101. package/dist/compat/util/method.d.mts +22 -0
  102. package/dist/compat/util/method.d.ts +22 -0
  103. package/dist/compat/util/method.mjs +9 -0
  104. package/dist/compat/util/now.d.mts +18 -0
  105. package/dist/compat/util/now.d.ts +18 -0
  106. package/dist/compat/util/now.mjs +5 -0
  107. package/dist/compat/util/stubArray.d.mts +10 -0
  108. package/dist/compat/util/stubArray.d.ts +10 -0
  109. package/dist/compat/util/stubArray.mjs +5 -0
  110. package/dist/compat/util/stubFalse.d.mts +10 -0
  111. package/dist/compat/util/stubFalse.d.ts +10 -0
  112. package/dist/compat/util/stubFalse.mjs +5 -0
  113. package/dist/compat/util/stubObject.d.mts +10 -0
  114. package/dist/compat/util/stubObject.d.ts +10 -0
  115. package/dist/compat/util/stubObject.mjs +5 -0
  116. package/dist/compat/util/stubString.d.mts +10 -0
  117. package/dist/compat/util/stubString.d.ts +10 -0
  118. package/dist/compat/util/stubString.mjs +5 -0
  119. package/dist/compat/util/stubTrue.d.mts +10 -0
  120. package/dist/compat/util/stubTrue.d.ts +10 -0
  121. package/dist/compat/util/stubTrue.mjs +5 -0
  122. package/dist/compat/util/toArray.mjs +0 -3
  123. package/dist/compat/util/toPlainObject.d.mts +16 -0
  124. package/dist/compat/util/toPlainObject.d.ts +16 -0
  125. package/dist/compat/util/toPlainObject.mjs +24 -0
  126. package/dist/index.d.mts +1 -0
  127. package/dist/index.d.ts +1 -0
  128. package/dist/index.js +13 -12
  129. package/dist/index.mjs +1 -0
  130. package/dist/math/index.js +26 -10
  131. package/package.json +1 -1
  132. package/dist/compat/util/uniqueId.d.mts +0 -25
  133. package/dist/compat/util/uniqueId.d.ts +0 -25
  134. package/dist/compat/util/uniqueId.mjs +0 -7
@@ -1,6 +1,5 @@
1
1
  export { at } from '../array/at.mjs';
2
2
  export { countBy } from '../array/countBy.mjs';
3
- export { differenceWith } from '../array/differenceWith.mjs';
4
3
  export { flatMap } from '../array/flatMap.mjs';
5
4
  export { flatMapDeep } from '../array/flatMapDeep.mjs';
6
5
  export { forEachRight } from '../array/forEachRight.mjs';
@@ -16,7 +15,6 @@ export { partition } from '../array/partition.mjs';
16
15
  export { pullAt } from '../array/pullAt.mjs';
17
16
  export { sampleSize } from '../array/sampleSize.mjs';
18
17
  export { shuffle } from '../array/shuffle.mjs';
19
- export { takeRightWhile } from '../array/takeRightWhile.mjs';
20
18
  export { takeWhile } from '../array/takeWhile.mjs';
21
19
  export { toFilled } from '../array/toFilled.mjs';
22
20
  export { unionBy } from '../array/unionBy.mjs';
@@ -30,7 +28,6 @@ export { zipObject } from '../array/zipObject.mjs';
30
28
  export { zipWith } from '../array/zipWith.mjs';
31
29
  export { AbortError } from '../error/AbortError.mjs';
32
30
  export { TimeoutError } from '../error/TimeoutError.mjs';
33
- export { after } from '../function/after.mjs';
34
31
  export { identity } from '../function/identity.mjs';
35
32
  export { memoize } from '../function/memoize.mjs';
36
33
  export { negate } from '../function/negate.mjs';
@@ -44,11 +41,8 @@ export { meanBy } from '../math/meanBy.mjs';
44
41
  export { median } from '../math/median.mjs';
45
42
  export { medianBy } from '../math/medianBy.mjs';
46
43
  export { randomInt } from '../math/randomInt.mjs';
47
- export { range } from '../math/range.mjs';
48
- export { rangeRight } from '../math/rangeRight.mjs';
49
44
  export { clone } from '../object/clone.mjs';
50
45
  export { isPrimitive } from '../predicate/isPrimitive.mjs';
51
- export { findKey } from '../object/findKey.mjs';
52
46
  export { flattenObject } from '../object/flattenObject.mjs';
53
47
  export { invert } from '../object/invert.mjs';
54
48
  export { isObjectLike } from './predicate/isObjectLike.mjs';
@@ -66,17 +60,12 @@ export { isLength } from '../predicate/isLength.mjs';
66
60
  export { isNotNil } from '../predicate/isNotNil.mjs';
67
61
  export { isNull } from '../predicate/isNull.mjs';
68
62
  export { isUndefined } from '../predicate/isUndefined.mjs';
69
- export { delay } from '../promise/delay.mjs';
70
63
  export { timeout } from '../promise/timeout.mjs';
71
64
  export { withTimeout } from '../promise/withTimeout.mjs';
72
65
  export { capitalize } from '../string/capitalize.mjs';
73
66
  export { constantCase } from '../string/constantCase.mjs';
74
- export { deburr } from '../string/deburr.mjs';
75
- export { escapeRegExp } from '../string/escapeRegExp.mjs';
76
- export { lowerFirst } from '../string/lowerFirst.mjs';
67
+ import '../string/deburr.mjs';
77
68
  export { pascalCase } from '../string/pascalCase.mjs';
78
- export { unescape } from '../string/unescape.mjs';
79
- export { upperFirst } from '../string/upperFirst.mjs';
80
69
  export { invariant } from '../util/invariant.mjs';
81
70
  export { castArray } from './array/castArray.mjs';
82
71
  export { chunk } from './array/chunk.mjs';
@@ -84,6 +73,7 @@ export { compact } from './array/compact.mjs';
84
73
  export { concat } from './array/concat.mjs';
85
74
  export { difference } from './array/difference.mjs';
86
75
  export { differenceBy } from './array/differenceBy.mjs';
76
+ export { differenceWith } from './array/differenceWith.mjs';
87
77
  export { drop } from './array/drop.mjs';
88
78
  export { dropRight } from './array/dropRight.mjs';
89
79
  export { dropRightWhile } from './array/dropRightWhile.mjs';
@@ -106,7 +96,10 @@ export { intersectionBy } from './array/intersectionBy.mjs';
106
96
  export { join } from './array/join.mjs';
107
97
  export { last } from './array/last.mjs';
108
98
  export { lastIndexOf } from './array/lastIndexOf.mjs';
99
+ export { map } from './array/map.mjs';
100
+ export { nth } from './array/nth.mjs';
109
101
  export { orderBy } from './array/orderBy.mjs';
102
+ export { pull } from './array/pull.mjs';
110
103
  export { sample } from './array/sample.mjs';
111
104
  export { size } from './array/size.mjs';
112
105
  export { slice } from './array/slice.mjs';
@@ -115,6 +108,7 @@ export { sortBy } from './array/sortBy.mjs';
115
108
  export { tail } from './array/tail.mjs';
116
109
  export { take } from './array/take.mjs';
117
110
  export { takeRight } from './array/takeRight.mjs';
111
+ export { takeRightWhile } from './array/takeRightWhile.mjs';
118
112
  export { union } from './array/union.mjs';
119
113
  export { uniq } from './array/uniq.mjs';
120
114
  export { uniqBy } from './array/uniqBy.mjs';
@@ -122,6 +116,7 @@ export { unzip } from './array/unzip.mjs';
122
116
  export { without } from './array/without.mjs';
123
117
  export { zip } from './array/zip.mjs';
124
118
  export { zipObjectDeep } from './array/zipObjectDeep.mjs';
119
+ export { after } from './function/after.mjs';
125
120
  export { ary } from './function/ary.mjs';
126
121
  export { attempt } from './function/attempt.mjs';
127
122
  export { before } from './function/before.mjs';
@@ -131,9 +126,11 @@ export { curry } from './function/curry.mjs';
131
126
  export { curryRight } from './function/curryRight.mjs';
132
127
  export { debounce } from './function/debounce.mjs';
133
128
  export { defer } from './function/defer.mjs';
129
+ export { delay } from './function/delay.mjs';
134
130
  export { flip } from './function/flip.mjs';
135
131
  export { flow } from './function/flow.mjs';
136
132
  export { flowRight } from './function/flowRight.mjs';
133
+ export { nthArg } from './function/nthArg.mjs';
137
134
  export { rearg } from './function/rearg.mjs';
138
135
  export { rest } from './function/rest.mjs';
139
136
  export { spread } from './function/spread.mjs';
@@ -147,6 +144,8 @@ export { max } from './math/max.mjs';
147
144
  export { min } from './math/min.mjs';
148
145
  export { parseInt } from './math/parseInt.mjs';
149
146
  export { random } from './math/random.mjs';
147
+ export { range } from './math/range.mjs';
148
+ export { rangeRight } from './math/rangeRight.mjs';
150
149
  export { round } from './math/round.mjs';
151
150
  export { sum } from './math/sum.mjs';
152
151
  export { sumBy } from './math/sumBy.mjs';
@@ -154,10 +153,12 @@ export { assignIn, assignIn as extend } from './object/assignIn.mjs';
154
153
  export { cloneDeep } from './object/cloneDeep.mjs';
155
154
  export { cloneDeepWith } from './object/cloneDeepWith.mjs';
156
155
  export { defaults } from './object/defaults.mjs';
156
+ export { findKey } from './object/findKey.mjs';
157
157
  export { fromPairs } from './object/fromPairs.mjs';
158
158
  export { get } from './object/get.mjs';
159
159
  export { has } from './object/has.mjs';
160
160
  export { invertBy } from './object/invertBy.mjs';
161
+ export { keys } from './object/keys.mjs';
161
162
  export { keysIn } from './object/keysIn.mjs';
162
163
  export { mapKeys } from './object/mapKeys.mjs';
163
164
  export { mapValues } from './object/mapValues.mjs';
@@ -166,6 +167,7 @@ export { mergeWith } from './object/mergeWith.mjs';
166
167
  export { omit } from './object/omit.mjs';
167
168
  export { pick } from './object/pick.mjs';
168
169
  export { property } from './object/property.mjs';
170
+ export { propertyOf } from './object/propertyOf.mjs';
169
171
  export { set } from './object/set.mjs';
170
172
  export { toDefaulted } from './object/toDefaulted.mjs';
171
173
  export { unset } from './object/unset.mjs';
@@ -202,10 +204,13 @@ export { isWeakSet } from './predicate/isWeakSet.mjs';
202
204
  export { matches } from './predicate/matches.mjs';
203
205
  export { matchesProperty } from './predicate/matchesProperty.mjs';
204
206
  export { camelCase } from './string/camelCase.mjs';
207
+ export { deburr } from './string/deburr.mjs';
205
208
  export { endsWith } from './string/endsWith.mjs';
206
209
  export { escape } from './string/escape.mjs';
210
+ export { escapeRegExp } from './string/escapeRegExp.mjs';
207
211
  export { kebabCase } from './string/kebabCase.mjs';
208
212
  export { lowerCase } from './string/lowerCase.mjs';
213
+ export { lowerFirst } from './string/lowerFirst.mjs';
209
214
  export { pad } from './string/pad.mjs';
210
215
  export { padEnd } from './string/padEnd.mjs';
211
216
  export { padStart } from './string/padStart.mjs';
@@ -215,17 +220,30 @@ export { snakeCase } from './string/snakeCase.mjs';
215
220
  export { startCase } from './string/startCase.mjs';
216
221
  export { startsWith } from './string/startsWith.mjs';
217
222
  export { template, templateSettings } from './string/template.mjs';
223
+ export { toLower } from './string/toLower.mjs';
218
224
  export { toUpper } from './string/toUpper.mjs';
219
225
  export { trim } from './string/trim.mjs';
220
226
  export { trimEnd } from './string/trimEnd.mjs';
221
227
  export { trimStart } from './string/trimStart.mjs';
228
+ export { unescape } from './string/unescape.mjs';
222
229
  export { upperCase } from './string/upperCase.mjs';
230
+ export { upperFirst } from './string/upperFirst.mjs';
223
231
  export { words } from './string/words.mjs';
224
232
  export { constant } from './util/constant.mjs';
225
233
  export { defaultTo } from './util/defaultTo.mjs';
226
234
  export { gt } from './util/gt.mjs';
227
235
  export { gte } from './util/gte.mjs';
236
+ export { invoke } from './util/invoke.mjs';
228
237
  export { iteratee } from './util/iteratee.mjs';
238
+ export { lt } from './util/lt.mjs';
239
+ export { lte } from './util/lte.mjs';
240
+ export { method } from './util/method.mjs';
241
+ export { now } from './util/now.mjs';
242
+ export { stubArray } from './util/stubArray.mjs';
243
+ export { stubFalse } from './util/stubFalse.mjs';
244
+ export { stubObject } from './util/stubObject.mjs';
245
+ export { stubString } from './util/stubString.mjs';
246
+ export { stubTrue } from './util/stubTrue.mjs';
229
247
  export { times } from './util/times.mjs';
230
248
  export { toArray } from './util/toArray.mjs';
231
249
  export { toFinite } from './util/toFinite.mjs';
@@ -233,6 +251,6 @@ export { toInteger } from './util/toInteger.mjs';
233
251
  export { toLength } from './util/toLength.mjs';
234
252
  export { toNumber } from './util/toNumber.mjs';
235
253
  export { toPath } from './util/toPath.mjs';
254
+ export { toPlainObject } from './util/toPlainObject.mjs';
236
255
  export { toSafeInteger } from './util/toSafeInteger.mjs';
237
256
  export { toString } from './util/toString.mjs';
238
- export { uniqueId } from './util/uniqueId.mjs';
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Returns an array of numbers from `0` (inclusive) to `end` (exclusive), incrementing by `1`.
3
+ *
4
+ * @param {number} end - The end number of the range (exclusive).
5
+ * @returns {number[]} An array of numbers from `0` (inclusive) to `end` (exclusive) with a step of `1`.
6
+ *
7
+ * @example
8
+ * // Returns [0, 1, 2, 3]
9
+ * range(4);
10
+ */
11
+ declare function range(end: number): number[];
12
+ /**
13
+ * Returns an array of numbers from `start` (inclusive) to `end` (exclusive), incrementing by `1`.
14
+ *
15
+ * @param {number} start - The starting number of the range (inclusive).
16
+ * @param {number} end - The end number of the range (exclusive).
17
+ * @returns {number[]} An array of numbers from `start` (inclusive) to `end` (exclusive) with a step of `1`.
18
+ *
19
+ * @example
20
+ * // Returns [1, 2, 3]
21
+ * range(1, 4);
22
+ */
23
+ declare function range(start: number, end: number): number[];
24
+ /**
25
+ * Returns an array of numbers from `start` (inclusive) to `end` (exclusive), incrementing by `step`.
26
+ *
27
+ * @param {number} start - The starting number of the range (inclusive).
28
+ * @param {number} end - The end number of the range (exclusive).
29
+ * @param {number} step - The step value for the range.
30
+ * @returns {number[]} An array of numbers from `start` (inclusive) to `end` (exclusive) with the specified `step`.
31
+ *
32
+ * @example
33
+ * // Returns [0, 5, 10, 15]
34
+ * range(0, 20, 5);
35
+ */
36
+ declare function range(start: number, end: number, step: number): number[];
37
+ /**
38
+ * Enables use as an iteratee for methods like `_.map`.
39
+ *
40
+ * @param {number} end - The current iteratee value.
41
+ * @param {PropertyKey} index - The iteration index.
42
+ * @param {object} guard - The iteratee object.
43
+ * @returns {number[]} An array of numbers from `start` (inclusive) to `end` (exclusive) with the specified `step`.
44
+ */
45
+ declare function range(end: number, index: PropertyKey, guard: object): number[];
46
+
47
+ export { range };
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Returns an array of numbers from `0` (inclusive) to `end` (exclusive), incrementing by `1`.
3
+ *
4
+ * @param {number} end - The end number of the range (exclusive).
5
+ * @returns {number[]} An array of numbers from `0` (inclusive) to `end` (exclusive) with a step of `1`.
6
+ *
7
+ * @example
8
+ * // Returns [0, 1, 2, 3]
9
+ * range(4);
10
+ */
11
+ declare function range(end: number): number[];
12
+ /**
13
+ * Returns an array of numbers from `start` (inclusive) to `end` (exclusive), incrementing by `1`.
14
+ *
15
+ * @param {number} start - The starting number of the range (inclusive).
16
+ * @param {number} end - The end number of the range (exclusive).
17
+ * @returns {number[]} An array of numbers from `start` (inclusive) to `end` (exclusive) with a step of `1`.
18
+ *
19
+ * @example
20
+ * // Returns [1, 2, 3]
21
+ * range(1, 4);
22
+ */
23
+ declare function range(start: number, end: number): number[];
24
+ /**
25
+ * Returns an array of numbers from `start` (inclusive) to `end` (exclusive), incrementing by `step`.
26
+ *
27
+ * @param {number} start - The starting number of the range (inclusive).
28
+ * @param {number} end - The end number of the range (exclusive).
29
+ * @param {number} step - The step value for the range.
30
+ * @returns {number[]} An array of numbers from `start` (inclusive) to `end` (exclusive) with the specified `step`.
31
+ *
32
+ * @example
33
+ * // Returns [0, 5, 10, 15]
34
+ * range(0, 20, 5);
35
+ */
36
+ declare function range(start: number, end: number, step: number): number[];
37
+ /**
38
+ * Enables use as an iteratee for methods like `_.map`.
39
+ *
40
+ * @param {number} end - The current iteratee value.
41
+ * @param {PropertyKey} index - The iteration index.
42
+ * @param {object} guard - The iteratee object.
43
+ * @returns {number[]} An array of numbers from `start` (inclusive) to `end` (exclusive) with the specified `step`.
44
+ */
45
+ declare function range(end: number, index: PropertyKey, guard: object): number[];
46
+
47
+ export { range };
@@ -0,0 +1,26 @@
1
+ import { isIterateeCall } from '../_internal/isIterateeCall.mjs';
2
+ import { toFinite } from '../util/toFinite.mjs';
3
+
4
+ function range(start, end, step) {
5
+ if (step && typeof step !== 'number' && isIterateeCall(start, end, step)) {
6
+ end = step = undefined;
7
+ }
8
+ start = toFinite(start);
9
+ if (end === undefined) {
10
+ end = start;
11
+ start = 0;
12
+ }
13
+ else {
14
+ end = toFinite(end);
15
+ }
16
+ step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
17
+ const length = Math.max(Math.ceil((end - start) / (step || 1)), 0);
18
+ const result = new Array(length);
19
+ for (let index = 0; index < length; index++) {
20
+ result[index] = start;
21
+ start += step;
22
+ }
23
+ return result;
24
+ }
25
+
26
+ export { range };
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Returns an array of numbers from `end` (exclusive) to `0` (inclusive), decrementing by `1`.
3
+ *
4
+ * @param {number} end - The end number of the range (exclusive).
5
+ * @returns {number[]} An array of numbers from `end` (exclusive) to `0` (inclusive) with a step of `1`.
6
+ *
7
+ * @example
8
+ * // Returns [3, 2, 1, 0]
9
+ * rangeRight(4);
10
+ */
11
+ declare function rangeRight(end: number): number[];
12
+ /**
13
+ * Returns an array of numbers from `end` (exclusive) to `start` (inclusive), decrementing by `1`.
14
+ *
15
+ * @param {number} start - The starting number of the range (inclusive).
16
+ * @param {number} end - The end number of the range (exclusive).
17
+ * @returns {number[]} An array of numbers from `end` (exclusive) to `start` (inclusive) with a step of `1`.
18
+ *
19
+ * @example
20
+ * // Returns [3, 2, 1]
21
+ * rangeRight(1, 4);
22
+ */
23
+ declare function rangeRight(start: number, end: number): number[];
24
+ /**
25
+ * Returns an array of numbers from `end` (exclusive) to `start` (inclusive), decrementing by `step`.
26
+ *
27
+ * @param {number} start - The starting number of the range (inclusive).
28
+ * @param {number} end - The end number of the range (exclusive).
29
+ * @param {number} step - The step value for the range.
30
+ * @returns {number[]} An array of numbers from `end` (exclusive) to `start` (inclusive) with the specified `step`.
31
+ *
32
+ * @example
33
+ * // Returns [15, 10, 5, 0]
34
+ * rangeRight(0, 20, 5);
35
+ */
36
+ declare function rangeRight(start: number, end: number, step: number): number[];
37
+ /**
38
+ * Enables use as an iteratee for methods like `_.map`.
39
+ *
40
+ * @param {number} end - The current iteratee value.
41
+ * @param {PropertyKey} index - The iteration index.
42
+ * @param {object} guard - The iteratee object.
43
+ * @returns {number[]} An array of numbers from `start` (inclusive) to `end` (exclusive) with the specified `step`.
44
+ */
45
+ declare function rangeRight(end: number, index: PropertyKey, guard: object): number[];
46
+
47
+ export { rangeRight };
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Returns an array of numbers from `end` (exclusive) to `0` (inclusive), decrementing by `1`.
3
+ *
4
+ * @param {number} end - The end number of the range (exclusive).
5
+ * @returns {number[]} An array of numbers from `end` (exclusive) to `0` (inclusive) with a step of `1`.
6
+ *
7
+ * @example
8
+ * // Returns [3, 2, 1, 0]
9
+ * rangeRight(4);
10
+ */
11
+ declare function rangeRight(end: number): number[];
12
+ /**
13
+ * Returns an array of numbers from `end` (exclusive) to `start` (inclusive), decrementing by `1`.
14
+ *
15
+ * @param {number} start - The starting number of the range (inclusive).
16
+ * @param {number} end - The end number of the range (exclusive).
17
+ * @returns {number[]} An array of numbers from `end` (exclusive) to `start` (inclusive) with a step of `1`.
18
+ *
19
+ * @example
20
+ * // Returns [3, 2, 1]
21
+ * rangeRight(1, 4);
22
+ */
23
+ declare function rangeRight(start: number, end: number): number[];
24
+ /**
25
+ * Returns an array of numbers from `end` (exclusive) to `start` (inclusive), decrementing by `step`.
26
+ *
27
+ * @param {number} start - The starting number of the range (inclusive).
28
+ * @param {number} end - The end number of the range (exclusive).
29
+ * @param {number} step - The step value for the range.
30
+ * @returns {number[]} An array of numbers from `end` (exclusive) to `start` (inclusive) with the specified `step`.
31
+ *
32
+ * @example
33
+ * // Returns [15, 10, 5, 0]
34
+ * rangeRight(0, 20, 5);
35
+ */
36
+ declare function rangeRight(start: number, end: number, step: number): number[];
37
+ /**
38
+ * Enables use as an iteratee for methods like `_.map`.
39
+ *
40
+ * @param {number} end - The current iteratee value.
41
+ * @param {PropertyKey} index - The iteration index.
42
+ * @param {object} guard - The iteratee object.
43
+ * @returns {number[]} An array of numbers from `start` (inclusive) to `end` (exclusive) with the specified `step`.
44
+ */
45
+ declare function rangeRight(end: number, index: PropertyKey, guard: object): number[];
46
+
47
+ export { rangeRight };
@@ -0,0 +1,26 @@
1
+ import { isIterateeCall } from '../_internal/isIterateeCall.mjs';
2
+ import { toFinite } from '../util/toFinite.mjs';
3
+
4
+ function rangeRight(start, end, step) {
5
+ if (step && typeof step !== 'number' && isIterateeCall(start, end, step)) {
6
+ end = step = undefined;
7
+ }
8
+ start = toFinite(start);
9
+ if (end === undefined) {
10
+ end = start;
11
+ start = 0;
12
+ }
13
+ else {
14
+ end = toFinite(end);
15
+ }
16
+ step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
17
+ const length = Math.max(Math.ceil((end - start) / (step || 1)), 0);
18
+ const result = new Array(length);
19
+ for (let index = length - 1; index >= 0; index--) {
20
+ result[index] = start;
21
+ start += step;
22
+ }
23
+ return result;
24
+ }
25
+
26
+ export { rangeRight };
@@ -34,7 +34,7 @@ declare function sumBy(array: ArrayLike<bigint>): bigint;
34
34
  */
35
35
  declare function sumBy(array: ArrayLike<unknown> | null | undefined): unknown;
36
36
  /**
37
- * Compmutes the sum of the `number` values that are returned by the `iteratee` function.
37
+ * Computes the sum of the `number` values that are returned by the `iteratee` function.
38
38
  *
39
39
  * @template T - The type of the array elements.
40
40
  * @param {ArrayLike<T>} array - The array to iterate over.
@@ -46,7 +46,7 @@ declare function sumBy(array: ArrayLike<unknown> | null | undefined): unknown;
46
46
  */
47
47
  declare function sumBy<T>(array: ArrayLike<T>, iteratee: (value: T) => number): number;
48
48
  /**
49
- * Compmutes the sum of the `bigint` values that are returned by the `iteratee` function.
49
+ * Computes the sum of the `bigint` values that are returned by the `iteratee` function.
50
50
  *
51
51
  * NOTE: If the `array` is empty, the function returns `0`.
52
52
  *
@@ -34,7 +34,7 @@ declare function sumBy(array: ArrayLike<bigint>): bigint;
34
34
  */
35
35
  declare function sumBy(array: ArrayLike<unknown> | null | undefined): unknown;
36
36
  /**
37
- * Compmutes the sum of the `number` values that are returned by the `iteratee` function.
37
+ * Computes the sum of the `number` values that are returned by the `iteratee` function.
38
38
  *
39
39
  * @template T - The type of the array elements.
40
40
  * @param {ArrayLike<T>} array - The array to iterate over.
@@ -46,7 +46,7 @@ declare function sumBy(array: ArrayLike<unknown> | null | undefined): unknown;
46
46
  */
47
47
  declare function sumBy<T>(array: ArrayLike<T>, iteratee: (value: T) => number): number;
48
48
  /**
49
- * Compmutes the sum of the `bigint` values that are returned by the `iteratee` function.
49
+ * Computes the sum of the `bigint` values that are returned by the `iteratee` function.
50
50
  *
51
51
  * NOTE: If the `array` is empty, the function returns `0`.
52
52
  *
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Finds the key of the first element predicate returns truthy for.
3
+ *
4
+ * @template T - The type of the object.
5
+ * @param {T | null | undefined} obj - The object to inspect.
6
+ * @param {(value: T[keyof T], key: keyof T, obj: T) => boolean} conditionToFind - The function invoked per iteration.
7
+ * @returns {keyof T | undefined} Returns the key of the matched element, else `undefined`.
8
+ *
9
+ * @example
10
+ * const users = { 'barney': { 'age': 36 }, 'fred': { 'age': 40 } };
11
+ * const result = findKey(users, o => o.age < 40);
12
+ * // => 'barney'
13
+ */
14
+ declare function findKey<T extends Record<any, any>>(obj: T | null | undefined, conditionToFind: (value: T[keyof T], key: keyof T, obj: T) => boolean): keyof T | undefined;
15
+ /**
16
+ * Finds the key of the first element that matches the given object.
17
+ *
18
+ * @template T - The type of the object.
19
+ * @param {T | null | undefined} obj - The object to inspect.
20
+ * @param {Partail<T[keyof T]>} objectToFind - The object to match.
21
+ * @returns {keyof T | undefined} Returns the key of the matched element, else `undefined`.
22
+ *
23
+ * @example
24
+ * const users = { 'barney': { 'age': 36 }, 'fred': { 'age': 40 } };
25
+ * const result = findKey(users, { 'age': 36 });
26
+ * // => 'barney'
27
+ */
28
+ declare function findKey<T extends Record<any, any>>(obj: T | null | undefined, objectToFind: Partial<T[keyof T]>): keyof T | undefined;
29
+ /**
30
+ * Finds the key of the first element that matches the given property and value.
31
+ *
32
+ * @template T - The type of the object.
33
+ * @param {T | null | undefined} obj - The object to inspect.
34
+ * @param {[keyof T[keyof T], any]} propertyToFind - The property and value to match.
35
+ * @returns {keyof T | undefined} Returns the key of the matched element, else `undefined`.
36
+ *
37
+ * @example
38
+ * const users = { 'barney': { 'age': 36 }, 'fred': { 'age': 40 } };
39
+ * const result = findKey(users, ['age', 36]);
40
+ * // => 'barney'
41
+ */
42
+ declare function findKey<T extends Record<any, any>>(obj: T | null | undefined, propertyToFind: [keyof T[keyof T], any]): keyof T | undefined;
43
+ /**
44
+ * Finds the key of the first element that has a truthy value for the given property.
45
+ *
46
+ * @template T - The type of the object.
47
+ * @param {T | null | undefined} obj - The object to inspect.
48
+ * @param {keyof T[keyof T]} propertyToFind - The property to check.
49
+ * @returns {keyof T | undefined} Returns the key of the matched element, else `undefined`.
50
+ *
51
+ * @example
52
+ * const users = { 'barney': { 'active': true }, 'fred': { 'active': false } };
53
+ * const result = findKey(users, 'active');
54
+ * // => 'barney'
55
+ */
56
+ declare function findKey<T extends Record<any, any>>(obj: T | null | undefined, propertyToFind: keyof T[keyof T]): keyof T | undefined;
57
+
58
+ export { findKey };
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Finds the key of the first element predicate returns truthy for.
3
+ *
4
+ * @template T - The type of the object.
5
+ * @param {T | null | undefined} obj - The object to inspect.
6
+ * @param {(value: T[keyof T], key: keyof T, obj: T) => boolean} conditionToFind - The function invoked per iteration.
7
+ * @returns {keyof T | undefined} Returns the key of the matched element, else `undefined`.
8
+ *
9
+ * @example
10
+ * const users = { 'barney': { 'age': 36 }, 'fred': { 'age': 40 } };
11
+ * const result = findKey(users, o => o.age < 40);
12
+ * // => 'barney'
13
+ */
14
+ declare function findKey<T extends Record<any, any>>(obj: T | null | undefined, conditionToFind: (value: T[keyof T], key: keyof T, obj: T) => boolean): keyof T | undefined;
15
+ /**
16
+ * Finds the key of the first element that matches the given object.
17
+ *
18
+ * @template T - The type of the object.
19
+ * @param {T | null | undefined} obj - The object to inspect.
20
+ * @param {Partail<T[keyof T]>} objectToFind - The object to match.
21
+ * @returns {keyof T | undefined} Returns the key of the matched element, else `undefined`.
22
+ *
23
+ * @example
24
+ * const users = { 'barney': { 'age': 36 }, 'fred': { 'age': 40 } };
25
+ * const result = findKey(users, { 'age': 36 });
26
+ * // => 'barney'
27
+ */
28
+ declare function findKey<T extends Record<any, any>>(obj: T | null | undefined, objectToFind: Partial<T[keyof T]>): keyof T | undefined;
29
+ /**
30
+ * Finds the key of the first element that matches the given property and value.
31
+ *
32
+ * @template T - The type of the object.
33
+ * @param {T | null | undefined} obj - The object to inspect.
34
+ * @param {[keyof T[keyof T], any]} propertyToFind - The property and value to match.
35
+ * @returns {keyof T | undefined} Returns the key of the matched element, else `undefined`.
36
+ *
37
+ * @example
38
+ * const users = { 'barney': { 'age': 36 }, 'fred': { 'age': 40 } };
39
+ * const result = findKey(users, ['age', 36]);
40
+ * // => 'barney'
41
+ */
42
+ declare function findKey<T extends Record<any, any>>(obj: T | null | undefined, propertyToFind: [keyof T[keyof T], any]): keyof T | undefined;
43
+ /**
44
+ * Finds the key of the first element that has a truthy value for the given property.
45
+ *
46
+ * @template T - The type of the object.
47
+ * @param {T | null | undefined} obj - The object to inspect.
48
+ * @param {keyof T[keyof T]} propertyToFind - The property to check.
49
+ * @returns {keyof T | undefined} Returns the key of the matched element, else `undefined`.
50
+ *
51
+ * @example
52
+ * const users = { 'barney': { 'active': true }, 'fred': { 'active': false } };
53
+ * const result = findKey(users, 'active');
54
+ * // => 'barney'
55
+ */
56
+ declare function findKey<T extends Record<any, any>>(obj: T | null | undefined, propertyToFind: keyof T[keyof T]): keyof T | undefined;
57
+
58
+ export { findKey };
@@ -0,0 +1,30 @@
1
+ import { property } from './property.mjs';
2
+ import { findKey as findKey$1 } from '../../object/findKey.mjs';
3
+ import { isObject } from '../predicate/isObject.mjs';
4
+ import { matches } from '../predicate/matches.mjs';
5
+ import { matchesProperty } from '../predicate/matchesProperty.mjs';
6
+
7
+ function findKey(obj, predicate) {
8
+ if (!isObject(obj)) {
9
+ return undefined;
10
+ }
11
+ return findKeyImpl(obj, predicate);
12
+ }
13
+ function findKeyImpl(obj, predicate) {
14
+ if (typeof predicate === 'function') {
15
+ return findKey$1(obj, predicate);
16
+ }
17
+ if (typeof predicate === 'object') {
18
+ if (Array.isArray(predicate)) {
19
+ const key = predicate[0];
20
+ const value = predicate[1];
21
+ return findKey$1(obj, matchesProperty(key, value));
22
+ }
23
+ return findKey$1(obj, matches(predicate));
24
+ }
25
+ if (typeof predicate === 'string') {
26
+ return findKey$1(obj, property(predicate));
27
+ }
28
+ }
29
+
30
+ export { findKey };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Creates an array of the own enumerable property names of `object`.
3
+ *
4
+ * Non-object values are coerced to objects.
5
+ *
6
+ * @param {object} object The object to query.
7
+ * @returns {string[]} Returns the array of property names.
8
+ * @example
9
+ * function Foo() {
10
+ * this.a = 1;
11
+ * this.b = 2;
12
+ * }
13
+ * Foo.prototype.c = 3;
14
+ * keys(new Foo); // ['a', 'b'] (iteration order is not guaranteed)
15
+ *
16
+ * keys('hi'); // ['0', '1']
17
+ * keys([1, 2, 3]); // ['0', '1', '2']
18
+ * keys({ a: 1, b: 2 }); // ['a', 'b']
19
+ */
20
+ declare function keys(object?: any): string[];
21
+
22
+ export { keys };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Creates an array of the own enumerable property names of `object`.
3
+ *
4
+ * Non-object values are coerced to objects.
5
+ *
6
+ * @param {object} object The object to query.
7
+ * @returns {string[]} Returns the array of property names.
8
+ * @example
9
+ * function Foo() {
10
+ * this.a = 1;
11
+ * this.b = 2;
12
+ * }
13
+ * Foo.prototype.c = 3;
14
+ * keys(new Foo); // ['a', 'b'] (iteration order is not guaranteed)
15
+ *
16
+ * keys('hi'); // ['0', '1']
17
+ * keys([1, 2, 3]); // ['0', '1', '2']
18
+ * keys({ a: 1, b: 2 }); // ['a', 'b']
19
+ */
20
+ declare function keys(object?: any): string[];
21
+
22
+ export { keys };