es-toolkit 1.35.0-dev.1206 → 1.35.0-dev.1211

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.
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Iterates over elements of 'array' from right to left and invokes 'callback' for each element.
3
+ *
4
+ * @template K - The type of elements in the array.
5
+ * @template T - The type of the array.
6
+ * @param {T | null | undefined} array - The array to iterate over.
7
+ * @param {(value: K, index: number, array: T) => unknown} [callback] - The function invoked for each element.
8
+ * The callback function receives three arguments:
9
+ * - 'value': The current element being processed in the array.
10
+ * - 'index': The index of the current element being processed in the array.
11
+ * - 'array': The array 'forEachRight' was called upon.
12
+ * @returns {T} Returns the original array.
13
+ *
14
+ * @example
15
+ * forEachRight([1, 2, 3], (value, index, array) => console.log(value, index));
16
+ * // Output:
17
+ * // 3 2
18
+ * // 2 1
19
+ * // 1 0
20
+ *
21
+ */
22
+ declare function forEachRight<T>(array: T[], callback?: (value: T, index: number, array: T[]) => unknown): T[];
23
+ /**
24
+ * Iterates over elements of 'array' from right to left and invokes 'callback' for each element.
25
+ *
26
+ * @template K - The type of elements in the array.
27
+ * @template T - The type of the array.
28
+ * @param {T | null | undefined} array - The array to iterate over.
29
+ * @param {(value: K, index: number, array: T) => unknown} [callback] - The function invoked for each element.
30
+ * The callback function receives three arguments:
31
+ * - 'value': The current element being processed in the array.
32
+ * - 'index': The index of the current element being processed in the array.
33
+ * - 'array': The array 'forEachRight' was called upon.
34
+ * @returns {T} Returns the original array.
35
+ *
36
+ * @example
37
+ * forEachRight([1, 2, 3], (value, index, array) => console.log(value, index));
38
+ * // Output:
39
+ * // 3 2
40
+ * // 2 1
41
+ * // 1 0
42
+ *
43
+ */
44
+ declare function forEachRight<T>(array: readonly T[], callback?: (value: T, index: number, array: T[]) => unknown): readonly T[];
45
+ /**
46
+ * Iterates over elements of 'array' from right to left and invokes 'callback' for each element.
47
+ *
48
+ * @template T - The type of string.
49
+ * @param {T | null | undefined} string - The string to iterate over
50
+ * @param {(value: T, index: number, string: T) => unknown} [callback] - The function invoked for each char.
51
+ * The callback function receives three arguments:
52
+ * - 'char': The current char being processed in the string.
53
+ * - 'index': The index of the current char being processed in the string.
54
+ * - 'string': The string 'forEachRight' was called upon.
55
+ * @returns {T} Returns the original string.
56
+ *
57
+ * @example
58
+ * forEachRight('abc', (char, index, string) => console.log(char, index));
59
+ * // Output:
60
+ * // 'c' 2
61
+ * // 'b' 1
62
+ * // 'a' 0
63
+ */
64
+ declare function forEachRight<T extends string | null | undefined>(string: T, callback?: (char: string, index: number, string: string) => unknown): T;
65
+ /**
66
+ * Iterates over elements of 'array' from right to left and invokes 'callback' for each element.
67
+ *
68
+ * @template T - The type of elements in the array.
69
+ * @param { ArrayLike<T> } array - The array to iterate over.
70
+ * @param {(value: T, index: number, array: ArrayLike<T>) => unknown} [callback] - The function invoked for each element.
71
+ * The callback function receives three arguments:
72
+ * - 'value': The current element being processed in the array.
73
+ * - 'index': The index of the current element being processed in the array.
74
+ * - 'array': The array 'forEachRight' was called upon.
75
+ * @returns {T} Returns the original array.
76
+ *
77
+ * @example
78
+ * forEachRight([1, 2, 3], (value, index, array) => console.log(value, index));
79
+ * // Output:
80
+ * // 3 2
81
+ * // 2 1
82
+ * // 1 0
83
+ *
84
+ */
85
+ declare function forEachRight<T>(array: ArrayLike<T>, callback?: (value: T, index: number, array: ArrayLike<T>) => unknown): ArrayLike<T>;
86
+ /**
87
+ * Iterates over elements of 'array' from right to left and invokes 'callback' for each element.
88
+ *
89
+ * @template T - The type of object.
90
+ * @param {T} object - The object to iterate over.
91
+ * @param {(value: T[keyof T], key: keyof T, object: T) => unknown} [callback] - The function invoked for each property.
92
+ * The callback function receives three arguments:
93
+ * - 'value': The current property being processed in the object.
94
+ * - 'key': The key of the current property being processed in the object.
95
+ * - 'object': The object 'forEachRight' was called upon.
96
+ * @returns {T} Returns the original object.
97
+ *
98
+ * @example
99
+ * forEachRight({'a': 1, 'b': 2 }, (value, key, object) => console.log(value, key));
100
+ * // Output:
101
+ * // 2 'b'
102
+ * // 1 'a'
103
+ */
104
+ declare function forEachRight<T extends object | null | undefined>(object: T, callback?: (value: T[keyof T], key: keyof T, object: T) => unknown): T;
105
+
106
+ export { forEachRight };
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Iterates over elements of 'array' from right to left and invokes 'callback' for each element.
3
+ *
4
+ * @template K - The type of elements in the array.
5
+ * @template T - The type of the array.
6
+ * @param {T | null | undefined} array - The array to iterate over.
7
+ * @param {(value: K, index: number, array: T) => unknown} [callback] - The function invoked for each element.
8
+ * The callback function receives three arguments:
9
+ * - 'value': The current element being processed in the array.
10
+ * - 'index': The index of the current element being processed in the array.
11
+ * - 'array': The array 'forEachRight' was called upon.
12
+ * @returns {T} Returns the original array.
13
+ *
14
+ * @example
15
+ * forEachRight([1, 2, 3], (value, index, array) => console.log(value, index));
16
+ * // Output:
17
+ * // 3 2
18
+ * // 2 1
19
+ * // 1 0
20
+ *
21
+ */
22
+ declare function forEachRight<T>(array: T[], callback?: (value: T, index: number, array: T[]) => unknown): T[];
23
+ /**
24
+ * Iterates over elements of 'array' from right to left and invokes 'callback' for each element.
25
+ *
26
+ * @template K - The type of elements in the array.
27
+ * @template T - The type of the array.
28
+ * @param {T | null | undefined} array - The array to iterate over.
29
+ * @param {(value: K, index: number, array: T) => unknown} [callback] - The function invoked for each element.
30
+ * The callback function receives three arguments:
31
+ * - 'value': The current element being processed in the array.
32
+ * - 'index': The index of the current element being processed in the array.
33
+ * - 'array': The array 'forEachRight' was called upon.
34
+ * @returns {T} Returns the original array.
35
+ *
36
+ * @example
37
+ * forEachRight([1, 2, 3], (value, index, array) => console.log(value, index));
38
+ * // Output:
39
+ * // 3 2
40
+ * // 2 1
41
+ * // 1 0
42
+ *
43
+ */
44
+ declare function forEachRight<T>(array: readonly T[], callback?: (value: T, index: number, array: T[]) => unknown): readonly T[];
45
+ /**
46
+ * Iterates over elements of 'array' from right to left and invokes 'callback' for each element.
47
+ *
48
+ * @template T - The type of string.
49
+ * @param {T | null | undefined} string - The string to iterate over
50
+ * @param {(value: T, index: number, string: T) => unknown} [callback] - The function invoked for each char.
51
+ * The callback function receives three arguments:
52
+ * - 'char': The current char being processed in the string.
53
+ * - 'index': The index of the current char being processed in the string.
54
+ * - 'string': The string 'forEachRight' was called upon.
55
+ * @returns {T} Returns the original string.
56
+ *
57
+ * @example
58
+ * forEachRight('abc', (char, index, string) => console.log(char, index));
59
+ * // Output:
60
+ * // 'c' 2
61
+ * // 'b' 1
62
+ * // 'a' 0
63
+ */
64
+ declare function forEachRight<T extends string | null | undefined>(string: T, callback?: (char: string, index: number, string: string) => unknown): T;
65
+ /**
66
+ * Iterates over elements of 'array' from right to left and invokes 'callback' for each element.
67
+ *
68
+ * @template T - The type of elements in the array.
69
+ * @param { ArrayLike<T> } array - The array to iterate over.
70
+ * @param {(value: T, index: number, array: ArrayLike<T>) => unknown} [callback] - The function invoked for each element.
71
+ * The callback function receives three arguments:
72
+ * - 'value': The current element being processed in the array.
73
+ * - 'index': The index of the current element being processed in the array.
74
+ * - 'array': The array 'forEachRight' was called upon.
75
+ * @returns {T} Returns the original array.
76
+ *
77
+ * @example
78
+ * forEachRight([1, 2, 3], (value, index, array) => console.log(value, index));
79
+ * // Output:
80
+ * // 3 2
81
+ * // 2 1
82
+ * // 1 0
83
+ *
84
+ */
85
+ declare function forEachRight<T>(array: ArrayLike<T>, callback?: (value: T, index: number, array: ArrayLike<T>) => unknown): ArrayLike<T>;
86
+ /**
87
+ * Iterates over elements of 'array' from right to left and invokes 'callback' for each element.
88
+ *
89
+ * @template T - The type of object.
90
+ * @param {T} object - The object to iterate over.
91
+ * @param {(value: T[keyof T], key: keyof T, object: T) => unknown} [callback] - The function invoked for each property.
92
+ * The callback function receives three arguments:
93
+ * - 'value': The current property being processed in the object.
94
+ * - 'key': The key of the current property being processed in the object.
95
+ * - 'object': The object 'forEachRight' was called upon.
96
+ * @returns {T} Returns the original object.
97
+ *
98
+ * @example
99
+ * forEachRight({'a': 1, 'b': 2 }, (value, key, object) => console.log(value, key));
100
+ * // Output:
101
+ * // 2 'b'
102
+ * // 1 'a'
103
+ */
104
+ declare function forEachRight<T extends object | null | undefined>(object: T, callback?: (value: T[keyof T], key: keyof T, object: T) => unknown): T;
105
+
106
+ export { forEachRight };
@@ -0,0 +1,21 @@
1
+ import { identity } from '../../function/identity.mjs';
2
+ import { range } from '../../math/range.mjs';
3
+ import { isArrayLike } from '../predicate/isArrayLike.mjs';
4
+
5
+ function forEachRight(collection, callback = identity) {
6
+ if (!collection) {
7
+ return collection;
8
+ }
9
+ const keys = isArrayLike(collection) ? range(0, collection.length) : Object.keys(collection);
10
+ for (let i = keys.length - 1; i >= 0; i--) {
11
+ const key = keys[i];
12
+ const value = collection[key];
13
+ const result = callback(value, key, collection);
14
+ if (result === false) {
15
+ break;
16
+ }
17
+ }
18
+ return collection;
19
+ }
20
+
21
+ export { forEachRight };
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Maps each element of an array based on a provided key-generating function.
3
+ *
4
+ * This function takes an array and a function that generates a key from each element. It returns
5
+ * an object where the keys are the generated keys and the values are the corresponding elements.
6
+ * If there are multiple elements generating the same key, the last element among them is used
7
+ * as the value.
8
+ *
9
+ * @template T - The type of elements in the array.
10
+ * @template K - The type of keys.
11
+ * @param {T[]} arr - The array of elements to be mapped.
12
+ * @param {(item: T) => K} getKeyFromItem - A function that generates a key from an element.
13
+ * @returns {Record<K, T>} An object where keys are mapped to each element of an array.
14
+ *
15
+ * @example
16
+ * const array = [
17
+ * { category: 'fruit', name: 'apple' },
18
+ * { category: 'fruit', name: 'banana' },
19
+ * { category: 'vegetable', name: 'carrot' }
20
+ * ];
21
+ * const result = keyBy(array, item => item.category);
22
+ * // result will be:
23
+ * // {
24
+ * // fruit: { category: 'fruit', name: 'banana' },
25
+ * // vegetable: { category: 'vegetable', name: 'carrot' }
26
+ * // }
27
+ */
28
+ declare function groupBy<T, K extends PropertyKey>(source: ArrayLike<T> | null | undefined, getKeyFromItem?: ((item: T, index: number, arr: any) => unknown) | Partial<T> | [keyof T, unknown] | PropertyKey | null): Record<K, T[]>;
29
+ /**
30
+ * Groups the elements of an object based on a provided key-generating function.
31
+ *
32
+ * This function takes an object and a function that generates a key from each value. It returns
33
+ * an object where the keys are the generated keys and the values are arrays of elements that share
34
+ * the same key.
35
+ *
36
+ * @template T - The type of values in the object.
37
+ * @template K - The type of keys.
38
+ * @param {Record<any, T> | null | undefined} source - The object to group.
39
+ * @param {Function | PropertyKey | Array | Object} [getKeyFromItem] - The iteratee to transform keys.
40
+ * - If a function is provided, it's invoked for each element in the collection.
41
+ * - If a property name (string) is provided, that property of each element is used as the key.
42
+ * - If a property-value pair (array) is provided, elements with matching property values are used.
43
+ * - If a partial object is provided, elements with matching properties are used.
44
+ * @returns {Record<K, T>} An object where each key is associated with an array of elements that
45
+ * share that key.
46
+ *
47
+ * @example
48
+ * // Using an object
49
+ * const obj = { a: { category: 'fruit' }, b: { category: 'vegetable' }, c: { category: 'fruit' } };
50
+ * const result = groupBy(obj, 'category');
51
+ * // => { fruit: [{ category: 'fruit' }, { category: 'fruit' }], vegetable: [{ category: 'vegetable' }] }
52
+ */
53
+ declare function groupBy<T, K extends PropertyKey>(source: Record<any, T> | null | undefined, getKeyFromItem?: ((item: T, index: number, arr: any) => unknown) | Partial<T> | [keyof T, unknown] | PropertyKey | null): Record<K, T[]>;
54
+
55
+ export { groupBy };
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Maps each element of an array based on a provided key-generating function.
3
+ *
4
+ * This function takes an array and a function that generates a key from each element. It returns
5
+ * an object where the keys are the generated keys and the values are the corresponding elements.
6
+ * If there are multiple elements generating the same key, the last element among them is used
7
+ * as the value.
8
+ *
9
+ * @template T - The type of elements in the array.
10
+ * @template K - The type of keys.
11
+ * @param {T[]} arr - The array of elements to be mapped.
12
+ * @param {(item: T) => K} getKeyFromItem - A function that generates a key from an element.
13
+ * @returns {Record<K, T>} An object where keys are mapped to each element of an array.
14
+ *
15
+ * @example
16
+ * const array = [
17
+ * { category: 'fruit', name: 'apple' },
18
+ * { category: 'fruit', name: 'banana' },
19
+ * { category: 'vegetable', name: 'carrot' }
20
+ * ];
21
+ * const result = keyBy(array, item => item.category);
22
+ * // result will be:
23
+ * // {
24
+ * // fruit: { category: 'fruit', name: 'banana' },
25
+ * // vegetable: { category: 'vegetable', name: 'carrot' }
26
+ * // }
27
+ */
28
+ declare function groupBy<T, K extends PropertyKey>(source: ArrayLike<T> | null | undefined, getKeyFromItem?: ((item: T, index: number, arr: any) => unknown) | Partial<T> | [keyof T, unknown] | PropertyKey | null): Record<K, T[]>;
29
+ /**
30
+ * Groups the elements of an object based on a provided key-generating function.
31
+ *
32
+ * This function takes an object and a function that generates a key from each value. It returns
33
+ * an object where the keys are the generated keys and the values are arrays of elements that share
34
+ * the same key.
35
+ *
36
+ * @template T - The type of values in the object.
37
+ * @template K - The type of keys.
38
+ * @param {Record<any, T> | null | undefined} source - The object to group.
39
+ * @param {Function | PropertyKey | Array | Object} [getKeyFromItem] - The iteratee to transform keys.
40
+ * - If a function is provided, it's invoked for each element in the collection.
41
+ * - If a property name (string) is provided, that property of each element is used as the key.
42
+ * - If a property-value pair (array) is provided, elements with matching property values are used.
43
+ * - If a partial object is provided, elements with matching properties are used.
44
+ * @returns {Record<K, T>} An object where each key is associated with an array of elements that
45
+ * share that key.
46
+ *
47
+ * @example
48
+ * // Using an object
49
+ * const obj = { a: { category: 'fruit' }, b: { category: 'vegetable' }, c: { category: 'fruit' } };
50
+ * const result = groupBy(obj, 'category');
51
+ * // => { fruit: [{ category: 'fruit' }, { category: 'fruit' }], vegetable: [{ category: 'vegetable' }] }
52
+ */
53
+ declare function groupBy<T, K extends PropertyKey>(source: Record<any, T> | null | undefined, getKeyFromItem?: ((item: T, index: number, arr: any) => unknown) | Partial<T> | [keyof T, unknown] | PropertyKey | null): Record<K, T[]>;
54
+
55
+ export { groupBy };
@@ -0,0 +1,15 @@
1
+ import { groupBy as groupBy$1 } from '../../array/groupBy.mjs';
2
+ import { identity } from '../../function/identity.mjs';
3
+ import { isArrayLike } from '../predicate/isArrayLike.mjs';
4
+ import { iteratee } from '../util/iteratee.mjs';
5
+
6
+ function groupBy(source, _getKeyFromItem) {
7
+ if (source == null) {
8
+ return {};
9
+ }
10
+ const items = isArrayLike(source) ? Array.from(source) : Object.values(source);
11
+ const getKeyFromItem = iteratee(_getKeyFromItem ?? identity);
12
+ return groupBy$1(items, getKeyFromItem);
13
+ }
14
+
15
+ export { groupBy };
@@ -2,8 +2,6 @@ export { at } from '../array/at.mjs';
2
2
  export { countBy } from '../array/countBy.mjs';
