es-toolkit 1.35.0 → 1.36.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 (106) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/_chunk/{isPromise-ByAybB.js → isPromise-CxqI1v.js} +122 -36
  3. package/dist/_chunk/{reverseString-D-wK2p.js → reverseString-BixeGz.js} +84 -13
  4. package/dist/_chunk/toSnakeCaseKeys-DZO2eB.js +4901 -0
  5. package/dist/_chunk/{unary-BsNWRM.js → unary-EIEhcF.js} +46 -0
  6. package/dist/_chunk/{zip-_HttSl.js → zip-BJSrRi.js} +38 -57
  7. package/dist/array/index.js +55 -6
  8. package/dist/array/pullAt.d.mts +0 -2
  9. package/dist/array/pullAt.d.ts +0 -2
  10. package/dist/array/take.d.mts +1 -1
  11. package/dist/array/take.d.ts +1 -1
  12. package/dist/array/take.mjs +4 -1
  13. package/dist/array/takeRight.d.mts +1 -1
  14. package/dist/array/takeRight.d.ts +1 -1
  15. package/dist/array/takeRight.mjs +5 -2
  16. package/dist/browser.global.js +1 -1
  17. package/dist/browser.global.js.map +1 -1
  18. package/dist/compat/_internal/copyArray.mjs +12 -0
  19. package/dist/compat/_internal/mapToEntries.mjs +11 -0
  20. package/dist/compat/_internal/setToEntries.mjs +11 -0
  21. package/dist/compat/_internal/toKey.mjs +2 -2
  22. package/dist/compat/array/find.mjs +3 -3
  23. package/dist/compat/array/findLast.mjs +2 -2
  24. package/dist/compat/array/flatMap.d.mts +20 -0
  25. package/dist/compat/array/flatMap.d.ts +20 -0
  26. package/dist/compat/array/flatMap.mjs +13 -0
  27. package/dist/compat/array/forEachRight.d.mts +106 -0
  28. package/dist/compat/array/forEachRight.d.ts +106 -0
  29. package/dist/compat/array/forEachRight.mjs +21 -0
  30. package/dist/compat/array/groupBy.d.mts +55 -0
  31. package/dist/compat/array/groupBy.d.ts +55 -0
  32. package/dist/compat/array/groupBy.mjs +15 -0
  33. package/dist/compat/array/partition.d.mts +65 -0
  34. package/dist/compat/array/partition.d.ts +65 -0
  35. package/dist/compat/array/partition.mjs +24 -0
  36. package/dist/compat/array/pullAllWith.d.mts +59 -0
  37. package/dist/compat/array/pullAllWith.d.ts +59 -0
  38. package/dist/compat/array/pullAllWith.mjs +33 -0
  39. package/dist/compat/array/pullAt.d.mts +32 -0
  40. package/dist/compat/array/pullAt.d.ts +32 -0
  41. package/dist/compat/array/pullAt.mjs +34 -0
  42. package/dist/compat/compat.d.mts +310 -0
  43. package/dist/compat/compat.d.ts +310 -0
  44. package/dist/compat/compat.mjs +312 -0
  45. package/dist/compat/function/partial.d.mts +575 -0
  46. package/dist/compat/function/partial.d.ts +575 -0
  47. package/dist/compat/function/partial.mjs +8 -0
  48. package/dist/compat/function/partialRight.d.mts +651 -0
  49. package/dist/compat/function/partialRight.d.ts +651 -0
  50. package/dist/compat/function/partialRight.mjs +8 -0
  51. package/dist/compat/index.d.mts +16 -7
  52. package/dist/compat/index.d.ts +16 -7
  53. package/dist/compat/index.js +290 -3771
  54. package/dist/compat/index.mjs +19 -8
  55. package/dist/compat/object/defaults.mjs +7 -1
  56. package/dist/compat/object/forIn.d.mts +58 -0
  57. package/dist/compat/object/forIn.d.ts +58 -0
  58. package/dist/compat/object/forIn.mjs +16 -0
  59. package/dist/compat/object/forInRight.d.mts +58 -0
  60. package/dist/compat/object/forInRight.d.ts +58 -0
  61. package/dist/compat/object/forInRight.mjs +21 -0
  62. package/dist/compat/object/forOwn.d.mts +54 -0
  63. package/dist/compat/object/forOwn.d.ts +54 -0
  64. package/dist/compat/object/forOwn.mjs +19 -0
  65. package/dist/compat/object/forOwnRight.d.mts +54 -0
  66. package/dist/compat/object/forOwnRight.d.ts +54 -0
  67. package/dist/compat/object/forOwnRight.mjs +19 -0
  68. package/dist/compat/object/hasIn.d.mts +40 -0
  69. package/dist/compat/object/hasIn.d.ts +40 -0
  70. package/dist/compat/object/hasIn.mjs +34 -0
  71. package/dist/compat/object/toPairs.mjs +7 -2
  72. package/dist/compat/object/toPairsIn.mjs +7 -2
  73. package/dist/compat/string/repeat.d.mts +1 -1
  74. package/dist/compat/string/repeat.d.ts +1 -1
  75. package/dist/compat/string/repeat.mjs +12 -2
  76. package/dist/compat/string/words.d.mts +1 -1
  77. package/dist/compat/string/words.d.ts +1 -1
  78. package/dist/compat/string/words.mjs +2 -1
  79. package/dist/compat/toolkit.d.mts +9 -0
  80. package/dist/compat/toolkit.d.ts +9 -0
  81. package/dist/compat/toolkit.mjs +10 -0
  82. package/dist/compat/util/overEvery.d.mts +67 -0
  83. package/dist/compat/util/overEvery.d.ts +67 -0
  84. package/dist/compat/util/overEvery.mjs +23 -0
  85. package/dist/compat/util/overSome.d.mts +69 -0
  86. package/dist/compat/util/overSome.d.ts +69 -0
  87. package/dist/compat/util/overSome.mjs +23 -0
  88. package/dist/function/index.js +3 -5
  89. package/dist/function/partial.d.mts +3 -3
  90. package/dist/function/partial.d.ts +3 -3
  91. package/dist/function/partial.mjs +17 -19
  92. package/dist/function/partialRight.d.mts +3 -3
  93. package/dist/function/partialRight.d.ts +3 -3
  94. package/dist/function/partialRight.mjs +18 -20
  95. package/dist/function/throttle.mjs +0 -1
  96. package/dist/index.js +39 -42
  97. package/dist/object/index.js +15 -15
  98. package/dist/object/toCamelCaseKeys.mjs +3 -0
  99. package/dist/object/toSnakeCaseKeys.mjs +3 -0
  100. package/dist/predicate/index.js +4 -5
  101. package/dist/string/index.js +7 -8
  102. package/package.json +1 -1
  103. package/dist/_chunk/isPlainObject-Xaozpc.js +0 -93
  104. package/dist/_chunk/partialRight-B0_CSB.js +0 -50
  105. package/dist/_chunk/snakeCase-BtVEeB.js +0 -75
  106. package/dist/_chunk/toSnakeCaseKeys-BNpS71.js +0 -569
@@ -1,16 +1,12 @@
1
1
  export { countBy } from '../array/countBy.mjs';
2
- export { flatMap } from '../array/flatMap.mjs';
3
2
  export { flatMapDeep } from '../array/flatMapDeep.mjs';
4
- export { forEachRight } from '../array/forEachRight.mjs';
5
- export { groupBy } from '../array/groupBy.mjs';
6
3
  export { initial } from '../array/initial.mjs';
7
4
  export { isSubset } from '../array/isSubset.mjs';
8
5
  export { isSubsetWith } from '../array/isSubsetWith.mjs';
9
6
  export { keyBy } from '../array/keyBy.mjs';
10
- export { partition } from '../array/partition.mjs';
11
- export { pullAt } from '../array/pullAt.mjs';
12
7
  export { sampleSize } from '../array/sampleSize.mjs';
13
8
  export { shuffle } from '../array/shuffle.mjs';
9
+ export { toInteger } from './util/toInteger.mjs';
14
10
  export { toFilled } from '../array/toFilled.mjs';
15
11
  export { unzipWith } from '../array/unzipWith.mjs';
16
12
  export { windowed } from '../array/windowed.mjs';
@@ -24,8 +20,8 @@ export { identity } from '../function/identity.mjs';
24
20
  export { memoize } from '../function/memoize.mjs';
25
21
  export { noop } from '../function/noop.mjs';
26
22
  export { once } from '../function/once.mjs';