3
3
  export { flatMap } from '../array/flatMap.mjs';
4
4
  export { flatMapDeep } from '../array/flatMapDeep.mjs';
5
- export { forEachRight } from '../array/forEachRight.mjs';
6
- export { groupBy } from '../array/groupBy.mjs';
7
5
  export { initial } from '../array/initial.mjs';
8
6
  export { isSubset } from '../array/isSubset.mjs';
9
7
  export { isSubsetWith } from '../array/isSubsetWith.mjs';
@@ -86,6 +84,8 @@ export { flatten } from './array/flatten.mjs';
86
84
  export { flattenDeep } from './array/flattenDeep.mjs';
87
85
  export { flattenDepth } from './array/flattenDepth.mjs';
88
86
  export { forEach as each, forEach } from './array/forEach.mjs';
87
+ export { forEachRight } from './array/forEachRight.mjs';
88
+ export { groupBy } from './array/groupBy.mjs';
89
89
  export { head as first, head } from './array/head.mjs';
90
90
  export { includes } from './array/includes.mjs';
91
91
  export { indexOf } from './array/indexOf.mjs';
@@ -2,8 +2,6 @@ export { at } from '../array/at.js';
2
2
  export { countBy } from '../array/countBy.js';
3
3
  export { flatMap } from '../array/flatMap.js';
4
4
  export { flatMapDeep } from '../array/flatMapDeep.js';
5
- export { forEachRight } from '../array/forEachRight.js';
6
- export { groupBy } from '../array/groupBy.js';
7
5
  export { initial } from '../array/initial.js';
8
6
  export { isSubset } from '../array/isSubset.js';
9
7
  export { isSubsetWith } from '../array/isSubsetWith.js';
@@ -86,6 +84,8 @@ export { flatten } from './array/flatten.js';
86
84
  export { flattenDeep } from './array/flattenDeep.js';
87
85
  export { flattenDepth } from './array/flattenDepth.js';
88
86
  export { forEach as each, forEach } from './array/forEach.js';
87
+ export { forEachRight } from './array/forEachRight.js';
88
+ export { groupBy } from './array/groupBy.js';
89
89
  export { head as first, head } from './array/head.js';
90
90
  export { includes } from './array/includes.js';
91
91
  export { indexOf } from './array/indexOf.js';
@@ -2,8 +2,6 @@ export { at } from '../array/at.mjs';
2
2
  export { countBy } from '../array/countBy.mjs';
3
3
  export { flatMap } from '../array/flatMap.mjs';
4
4
  export { flatMapDeep } from '../array/flatMapDeep.mjs';
5
- export { forEachRight } from '../array/forEachRight.mjs';
6
- export { groupBy } from '../array/groupBy.mjs';
7
5
  export { initial } from '../array/initial.mjs';