27
- export { partial } from '../function/partial.mjs';
28
- export { partialRight } from '../function/partialRight.mjs';
23
+ import '../function/partial.mjs';
24
+ import '../function/partialRight.mjs';
29
25
  export { retry } from '../function/retry.mjs';
30
26
  export { unary } from '../function/unary.mjs';
31
27
  export { median } from '../math/median.mjs';
@@ -83,10 +79,13 @@ export { find } from './array/find.mjs';
83
79
  export { findIndex } from './array/findIndex.mjs';
84
80
  export { findLast } from './array/findLast.mjs';
85
81
  export { findLastIndex } from './array/findLastIndex.mjs';
82
+ export { flatMap } from './array/flatMap.mjs';
86
83
  export { flatten } from './array/flatten.mjs';
87
84
  export { flattenDeep } from './array/flattenDeep.mjs';
88
85
  export { flattenDepth } from './array/flattenDepth.mjs';
89
86
  export { forEach as each, forEach } from './array/forEach.mjs';
87
+ export { forEachRight as eachRight, forEachRight } from './array/forEachRight.mjs';
88
+ export { groupBy } from './array/groupBy.mjs';
90
89
  export { head as first, head } from './array/head.mjs';
91
90
  export { includes } from './array/includes.mjs';
92
91
  export { indexOf } from './array/indexOf.mjs';
@@ -99,9 +98,12 @@ export { lastIndexOf } from './array/lastIndexOf.mjs';
99
98
  export { map } from './array/map.mjs';
100
99
  export { nth } from './array/nth.mjs';
101
100
  export { orderBy } from './array/orderBy.mjs';
101
+ export { partition } from './array/partition.mjs';
102
102
  export { pull } from './array/pull.mjs';
103
103
  export { pullAll } from './array/pullAll.mjs';
104
104
  export { pullAllBy } from './array/pullAllBy.mjs';
105
+ export { pullAllWith } from './array/pullAllWith.mjs';
106
+ export { pullAt } from './array/pullAt.mjs';
105
107
  export { reduce } from './array/reduce.mjs';
106
108
  export { reduceRight } from './array/reduceRight.mjs';
107
109
  export { reject } from './array/reject.mjs';
@@ -150,6 +152,8 @@ export { flow } from './function/flow.mjs';
150
152
  export { flowRight } from './function/flowRight.mjs';
151
153
  export { negate } from './function/negate.mjs';
152
154
  export { nthArg } from './function/nthArg.mjs';
155
+ export { partial } from './function/partial.mjs';
156
+ export { partialRight } from './function/partialRight.mjs';
153
157
  export { rearg } from './function/rearg.mjs';
154
158
  export { rest } from './function/rest.mjs';
155
159
  export { spread } from './function/spread.mjs';
@@ -185,11 +189,16 @@ export { cloneDeepWith } from './object/cloneDeepWith.mjs';
185
189
  export { create } from './object/create.mjs';
186
190
  export { defaults } from './object/defaults.mjs';
187
191
  export { findKey } from './object/findKey.mjs';
192
+ export { forIn } from './object/forIn.mjs';
193
+ export { forInRight } from './object/forInRight.mjs';
194
+ export { forOwn } from './object/forOwn.mjs';
195
+ export { forOwnRight } from './object/forOwnRight.mjs';
188
196
  export { fromPairs } from './object/fromPairs.mjs';
189
197
  export { functions } from './object/functions.mjs';
190
198
  export { functionsIn } from './object/functionsIn.mjs';
191
199
  export { get } from './object/get.mjs';
192
200
  export { has } from './object/has.mjs';
201
+ export { hasIn } from './object/hasIn.mjs';
193
202
  export { invertBy } from './object/invertBy.mjs';
194
203
  export { keys } from './object/keys.mjs';
195
204
  export { keysIn } from './object/keysIn.mjs';
@@ -284,6 +293,8 @@ export { method } from './util/method.mjs';
284
293
  export { methodOf } from './util/methodOf.mjs';
285
294
  export { now } from './util/now.mjs';
286
295
  export { over } from './util/over.mjs';
296
+ export { overEvery } from './util/overEvery.mjs';
297
+ export { overSome } from './util/overSome.mjs';
287
298
  export { stubArray } from './util/stubArray.mjs';
288
299
  export { stubFalse } from './util/stubFalse.mjs';
289
300
  export { stubObject } from './util/stubObject.mjs';