8
6
  export { isSubset } from '../array/isSubset.mjs';
9
7
  export { isSubsetWith } from '../array/isSubsetWith.mjs';
@@ -12,6 +10,7 @@ export { partition } from '../array/partition.mjs';
12
10
  export { pullAt } from '../array/pullAt.mjs';
13
11
  export { sampleSize } from '../array/sampleSize.mjs';
14
12
  export { shuffle } from '../array/shuffle.mjs';
13
+ export { toInteger } from './util/toInteger.mjs';
15
14
  export { toFilled } from '../array/toFilled.mjs';
16
15
  export { unzipWith } from '../array/unzipWith.mjs';
17
16
  export { windowed } from '../array/windowed.mjs';
@@ -90,6 +89,8 @@ export { flatten } from './array/flatten.mjs';
90
89
  export { flattenDeep } from './array/flattenDeep.mjs';
91
90
  export { flattenDepth } from './array/flattenDepth.mjs';
92
91
  export { forEach as each, forEach } from './array/forEach.mjs';
92
+ export { forEachRight } from './array/forEachRight.mjs';
93
+ export { groupBy } from './array/groupBy.mjs';
93
94
  export { head as first, head } from './array/head.mjs';
94
95
  export { includes } from './array/includes.mjs';
95
96
  export { indexOf } from './array/indexOf.mjs';
@@ -293,7 +294,6 @@ export { stubTrue } from './util/stubTrue.mjs';
293
294
  export { times } from './util/times.mjs';
294
295
  export { toArray } from './util/toArray.mjs';
295
296
  export { toFinite } from './util/toFinite.mjs';
296
- export { toInteger } from './util/toInteger.mjs';
297
297
  export { toLength } from './util/toLength.mjs';
298
298
  export { toNumber } from './util/toNumber.mjs';
299
299
  export { toPath } from './util/toPath.mjs';
@@ -2,8 +2,6 @@ export { at } from '../array/at.mjs';
2
2
  export { countBy } from '../array/countBy.mjs';
3
3
  export { flatMap } from '../array/flatMap.mjs';
4
4
  export { flatMapDeep } from '../array/flatMapDeep.mjs';
5
- export { forEachRight } from '../array/forEachRight.mjs';
6
- export { groupBy } from '../array/groupBy.mjs';
7
5
  export { initial } from '../array/initial.mjs';
8
6
  export { isSubset } from '../array/isSubset.mjs';
9
7
  export { isSubsetWith } from '../array/isSubsetWith.mjs';
@@ -86,6 +84,8 @@ export { flatten } from './array/flatten.mjs';
86
84
  export { flattenDeep } from './array/flattenDeep.mjs';