@@ -292,7 +303,6 @@ export { stubTrue } from './util/stubTrue.mjs';
292
303
  export { times } from './util/times.mjs';
293
304
  export { toArray } from './util/toArray.mjs';
294
305
  export { toFinite } from './util/toFinite.mjs';
295
- export { toInteger } from './util/toInteger.mjs';
296
306
  export { toLength } from './util/toLength.mjs';
297
307
  export { toNumber } from './util/toNumber.mjs';
298
308
  export { toPath } from './util/toPath.mjs';
@@ -300,3 +310,4 @@ export { toPlainObject } from './util/toPlainObject.mjs';
300
310
  export { toSafeInteger } from './util/toSafeInteger.mjs';
301
311
  export { toString } from './util/toString.mjs';
302
312
  export { uniqueId } from './util/uniqueId.mjs';
313
+ export { toolkit as default } from './toolkit.mjs';
@@ -1,9 +1,15 @@
1
+ import { isIterateeCall } from '../_internal/isIterateeCall.mjs';
1
2
  import { eq } from '../util/eq.mjs';
2
3
 
3
4
  function defaults(object, ...sources) {
4
5
  object = Object(object);
5
6
  const objectProto = Object.prototype;
6
- for (let i = 0; i < sources.length; i++) {
7
+ let length = sources.length;
8
+ const guard = length > 2 ? sources[2] : undefined;
9
+ if (guard && isIterateeCall(sources[0], sources[1], guard)) {
10
+ length = 1;
11
+ }
12
+ for (let i = 0; i < length; i++) {
7
13
  const source = sources[i];
8
14
  const keys = Object.keys(source);
9
15
  for (let j = 0; j < keys.length; j++) {
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Iterates over an object and invokes the `iteratee` function for each property.
3
+ *
4
+ * Iterates over string keyed properties including inherited properties.
5
+ *
6
+ * The iteration is terminated early if the `iteratee` function returns `false`.
7
+ *
8
+ * @template T - The type of the object
9
+ * @param {T} object - The object to iterate over
10
+ * @param {(value: T[keyof T], key: string, obj: T) => any} iteratee - The function invoked per iteration
11
+ * @returns {T} Returns the object
12
+ *
13
+ * @example
14
+ * // Iterate over all properties including inherited ones
15
+ * const obj = { a: 1, b: 2 };
16
+ * forIn(obj, (value, key) => {
17
+ * console.log(key, value);
18
+ * });
19
+ * // Output: 'a' 1, 'b' 2
20
+ *
21
+ * // Early termination
22
+ * forIn(obj, (value, key) => {
23
+ * console.log(key, value);
24
+ * return key !== 'a'; // stop after 'a'
25
+ * });
26
+ * // Output: 'a' 1
27
+ */
28
+ declare function forIn<T>(object: T, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T;
29
+ /**
30
+ * Iterates over an object and invokes the `iteratee` function for each property.
31
+ *
32
+ * Iterates over string keyed properties including inherited properties.
33
+ *
34
+ * The iteration is terminated early if the `iteratee` function returns `false`.
35
+ *
36
+ * @template T - The type of the object
37
+ * @param {T | null | undefined} object - The object to iterate over
38
+ * @param {(value: T[keyof T], key: string, obj: T) => any} iteratee - The function invoked per iteration
39
+ * @returns {T | null | undefined} Returns the object
40
+ *
41
+ * @example
42
+ * // Iterate over all properties including inherited ones
43
+ * const obj = { a: 1, b: 2 };
44
+ * forIn(obj, (value, key) => {
45
+ * console.log(key, value);
46
+ * });
47
+ * // Output: 'a' 1, 'b' 2
48
+ *
49
+ * // Early termination
50
+ * forIn(obj, (value, key) => {
51
+ * console.log(key, value);
52
+ * return key !== 'a'; // stop after 'a'
53
+ * });
54
+ * // Output: 'a' 1
55
+ */
56
+ declare function forIn<T>(object: T | null | undefined, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T | null | undefined;
57
+
58
+ export { forIn };
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Iterates over an object and invokes the `iteratee` function for each property.
3
+ *
4
+ * Iterates over string keyed properties including inherited properties.
5
+ *
6
+ * The iteration is terminated early if the `iteratee` function returns `false`.
7
+ *
8
+ * @template T - The type of the object
9
+ * @param {T} object - The object to iterate over
10
+ * @param {(value: T[keyof T], key: string, obj: T) => any} iteratee - The function invoked per iteration
11
+ * @returns {T} Returns the object
12
+ *
13
+ * @example
14
+ * // Iterate over all properties including inherited ones
15
+ * const obj = { a: 1, b: 2 };
16
+ * forIn(obj, (value, key) => {
17
+ * console.log(key, value);
18
+ * });
19
+ * // Output: 'a' 1, 'b' 2
20
+ *
21
+ * // Early termination
22
+ * forIn(obj, (value, key) => {
23
+ * console.log(key, value);
24
+ * return key !== 'a'; // stop after 'a'
25
+ * });
26
+ * // Output: 'a' 1
27
+ */
28
+ declare function forIn<T>(object: T, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T;
29
+ /**
30
+ * Iterates over an object and invokes the `iteratee` function for each property.
31
+ *
32
+ * Iterates over string keyed properties including inherited properties.
33
+ *
34
+ * The iteration is terminated early if the `iteratee` function returns `false`.
35
+ *
36
+ * @template T - The type of the object
37
+ * @param {T | null | undefined} object - The object to iterate over
38
+ * @param {(value: T[keyof T], key: string, obj: T) => any} iteratee - The function invoked per iteration
39
+ * @returns {T | null | undefined} Returns the object
40
+ *
41
+ * @example
42
+ * // Iterate over all properties including inherited ones
43
+ * const obj = { a: 1, b: 2 };
44
+ * forIn(obj, (value, key) => {
45
+ * console.log(key, value);
46
+ * });
47
+ * // Output: 'a' 1, 'b' 2
48
+ *
49
+ * // Early termination
50
+ * forIn(obj, (value, key) => {
51
+ * console.log(key, value);
52
+ * return key !== 'a'; // stop after 'a'
53
+ * });
54
+ * // Output: 'a' 1
55
+ */
56
+ declare function forIn<T>(object: T | null | undefined, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T | null | undefined;
57
+
58
+ export { forIn };
@@ -0,0 +1,16 @@
1
+ import { identity } from '../../function/identity.mjs';
2
+
3
+ function forIn(object, iteratee = identity) {
4
+ if (object == null) {
5
+ return object;
6
+ }
7
+ for (const key in object) {
8
+ const result = iteratee(object[key], key, object);
9
+ if (result === false) {
10
+ break;
11
+ }
12
+ }
13
+ return object;
14
+ }
15
+
16
+ export { forIn };
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Iterates over an object in reverse order and invokes the `iteratee` function for each property.
3
+ *
4
+ * Iterates over string keyed properties including inherited properties in reverse order.
5
+ *
6
+ * The iteration is terminated early if the `iteratee` function returns `false`.
7
+ *
8
+ * @template T - The type of the object
9
+ * @param {T} object - The object to iterate over
10
+ * @param {(value: T[keyof T], key: string, collection: T) => any} iteratee - The function invoked per iteration
11
+ * @returns {T} Returns the object
12
+ *
13
+ * @example
14
+ * // Iterate over all properties including inherited ones
15
+ * const obj = { a: 1, b: 2 };
16
+ * forInRight(obj, (value, key) => {
17
+ * console.log(key, value);
18
+ * });
19
+ * // Output: 'b' 2, 'a' 1
20
+ *
21
+ * // Early termination
22
+ * forInRight(obj, (value, key) => {
23
+ * console.log(key, value);
24
+ * return key !== 'a'; // stop after 'a'
25
+ * });
26
+ * // Output: 'b' 2
27
+ */
28
+ declare function forInRight<T>(object: T, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T;
29
+ /**
30
+ * Iterates over an object in reverse order and invokes the `iteratee` function for each property.
31
+ *
32
+ * Iterates over string keyed properties including inherited properties in reverse order.
33
+ *
34
+ * The iteration is terminated early if the `iteratee` function returns `false`.
35
+ *
36
+ * @template T - The type of the object
37
+ * @param {T | null | undefined} object - The object to iterate over
38
+ * @param {(value: T[keyof T], key: string, obj: T) => any} iteratee - The function invoked per iteration
39
+ * @returns {T | null | undefined} Returns the object
40
+ *
41
+ * @example
42
+ * // Iterate over all properties including inherited ones
43
+ * const obj = { a: 1, b: 2 };
44
+ * forInRight(obj, (value, key) => {
45
+ * console.log(key, value);
46
+ * });
47
+ * // Output: 'b' 2, 'a' 1
48
+ *
49
+ * // Early termination
50
+ * forInRight(obj, (value, key) => {
51
+ * console.log(key, value);
52
+ * return key !== 'a'; // stop after 'a'
53
+ * });
54
+ * // Output: 'b' 2
55
+ */
56
+ declare function forInRight<T>(object: T | null | undefined, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T | null | undefined;
57
+
58
+ export { forInRight };
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Iterates over an object in reverse order and invokes the `iteratee` function for each property.
3
+ *
4
+ * Iterates over string keyed properties including inherited properties in reverse order.
5
+ *
6
+ * The iteration is terminated early if the `iteratee` function returns `false`.
7
+ *
8
+ * @template T - The type of the object
9
+ * @param {T} object - The object to iterate over
10
+ * @param {(value: T[keyof T], key: string, collection: T) => any} iteratee - The function invoked per iteration
11
+ * @returns {T} Returns the object
12
+ *
13
+ * @example
14
+ * // Iterate over all properties including inherited ones
15
+ * const obj = { a: 1, b: 2 };
16
+ * forInRight(obj, (value, key) => {
17
+ * console.log(key, value);
18
+ * });
19
+ * // Output: 'b' 2, 'a' 1
20
+ *
21
+ * // Early termination
22
+ * forInRight(obj, (value, key) => {
23
+ * console.log(key, value);
24
+ * return key !== 'a'; // stop after 'a'
25
+ * });
26
+ * // Output: 'b' 2
27
+ */
28
+ declare function forInRight<T>(object: T, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T;
29
+ /**
30
+ * Iterates over an object in reverse order and invokes the `iteratee` function for each property.
31
+ *
32
+ * Iterates over string keyed properties including inherited properties in reverse order.
33
+ *
34
+ * The iteration is terminated early if the `iteratee` function returns `false`.
35
+ *
36
+ * @template T - The type of the object
37
+ * @param {T | null | undefined} object - The object to iterate over
38
+ * @param {(value: T[keyof T], key: string, obj: T) => any} iteratee - The function invoked per iteration
39
+ * @returns {T | null | undefined} Returns the object
40
+ *
41
+ * @example
42
+ * // Iterate over all properties including inherited ones
43
+ * const obj = { a: 1, b: 2 };
44
+ * forInRight(obj, (value, key) => {
45
+ * console.log(key, value);
46
+ * });
47
+ * // Output: 'b' 2, 'a' 1
48
+ *
49
+ * // Early termination
50
+ * forInRight(obj, (value, key) => {
51
+ * console.log(key, value);
52
+ * return key !== 'a'; // stop after 'a'
53
+ * });
54
+ * // Output: 'b' 2
55
+ */
56
+ declare function forInRight<T>(object: T | null | undefined, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T | null | undefined;
57
+
58
+ export { forInRight };
@@ -0,0 +1,21 @@
1
+ import { identity } from '../../function/identity.mjs';
2
+
3
+ function forInRight(object, iteratee = identity) {
4
+ if (object == null) {
5
+ return object;
6
+ }
7
+ const keys = [];
8
+ for (const key in object) {
9
+ keys.push(key);
10
+ }
11
+ for (let i = keys.length - 1; i >= 0; i--) {
12
+ const key = keys[i];
13
+ const result = iteratee(object[key], key, object);
14
+ if (result === false) {
15
+ break;
16
+ }
17
+ }
18
+ return object;
19
+ }
20
+
21
+ export { forInRight };
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Iterates over an object's properties and calls the `iteratee` function for each property.
3
+ *
4
+ * It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys.
5
+ *
6
+ * The `iteratee` function can terminate the iteration early by returning `false`.
7
+ *
8
+ * @template T - The type of the object.
9
+ * @param {T} object The object to iterate over.
10
+ * @param {(value: T[keyof T], key: string, collection: T) => any} [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used.
11
+ * @return {T} Returns object.
12
+ *
13
+ * @example
14
+ * function Foo() {
15
+ * this.a = 1;
16
+ * this.b = 2;
17
+ * }
18
+ *
19
+ * Foo.prototype.c = 3;
20
+ *
21
+ * forOwn(new Foo(), function(value, key) {
22
+ * console.log(key);
23
+ * });
24
+ * // => Logs 'a' then 'b' (iteration order is not guaranteed).
25
+ */
26
+ declare function forOwn<T>(object: T, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T;
27
+ /**
28
+ * Iterates over an object's properties and calls the `iteratee` function for each property.
29
+ *
30
+ * It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys.
31
+ *
32
+ * The `iteratee` function can terminate the iteration early by returning `false`.
33
+ *
34
+ * @template T - The type of the object.
35
+ * @param {T | null | undefined} object The object to iterate over.
36
+ * @param {(value: T[keyof T], key: string, collection: T) => any} [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used.
37
+ * @return {T | null | undefined} Returns object.
38
+ *
39
+ * @example
40
+ * function Foo() {
41
+ * this.a = 1;
42
+ * this.b = 2;
43
+ * }
44
+ *
45
+ * Foo.prototype.c = 3;
46
+ *
47
+ * forOwn(new Foo(), function(value, key) {
48
+ * console.log(key);
49
+ * });
50
+ * // => Logs 'a' then 'b' (iteration order is not guaranteed).
51
+ */
52
+ declare function forOwn<T>(object: T | null | undefined, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T | null | undefined;
53
+
54
+ export { forOwn };
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Iterates over an object's properties and calls the `iteratee` function for each property.
3
+ *
4
+ * It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys.
5
+ *
6
+ * The `iteratee` function can terminate the iteration early by returning `false`.
7
+ *
8
+ * @template T - The type of the object.
9
+ * @param {T} object The object to iterate over.
10
+ * @param {(value: T[keyof T], key: string, collection: T) => any} [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used.
11
+ * @return {T} Returns object.
12
+ *
13
+ * @example
14
+ * function Foo() {
15
+ * this.a = 1;
16
+ * this.b = 2;
17
+ * }
18
+ *
19
+ * Foo.prototype.c = 3;
20
+ *
21
+ * forOwn(new Foo(), function(value, key) {
22
+ * console.log(key);
23
+ * });
24
+ * // => Logs 'a' then 'b' (iteration order is not guaranteed).
25
+ */
26
+ declare function forOwn<T>(object: T, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T;
27
+ /**
28
+ * Iterates over an object's properties and calls the `iteratee` function for each property.
29
+ *
30
+ * It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys.
31
+ *
32
+ * The `iteratee` function can terminate the iteration early by returning `false`.
33
+ *
34
+ * @template T - The type of the object.
35
+ * @param {T | null | undefined} object The object to iterate over.
36
+ * @param {(value: T[keyof T], key: string, collection: T) => any} [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used.
37
+ * @return {T | null | undefined} Returns object.
38
+ *
39
+ * @example
40
+ * function Foo() {
41
+ * this.a = 1;
42
+ * this.b = 2;
43
+ * }
44
+ *
45
+ * Foo.prototype.c = 3;
46
+ *
47
+ * forOwn(new Foo(), function(value, key) {
48
+ * console.log(key);
49
+ * });
50
+ * // => Logs 'a' then 'b' (iteration order is not guaranteed).
51
+ */
52
+ declare function forOwn<T>(object: T | null | undefined, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T | null | undefined;
53
+
54
+ export { forOwn };
@@ -0,0 +1,19 @@
1
+ import { keys } from './keys.mjs';
2
+ import { identity } from '../../function/identity.mjs';
3
+
4
+ function forOwn(object, iteratee = identity) {
5
+ if (object == null) {
6
+ return object;
7
+ }
8
+ const iterable = Object(object);
9
+ const keys$1 = keys(object);
10
+ for (let i = 0; i < keys$1.length; ++i) {
11
+ const key = keys$1[i];
12
+ if (iteratee(iterable[key], key, iterable) === false) {
13
+ break;
14
+ }
15
+ }
16
+ return object;
17
+ }
18
+
19
+ export { forOwn };
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Iterates over an object's properties in reverse order and calls the `iteratee` function for each property.
3
+ *
4
+ * It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys.
5
+ *
6
+ * The `iteratee` function can terminate the iteration early by returning `false`.
7
+ *
8
+ * @template T - The type of the object.
9
+ * @param {T} object The object to iterate over.
10
+ * @param {(value: T[keyof T], key: string, collection: T) => any} [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used.
11
+ * @return {T} Returns object.
12
+ *
13
+ * @example
14
+ * function Foo() {
15
+ * this.a = 1;
16
+ * this.b = 2;
17
+ * }
18
+ *
19
+ * Foo.prototype.c = 3;
20
+ *
21
+ * forOwnRight(new Foo(), function(value, key) {
22
+ * console.log(key);
23
+ * });
24
+ * // => Logs 'b' then 'a' (iteration order is not guaranteed).
25
+ */
26
+ declare function forOwnRight<T>(object: T, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T;
27
+ /**
28
+ * Iterates over an object's properties in reverse order and calls the `iteratee` function for each property.
29
+ *
30
+ * It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys.
31
+ *
32
+ * The `iteratee` function can terminate the iteration early by returning `false`.
33
+ *
34
+ * @template T - The type of the object.
35
+ * @param {T | null | undefined} object The object to iterate over.
36
+ * @param {(value: T[keyof T], key: string, collection: T) => any} [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used.
37
+ * @return {T | null | undefined} Returns object.
38
+ *
39
+ * @example
40
+ * function Foo() {
41
+ * this.a = 1;
42
+ * this.b = 2;
43
+ * }
44
+ *
45
+ * Foo.prototype.c = 3;
46
+ *
47
+ * forOwnRight(new Foo(), function(value, key) {
48
+ * console.log(key);
49
+ * });
50
+ * // => Logs 'b' then 'a' (iteration order is not guaranteed).
51
+ */
52
+ declare function forOwnRight<T>(object: T | null | undefined, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T | null | undefined;
53
+
54
+ export { forOwnRight };
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Iterates over an object's properties in reverse order and calls the `iteratee` function for each property.
3
+ *
4
+ * It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys.
5
+ *
6
+ * The `iteratee` function can terminate the iteration early by returning `false`.
7
+ *
8
+ * @template T - The type of the object.
9
+ * @param {T} object The object to iterate over.
10
+ * @param {(value: T[keyof T], key: string, collection: T) => any} [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used.
11
+ * @return {T} Returns object.
12
+ *
13
+ * @example
14
+ * function Foo() {
15
+ * this.a = 1;
16
+ * this.b = 2;
17
+ * }
18
+ *
19
+ * Foo.prototype.c = 3;
20
+ *
21
+ * forOwnRight(new Foo(), function(value, key) {
22
+ * console.log(key);
23
+ * });
24
+ * // => Logs 'b' then 'a' (iteration order is not guaranteed).
25
+ */
26
+ declare function forOwnRight<T>(object: T, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T;
27
+ /**
28
+ * Iterates over an object's properties in reverse order and calls the `iteratee` function for each property.
29
+ *
30
+ * It only iterates over the object's own properties, not including inherited properties or properties with `Symbol` keys.
31
+ *
32
+ * The `iteratee` function can terminate the iteration early by returning `false`.
33
+ *
34
+ * @template T - The type of the object.
35
+ * @param {T | null | undefined} object The object to iterate over.
36
+ * @param {(value: T[keyof T], key: string, collection: T) => any} [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used.
37
+ * @return {T | null | undefined} Returns object.
38
+ *
39
+ * @example
40
+ * function Foo() {
41
+ * this.a = 1;
42
+ * this.b = 2;
43
+ * }
44
+ *
45
+ * Foo.prototype.c = 3;
46
+ *
47
+ * forOwnRight(new Foo(), function(value, key) {
48
+ * console.log(key);
49
+ * });
50
+ * // => Logs 'b' then 'a' (iteration order is not guaranteed).
51
+ */
52
+ declare function forOwnRight<T>(object: T | null | undefined, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T | null | undefined;
53
+
54
+ export { forOwnRight };
@@ -0,0 +1,19 @@
1
+ import { keys } from './keys.mjs';
2
+ import { identity } from '../../function/identity.mjs';
3
+
4
+ function forOwnRight(object, iteratee = identity) {
5
+ if (object == null) {
6
+ return object;
7
+ }
8
+ const iterable = Object(object);
9
+ const keys$1 = keys(object);
10
+ for (let i = keys$1.length - 1; i >= 0; --i) {
11
+ const key = keys$1[i];
12
+ if (iteratee(iterable[key], key, iterable) === false) {
13
+ break;
14
+ }
15
+ }
16
+ return object;
17
+ }
18
+
19
+ export { forOwnRight };