87
85
  export { flattenDepth } from './array/flattenDepth.mjs';
88
86
  export { forEach as each, forEach } from './array/forEach.mjs';
87
+ export { forEachRight } from './array/forEachRight.mjs';
88
+ export { groupBy } from './array/groupBy.mjs';
89
89
  export { head as first, head } from './array/head.mjs';
90
90
  export { includes } from './array/includes.mjs';
91
91
  export { indexOf } from './array/indexOf.mjs';
@@ -2,8 +2,6 @@ export { at } from '../array/at.js';
2
2
  export { countBy } from '../array/countBy.js';
3
3
  export { flatMap } from '../array/flatMap.js';
4
4
  export { flatMapDeep } from '../array/flatMapDeep.js';
5
- export { forEachRight } from '../array/forEachRight.js';
6
- export { groupBy } from '../array/groupBy.js';
7
5
  export { initial } from '../array/initial.js';
8
6
  export { isSubset } from '../array/isSubset.js';
9
7
  export { isSubsetWith } from '../array/isSubsetWith.js';
@@ -86,6 +84,8 @@ export { flatten } from './array/flatten.js';
86
84
  export { flattenDeep } from './array/flattenDeep.js';
87
85
  export { flattenDepth } from './array/flattenDepth.js';
88
86
  export { forEach as each, forEach } from './array/forEach.js';
87
+ export { forEachRight } from './array/forEachRight.js';
88
+ export { groupBy } from './array/groupBy.js';
89
89
  export { head as first, head } from './array/head.js';
90
90
  export { includes } from './array/includes.js';
91
91
  export { indexOf } from './array/indexOf.js';
@@ -2,14 +2,14 @@
2
2
 
3
3
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
4
 
5
- const zipWith = require('../_chunk/zipWith-ChDTPy.js');
5
+ const zipWith = require('../_chunk/zipWith-Bt0YQl.js');
6
6
  const AbortError = require('../_chunk/AbortError-Cg4ZQ1.js');
7
7
  const error_index = require('../error/index.js');
8
8
  const unary = require('../_chunk/unary-EIEhcF.js');
9
9
  const noop = require('../_chunk/noop-2IwLUk.js');
10
10
  const range = require('../_chunk/range-HnEIT7.js');
11
11
  const randomInt = require('../_chunk/randomInt-CF7bZK.js');
12
- const compat_index = require('../_chunk/toSnakeCaseKeys-DCXJ3Q.js');
12
+ const compat_index = require('../_chunk/toSnakeCaseKeys-nofgoP.js');
13
13
  const isPromise = require('../_chunk/isPromise-BqEEYJ.js');
14
14
  const promise_index = require('../promise/index.js');
15
15
  const reverseString = require('../_chunk/reverseString-BixeGz.js');
@@ -21,17 +21,19 @@ exports.at = zipWith.at;
21
21
  exports.countBy = zipWith.countBy;
22
22
  exports.flatMap = zipWith.flatMap;
23
23
  exports.flatMapDeep = zipWith.flatMapDeep;
24
- exports.forEachRight = zipWith.forEachRight;
25
- exports.groupBy = zipWith.groupBy;
26
24
  exports.initial = zipWith.initial;
27
25
  exports.isSubset = zipWith.isSubset;
28
26
  exports.isSubsetWith = zipWith.isSubsetWith;
27
+ exports.isSymbol = zipWith.isSymbol;
29
28
  exports.keyBy = zipWith.keyBy;
30
29
  exports.partition = zipWith.partition;
31
30
  exports.pullAt = zipWith.pullAt;
32
31
  exports.sampleSize = zipWith.sampleSize;
33
32
  exports.shuffle = zipWith.shuffle;
34
33
  exports.toFilled = zipWith.toFilled;
34
+ exports.toFinite = zipWith.toFinite;
35
+ exports.toInteger = zipWith.toInteger;
36
+ exports.toNumber = zipWith.toNumber;
35
37
  exports.unzipWith = zipWith.unzipWith;
36
38
  exports.windowed = zipWith.windowed;
37
39
  exports.xor = zipWith.xor;
@@ -118,10 +120,12 @@ exports.floor = compat_index.floor;
118
120
  exports.flow = compat_index.flow;
119
121
  exports.flowRight = compat_index.flowRight;
120
122
  exports.forEach = compat_index.forEach;
123
+ exports.forEachRight = compat_index.forEachRight;
121
124
  exports.fromPairs = compat_index.fromPairs;
122
125
  exports.functions = compat_index.functions;
123
126
  exports.functionsIn = compat_index.functionsIn;
124
127
  exports.get = compat_index.get;
128
+ exports.groupBy = compat_index.groupBy;
125
129
  exports.gt = compat_index.gt;
126
130
  exports.gte = compat_index.gte;
127
131
  exports.has = compat_index.has;
@@ -161,7 +165,6 @@ exports.isRegExp = compat_index.isRegExp;
161
165
  exports.isSafeInteger = compat_index.isSafeInteger;
162
166
  exports.isSet = compat_index.isSet;
163
167
  exports.isString = compat_index.isString;
164
- exports.isSymbol = compat_index.isSymbol;
165
168
  exports.isTypedArray = compat_index.isTypedArray;
166
169
  exports.isWeakMap = compat_index.isWeakMap;
167
170
  exports.isWeakSet = compat_index.isWeakSet;
@@ -261,12 +264,9 @@ exports.times = compat_index.times;
261
264
  exports.toArray = compat_index.toArray;
262
265
  exports.toCamelCaseKeys = compat_index.toCamelCaseKeys;
263
266
  exports.toDefaulted = compat_index.toDefaulted;
264
- exports.toFinite = compat_index.toFinite;
265
- exports.toInteger = compat_index.toInteger;
266
267
  exports.toLength = compat_index.toLength;
267
268
  exports.toLower = compat_index.toLower;
268
269
  exports.toMerged = compat_index.toMerged;
269
- exports.toNumber = compat_index.toNumber;
270
270
  exports.toPairs = compat_index.toPairs;
271
271
  exports.toPairsIn = compat_index.toPairsIn;
272
272
  exports.toPath = compat_index.toPath;
@@ -2,8 +2,6 @@ export { at } from '../array/at.mjs';
2
2
  export { countBy } from '../array/countBy.mjs';
3
3
  export { flatMap } from '../array/flatMap.mjs';
4
4
  export { flatMapDeep } from '../array/flatMapDeep.mjs';
5
- export { forEachRight } from '../array/forEachRight.mjs';
6
- export { groupBy } from '../array/groupBy.mjs';
7
5
  export { initial } from '../array/initial.mjs';
8
6
  export { isSubset } from '../array/isSubset.mjs';
9
7
  export { isSubsetWith } from '../array/isSubsetWith.mjs';
@@ -12,6 +10,7 @@ export { partition } from '../array/partition.mjs';
12
10
  export { pullAt } from '../array/pullAt.mjs';
13
11
  export { sampleSize } from '../array/sampleSize.mjs';
14
12
  export { shuffle } from '../array/shuffle.mjs';
13
+ export { toInteger } from './util/toInteger.mjs';
15
14
  export { toFilled } from '../array/toFilled.mjs';
16
15
  export { unzipWith } from '../array/unzipWith.mjs';
17
16
  export { windowed } from '../array/windowed.mjs';
@@ -90,6 +89,8 @@ export { flatten } from './array/flatten.mjs';
90
89
  export { flattenDeep } from './array/flattenDeep.mjs';
91
90
  export { flattenDepth } from './array/flattenDepth.mjs';
92
91
  export { forEach as each, forEach } from './array/forEach.mjs';
92
+ export { forEachRight } from './array/forEachRight.mjs';
93
+ export { groupBy } from './array/groupBy.mjs';
93
94
  export { head as first, head } from './array/head.mjs';
94
95
  export { includes } from './array/includes.mjs';
95
96
  export { indexOf } from './array/indexOf.mjs';
@@ -293,7 +294,6 @@ export { stubTrue } from './util/stubTrue.mjs';
293
294
  export { times } from './util/times.mjs';
294
295
  export { toArray } from './util/toArray.mjs';
295
296
  export { toFinite } from './util/toFinite.mjs';
296
- export { toInteger } from './util/toInteger.mjs';
297
297
  export { toLength } from './util/toLength.mjs';
298
298
  export { toNumber } from './util/toNumber.mjs';
299
299
  export { toPath } from './util/toPath.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++) {
@@ -12,6 +12,6 @@
12
12
  * repeat('abc', 0); // ''
13
13
  * repeat('abc', 2); // 'abcabc'
14
14
  */
15
- declare function repeat(str: string, n: number): string;
15
+ declare function repeat(str: string, n?: number, guard?: unknown): string;
16
16
 
17
17
  export { repeat };
@@ -12,6 +12,6 @@
12
12
  * repeat('abc', 0); // ''
13
13
  * repeat('abc', 2); // 'abcabc'
14
14
  */
15
- declare function repeat(str: string, n: number): string;
15
+ declare function repeat(str: string, n?: number, guard?: unknown): string;
16
16
 
17
17
  export { repeat };
@@ -1,5 +1,15 @@
1
- function repeat(str, n) {
2
- return str.repeat(n);
1
+ import { isIterateeCall } from '../_internal/isIterateeCall.mjs';
2
+ import { toInteger } from '../util/toInteger.mjs';
3
+ import { toString } from '../util/toString.mjs';
4
+
5
+ function repeat(str, n, guard) {
6
+ if (guard ? isIterateeCall(str, n, guard) : n === undefined) {
7
+ n = 1;
8
+ }
9
+ else {
10
+ n = toInteger(n);
11
+ }
12
+ return toString(str).repeat(n);
3
13
  }
4
14
 
5
15
  export { repeat };
@@ -10,6 +10,6 @@
10
10
  * // => ['fred', 'barney', 'pebbles']
11
11
  *
12
12
  */
13
- declare function words(str?: string | object, pattern?: RegExp | string): string[];
13
+ declare function words(str?: string | object, pattern?: RegExp | string, guard?: unknown): string[];
14
14
 
15
15
  export { words };
@@ -10,6 +10,6 @@
10
10
  * // => ['fred', 'barney', 'pebbles']
11
11
  *
12
12
  */
13
- declare function words(str?: string | object, pattern?: RegExp | string): string[];
13
+ declare function words(str?: string | object, pattern?: RegExp | string, guard?: unknown): string[];
14
14
 
15
15
  export { words };