Add settings page for managing forecasting API key and URL via UI

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-20 14:37:36 +00:00
parent cae411eae7
commit 1c411e402e
19809 changed files with 1962608 additions and 97 deletions

View file

@ -0,0 +1,30 @@
//#region src/compat/array/castArray.d.ts
/**
* Casts value as an array if it's not one.
*
* @template T The type of elements in the array.
* @param value The value to be cast to an array.
* @returns An array containing the input value if it wasn't an array, or the original array if it was.
*
* @example
* const arr1 = castArray(1);
* // Returns: [1]
*
* const arr2 = castArray([1]);
* // Returns: [1]
*
* const arr3 = castArray({'a': 1});
* // Returns: [{'a': 1}]
*
* const arr4 = castArray(null);
* // Returns: [null]
*
* const arr5 = castArray(undefined);
* // Returns: [undefined]
*
* const arr6 = castArray();
* // Returns: []
*/
declare function castArray<T>(value?: T | readonly T[]): T[];
//#endregion
export { castArray };

View file

@ -0,0 +1,30 @@
//#region src/compat/array/castArray.d.ts
/**
* Casts value as an array if it's not one.
*
* @template T The type of elements in the array.
* @param value The value to be cast to an array.
* @returns An array containing the input value if it wasn't an array, or the original array if it was.
*
* @example
* const arr1 = castArray(1);
* // Returns: [1]
*
* const arr2 = castArray([1]);
* // Returns: [1]
*
* const arr3 = castArray({'a': 1});
* // Returns: [{'a': 1}]
*
* const arr4 = castArray(null);
* // Returns: [null]
*
* const arr5 = castArray(undefined);
* // Returns: [undefined]
*
* const arr6 = castArray();
* // Returns: []
*/
declare function castArray<T>(value?: T | readonly T[]): T[];
//#endregion
export { castArray };

View file

@ -0,0 +1,33 @@
//#region src/compat/array/castArray.ts
/**
* Casts value as an array if it's not one.
*
* @template T The type of elements in the array.
* @param value The value to be cast to an array.
* @returns An array containing the input value if it wasn't an array, or the original array if it was.
*
* @example
* const arr1 = castArray(1);
* // Returns: [1]
*
* const arr2 = castArray([1]);
* // Returns: [1]
*
* const arr3 = castArray({'a': 1});
* // Returns: [{'a': 1}]
*
* const arr4 = castArray(null);
* // Returns: [null]
*
* const arr5 = castArray(undefined);
* // Returns: [undefined]
*
* const arr6 = castArray();
* // Returns: []
*/
function castArray(value) {
if (arguments.length === 0) return [];
return Array.isArray(value) ? value : [value];
}
//#endregion
exports.castArray = castArray;

View file

@ -0,0 +1,33 @@
//#region src/compat/array/castArray.ts
/**
* Casts value as an array if it's not one.
*
* @template T The type of elements in the array.
* @param value The value to be cast to an array.
* @returns An array containing the input value if it wasn't an array, or the original array if it was.
*
* @example
* const arr1 = castArray(1);
* // Returns: [1]
*
* const arr2 = castArray([1]);
* // Returns: [1]
*
* const arr3 = castArray({'a': 1});
* // Returns: [{'a': 1}]
*
* const arr4 = castArray(null);
* // Returns: [null]
*
* const arr5 = castArray(undefined);
* // Returns: [undefined]
*
* const arr6 = castArray();
* // Returns: []
*/
function castArray(value) {
if (arguments.length === 0) return [];
return Array.isArray(value) ? value : [value];
}
//#endregion
export { castArray };

View file

@ -0,0 +1,26 @@
//#region src/compat/array/chunk.d.ts
/**
* Splits an array into smaller arrays of a specified length.
*
* This function takes an input array and divides it into multiple smaller arrays,
* each of a specified length. If the input array cannot be evenly divided,
* the final sub-array will contain the remaining elements.
*
* @template T The type of elements in the array.
* @param arr - The array to be chunked into smaller arrays.
* @param size - The size of each smaller array. Must be a positive integer.
* @returns A two-dimensional array where each sub-array has a maximum length of `size`.
*
* @example
* // Splits an array of numbers into sub-arrays of length 2
* chunk([1, 2, 3, 4, 5], 2);
* // Returns: [[1, 2], [3, 4], [5]]
*
* @example
* // Splits an array of strings into sub-arrays of length 3
* chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3);
* // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']]
*/
declare function chunk<T>(arr: ArrayLike<T> | null | undefined, size?: number): T[][];
//#endregion
export { chunk };

View file

@ -0,0 +1,26 @@
//#region src/compat/array/chunk.d.ts
/**
* Splits an array into smaller arrays of a specified length.
*
* This function takes an input array and divides it into multiple smaller arrays,
* each of a specified length. If the input array cannot be evenly divided,
* the final sub-array will contain the remaining elements.
*
* @template T The type of elements in the array.
* @param arr - The array to be chunked into smaller arrays.
* @param size - The size of each smaller array. Must be a positive integer.
* @returns A two-dimensional array where each sub-array has a maximum length of `size`.
*
* @example
* // Splits an array of numbers into sub-arrays of length 2
* chunk([1, 2, 3, 4, 5], 2);
* // Returns: [[1, 2], [3, 4], [5]]
*
* @example
* // Splits an array of strings into sub-arrays of length 3
* chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3);
* // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']]
*/
declare function chunk<T>(arr: ArrayLike<T> | null | undefined, size?: number): T[][];
//#endregion
export { chunk };

View file

@ -0,0 +1,35 @@
const require_chunk = require("../../array/chunk.js");
const require_toArray = require("../_internal/toArray.js");
const require_isArrayLike = require("../predicate/isArrayLike.js");
//#region src/compat/array/chunk.ts
/**
* Splits an array into smaller arrays of a specified length.
*
* This function takes an input array and divides it into multiple smaller arrays,
* each of a specified length. If the input array cannot be evenly divided,
* the final sub-array will contain the remaining elements.
*
* @template T The type of elements in the array.
* @param arr - The array to be chunked into smaller arrays.
* @param size - The size of each smaller array. Must be a positive integer.
* @returns A two-dimensional array where each sub-array has a maximum length of `size`.
*
* @example
* // Splits an array of numbers into sub-arrays of length 2
* chunk([1, 2, 3, 4, 5], 2);
* // Returns: [[1, 2], [3, 4], [5]]
*
* @example
* // Splits an array of strings into sub-arrays of length 3
* chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3);
* // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']]
*/
function chunk(arr, size = 1) {
size = Math.max(Math.floor(size), 0);
if (size === 0 || !require_isArrayLike.isArrayLike(arr) || Number.isNaN(size)) return [];
const array = require_toArray.toArray(arr);
if (!isFinite(size)) return [array];
return require_chunk.chunk(array, size);
}
//#endregion
exports.chunk = chunk;

View file

@ -0,0 +1,35 @@
import { chunk as chunk$1 } from "../../array/chunk.mjs";
import { toArray } from "../_internal/toArray.mjs";
import { isArrayLike } from "../predicate/isArrayLike.mjs";
//#region src/compat/array/chunk.ts
/**
* Splits an array into smaller arrays of a specified length.
*
* This function takes an input array and divides it into multiple smaller arrays,
* each of a specified length. If the input array cannot be evenly divided,
* the final sub-array will contain the remaining elements.
*
* @template T The type of elements in the array.
* @param arr - The array to be chunked into smaller arrays.
* @param size - The size of each smaller array. Must be a positive integer.
* @returns A two-dimensional array where each sub-array has a maximum length of `size`.
*
* @example
* // Splits an array of numbers into sub-arrays of length 2
* chunk([1, 2, 3, 4, 5], 2);
* // Returns: [[1, 2], [3, 4], [5]]
*
* @example
* // Splits an array of strings into sub-arrays of length 3
* chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3);
* // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']]
*/
function chunk(arr, size = 1) {
size = Math.max(Math.floor(size), 0);
if (size === 0 || !isArrayLike(arr) || Number.isNaN(size)) return [];
const array = toArray(arr);
if (!isFinite(size)) return [array];
return chunk$1(array, size);
}
//#endregion
export { chunk };

View file

@ -0,0 +1,16 @@
//#region src/compat/array/compact.d.ts
type Falsey = false | null | 0 | 0n | '' | undefined;
/**
* Removes falsey values (false, null, 0, 0n, '', undefined, NaN) from an array.
*
* @template T - The type of elements in the array.
* @param arr - The input array to remove falsey values.
* @returns A new array with all falsey values removed.
*
* @example
* compact([0, 0n, 1, false, 2, '', 3, null, undefined, 4, NaN, 5]);
* Returns: [1, 2, 3, 4, 5]
*/
declare function compact<T>(arr: ArrayLike<T | Falsey> | null | undefined): T[];
//#endregion
export { compact };

View file

@ -0,0 +1,16 @@
//#region src/compat/array/compact.d.ts
type Falsey = false | null | 0 | 0n | '' | undefined;
/**
* Removes falsey values (false, null, 0, 0n, '', undefined, NaN) from an array.
*
* @template T - The type of elements in the array.
* @param arr - The input array to remove falsey values.
* @returns A new array with all falsey values removed.
*
* @example
* compact([0, 0n, 1, false, 2, '', 3, null, undefined, 4, NaN, 5]);
* Returns: [1, 2, 3, 4, 5]
*/
declare function compact<T>(arr: ArrayLike<T | Falsey> | null | undefined): T[];
//#endregion
export { compact };

View file

@ -0,0 +1,20 @@
const require_compact = require("../../array/compact.js");
const require_isArrayLike = require("../predicate/isArrayLike.js");
//#region src/compat/array/compact.ts
/**
* Removes falsey values (false, null, 0, 0n, '', undefined, NaN) from an array.
*
* @template T - The type of elements in the array.
* @param arr - The input array to remove falsey values.
* @returns A new array with all falsey values removed.
*
* @example
* compact([0, 0n, 1, false, 2, '', 3, null, undefined, 4, NaN, 5]);
* Returns: [1, 2, 3, 4, 5]
*/
function compact(arr) {
if (!require_isArrayLike.isArrayLike(arr)) return [];
return require_compact.compact(Array.from(arr));
}
//#endregion
exports.compact = compact;

View file

@ -0,0 +1,20 @@
import { compact as compact$1 } from "../../array/compact.mjs";
import { isArrayLike } from "../predicate/isArrayLike.mjs";
//#region src/compat/array/compact.ts
/**
* Removes falsey values (false, null, 0, 0n, '', undefined, NaN) from an array.
*
* @template T - The type of elements in the array.
* @param arr - The input array to remove falsey values.
* @returns A new array with all falsey values removed.
*
* @example
* compact([0, 0n, 1, false, 2, '', 3, null, undefined, 4, NaN, 5]);
* Returns: [1, 2, 3, 4, 5]
*/
function compact(arr) {
if (!isArrayLike(arr)) return [];
return compact$1(Array.from(arr));
}
//#endregion
export { compact };

View file

@ -0,0 +1,31 @@
//#region src/compat/array/concat.d.ts
/**
* Concatenates multiple arrays and values into a single array.
*
* @template T The type of elements in the array.
* @param values - The values and/or arrays to concatenate.
* @returns A new array containing all the input values.
*
* @example
* // Concatenate individual values
* concat(1, 2, 3);
* // returns [1, 2, 3]
*
* @example
* // Concatenate arrays of values
* concat([1, 2], [3, 4]);
* // returns [1, 2, 3, 4]
*
* @example
* // Concatenate a mix of individual values and arrays
* concat(1, [2, 3], 4);
* // returns [1, 2, 3, 4]
*
* @example
* // Concatenate nested arrays
* concat([1, [2, 3]], 4);
* // returns [1, [2, 3], 4]
*/
declare function concat<T>(...values: Array<T | readonly T[]>): T[];
//#endregion
export { concat };

View file

@ -0,0 +1,31 @@
//#region src/compat/array/concat.d.ts
/**
* Concatenates multiple arrays and values into a single array.
*
* @template T The type of elements in the array.
* @param values - The values and/or arrays to concatenate.
* @returns A new array containing all the input values.
*
* @example
* // Concatenate individual values
* concat(1, 2, 3);
* // returns [1, 2, 3]
*
* @example
* // Concatenate arrays of values
* concat([1, 2], [3, 4]);
* // returns [1, 2, 3, 4]
*
* @example
* // Concatenate a mix of individual values and arrays
* concat(1, [2, 3], 4);
* // returns [1, 2, 3, 4]
*
* @example
* // Concatenate nested arrays
* concat([1, [2, 3]], 4);
* // returns [1, [2, 3], 4]
*/
declare function concat<T>(...values: Array<T | readonly T[]>): T[];
//#endregion
export { concat };

View file

@ -0,0 +1,34 @@
const require_flatten = require("../../array/flatten.js");
//#region src/compat/array/concat.ts
/**
* Concatenates multiple arrays and values into a single array.
*
* @template T The type of elements in the array.
* @param values - The values and/or arrays to concatenate.
* @returns A new array containing all the input values.
*
* @example
* // Concatenate individual values
* concat(1, 2, 3);
* // returns [1, 2, 3]
*
* @example
* // Concatenate arrays of values
* concat([1, 2], [3, 4]);
* // returns [1, 2, 3, 4]
*
* @example
* // Concatenate a mix of individual values and arrays
* concat(1, [2, 3], 4);
* // returns [1, 2, 3, 4]
*
* @example
* // Concatenate nested arrays
* concat([1, [2, 3]], 4);
* // returns [1, [2, 3], 4]
*/
function concat(...values) {
return require_flatten.flatten(values);
}
//#endregion
exports.concat = concat;

View file

@ -0,0 +1,34 @@
import { flatten } from "../../array/flatten.mjs";
//#region src/compat/array/concat.ts
/**
* Concatenates multiple arrays and values into a single array.
*
* @template T The type of elements in the array.
* @param values - The values and/or arrays to concatenate.
* @returns A new array containing all the input values.
*
* @example
* // Concatenate individual values
* concat(1, 2, 3);
* // returns [1, 2, 3]
*
* @example
* // Concatenate arrays of values
* concat([1, 2], [3, 4]);
* // returns [1, 2, 3, 4]
*
* @example
* // Concatenate a mix of individual values and arrays
* concat(1, [2, 3], 4);
* // returns [1, 2, 3, 4]
*
* @example
* // Concatenate nested arrays
* concat([1, [2, 3]], 4);
* // returns [1, [2, 3], 4]
*/
function concat(...values) {
return flatten(values);
}
//#endregion
export { concat };

View file

@ -0,0 +1,20 @@
import { ValueIteratee } from "../_internal/ValueIteratee.mjs";
//#region src/compat/array/countBy.d.ts
/**
* Creates an object composed of keys generated from the results of running each element of collection through
* iteratee. The corresponding value of each key is the number of times the key was returned by iteratee. The
* iteratee is invoked with one argument: (value).
*
* @param collection The collection to iterate over.
* @param iteratee The function invoked per iteration.
* @return Returns the composed aggregate object.
*
* @example
* countBy([6.1, 4.2, 6.3], Math.floor); // => { '4': 1, '6': 2 }
* countBy(['one', 'two', 'three'], 'length'); // => { '3': 2, '5': 1 }
*/
declare function countBy<T>(collection: ArrayLike<T> | null | undefined, iteratee?: ValueIteratee<T>): Record<string, number>;
declare function countBy<T extends object>(collection: T | null | undefined, iteratee?: ValueIteratee<T[keyof T]>): Record<string, number>;
//#endregion
export { countBy };

View file

@ -0,0 +1,20 @@
import { ValueIteratee } from "../_internal/ValueIteratee.js";
//#region src/compat/array/countBy.d.ts
/**
* Creates an object composed of keys generated from the results of running each element of collection through
* iteratee. The corresponding value of each key is the number of times the key was returned by iteratee. The
* iteratee is invoked with one argument: (value).
*
* @param collection The collection to iterate over.
* @param iteratee The function invoked per iteration.
* @return Returns the composed aggregate object.
*
* @example
* countBy([6.1, 4.2, 6.3], Math.floor); // => { '4': 1, '6': 2 }
* countBy(['one', 'two', 'three'], 'length'); // => { '3': 2, '5': 1 }
*/
declare function countBy<T>(collection: ArrayLike<T> | null | undefined, iteratee?: ValueIteratee<T>): Record<string, number>;
declare function countBy<T extends object>(collection: T | null | undefined, iteratee?: ValueIteratee<T[keyof T]>): Record<string, number>;
//#endregion
export { countBy };

View file

@ -0,0 +1,17 @@
const require_isArrayLike = require("../predicate/isArrayLike.js");
const require_iteratee = require("../util/iteratee.js");
//#region src/compat/array/countBy.ts
function countBy(collection, iteratee$1) {
if (collection == null) return {};
const array = require_isArrayLike.isArrayLike(collection) ? Array.from(collection) : Object.values(collection);
const mapper = require_iteratee.iteratee(iteratee$1 ?? void 0);
const result = Object.create(null);
for (let i = 0; i < array.length; i++) {
const item = array[i];
const key = mapper(item);
result[key] = (result[key] ?? 0) + 1;
}
return result;
}
//#endregion
exports.countBy = countBy;

View file

@ -0,0 +1,17 @@
import { isArrayLike } from "../predicate/isArrayLike.mjs";
import { iteratee } from "../util/iteratee.mjs";
//#region src/compat/array/countBy.ts
function countBy(collection, iteratee$1) {
if (collection == null) return {};
const array = isArrayLike(collection) ? Array.from(collection) : Object.values(collection);
const mapper = iteratee(iteratee$1 ?? void 0);
const result = Object.create(null);
for (let i = 0; i < array.length; i++) {
const item = array[i];
const key = mapper(item);
result[key] = (result[key] ?? 0) + 1;
}
return result;
}
//#endregion
export { countBy };

View file

@ -0,0 +1,29 @@
//#region src/compat/array/difference.d.ts
/**
* Computes the difference between an array and multiple arrays.
*
* @template T
* @param arr - The primary array from which to derive the difference. This is the main array
* from which elements will be compared and filtered.
* @param values - Multiple arrays containing elements to be excluded from the primary array.
* These arrays will be flattened into a single array, and each element in this array will be checked against the primary array.
* If a match is found, that element will be excluded from the result.
* @returns A new array containing the elements that are present in the primary array but not
* in the flattened array.
*
* @example
* const array1 = [1, 2, 3, 4, 5];
* const array2 = [2, 4];
* const array3 = [5, 6];
* const result = difference(array1, array2, array3);
* // result will be [1, 3] since 2, 4, and 5 are in the other arrays and are excluded from the result.
*
* @example
* const arrayLike1 = { 0: 1, 1: 2, 2: 3, length: 3 };
* const arrayLike2 = { 0: 2, 1: 4, length: 2 };
* const result = difference(arrayLike1, arrayLike2);
* // result will be [1, 3] since 2 is in both array-like objects and is excluded from the result.
*/
declare function difference<T>(arr: ArrayLike<T> | undefined | null, ...values: Array<ArrayLike<T>>): T[];
//#endregion
export { difference };

View file

@ -0,0 +1,29 @@
//#region src/compat/array/difference.d.ts
/**
* Computes the difference between an array and multiple arrays.
*
* @template T
* @param arr - The primary array from which to derive the difference. This is the main array
* from which elements will be compared and filtered.
* @param values - Multiple arrays containing elements to be excluded from the primary array.
* These arrays will be flattened into a single array, and each element in this array will be checked against the primary array.
* If a match is found, that element will be excluded from the result.
* @returns A new array containing the elements that are present in the primary array but not
* in the flattened array.
*
* @example
* const array1 = [1, 2, 3, 4, 5];
* const array2 = [2, 4];
* const array3 = [5, 6];
* const result = difference(array1, array2, array3);
* // result will be [1, 3] since 2, 4, and 5 are in the other arrays and are excluded from the result.
*
* @example
* const arrayLike1 = { 0: 1, 1: 2, 2: 3, length: 3 };
* const arrayLike2 = { 0: 2, 1: 4, length: 2 };
* const result = difference(arrayLike1, arrayLike2);
* // result will be [1, 3] since 2 is in both array-like objects and is excluded from the result.
*/
declare function difference<T>(arr: ArrayLike<T> | undefined | null, ...values: Array<ArrayLike<T>>): T[];
//#endregion
export { difference };

View file

@ -0,0 +1,40 @@
const require_difference = require("../../array/difference.js");
const require_isArrayLikeObject = require("../predicate/isArrayLikeObject.js");
//#region src/compat/array/difference.ts
/**
* Computes the difference between an array and multiple arrays.
*
* @template T
* @param arr - The primary array from which to derive the difference. This is the main array
* from which elements will be compared and filtered.
* @param values - Multiple arrays containing elements to be excluded from the primary array.
* These arrays will be flattened into a single array, and each element in this array will be checked against the primary array.
* If a match is found, that element will be excluded from the result.
* @returns A new array containing the elements that are present in the primary array but not
* in the flattened array.
*
* @example
* const array1 = [1, 2, 3, 4, 5];
* const array2 = [2, 4];
* const array3 = [5, 6];
* const result = difference(array1, array2, array3);
* // result will be [1, 3] since 2, 4, and 5 are in the other arrays and are excluded from the result.
*
* @example
* const arrayLike1 = { 0: 1, 1: 2, 2: 3, length: 3 };
* const arrayLike2 = { 0: 2, 1: 4, length: 2 };
* const result = difference(arrayLike1, arrayLike2);
* // result will be [1, 3] since 2 is in both array-like objects and is excluded from the result.
*/
function difference(arr, ...values) {
if (!require_isArrayLikeObject.isArrayLikeObject(arr)) return [];
const arr1 = Array.from(arr);
const arr2 = [];
for (let i = 0; i < values.length; i++) {
const value = values[i];
if (require_isArrayLikeObject.isArrayLikeObject(value)) arr2.push(...Array.from(value));
}
return require_difference.difference(arr1, arr2);
}
//#endregion
exports.difference = difference;

View file

@ -0,0 +1,40 @@
import { difference as difference$1 } from "../../array/difference.mjs";
import { isArrayLikeObject } from "../predicate/isArrayLikeObject.mjs";
//#region src/compat/array/difference.ts
/**
* Computes the difference between an array and multiple arrays.
*
* @template T
* @param arr - The primary array from which to derive the difference. This is the main array
* from which elements will be compared and filtered.
* @param values - Multiple arrays containing elements to be excluded from the primary array.
* These arrays will be flattened into a single array, and each element in this array will be checked against the primary array.
* If a match is found, that element will be excluded from the result.
* @returns A new array containing the elements that are present in the primary array but not
* in the flattened array.
*
* @example
* const array1 = [1, 2, 3, 4, 5];
* const array2 = [2, 4];
* const array3 = [5, 6];
* const result = difference(array1, array2, array3);
* // result will be [1, 3] since 2, 4, and 5 are in the other arrays and are excluded from the result.
*
* @example
* const arrayLike1 = { 0: 1, 1: 2, 2: 3, length: 3 };
* const arrayLike2 = { 0: 2, 1: 4, length: 2 };
* const result = difference(arrayLike1, arrayLike2);
* // result will be [1, 3] since 2 is in both array-like objects and is excluded from the result.
*/
function difference(arr, ...values) {
if (!isArrayLikeObject(arr)) return [];
const arr1 = Array.from(arr);
const arr2 = [];
for (let i = 0; i < values.length; i++) {
const value = values[i];
if (isArrayLikeObject(value)) arr2.push(...Array.from(value));
}
return difference$1(arr1, arr2);
}
//#endregion
export { difference };

View file

@ -0,0 +1,109 @@
import { ValueIteratee } from "../_internal/ValueIteratee.mjs";
//#region src/compat/array/differenceBy.d.ts
/**
* Creates an array of array values not included in the other given arrays using an iteratee function.
*
* @template T1, T2
* @param array The array to inspect
* @param values The values to exclude
* @param iteratee The iteratee invoked per element
* @returns Returns the new array of filtered values
* @example
* differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor)
* // => [1.2]
*/
declare function differenceBy<T1, T2>(array: ArrayLike<T1> | null | undefined, values: ArrayLike<T2>, iteratee: ValueIteratee<T1 | T2>): T1[];
/**
* Creates an array of array values not included in the other given arrays using an iteratee function.
*
* @template T1, T2, T3
* @param array The array to inspect
* @param values1 The first array of values to exclude
* @param values2 The second array of values to exclude
* @param iteratee The iteratee invoked per element
* @returns Returns the new array of filtered values
* @example
* differenceBy([2.1, 1.2], [2.3], [1.4], Math.floor)
* // => []
*/
declare function differenceBy<T1, T2, T3>(array: ArrayLike<T1> | null | undefined, values1: ArrayLike<T2>, values2: ArrayLike<T3>, iteratee: ValueIteratee<T1 | T2 | T3>): T1[];
/**
* Creates an array of array values not included in the other given arrays using an iteratee function.
*
* @template T1, T2, T3, T4
* @param array The array to inspect
* @param values1 The first array of values to exclude
* @param values2 The second array of values to exclude
* @param values3 The third array of values to exclude
* @param iteratee The iteratee invoked per element
* @returns Returns the new array of filtered values
* @example
* differenceBy([2.1, 1.2, 3.5], [2.3], [1.4], [3.2], Math.floor)
* // => []
*/
declare function differenceBy<T1, T2, T3, T4>(array: ArrayLike<T1> | null | undefined, values1: ArrayLike<T2>, values2: ArrayLike<T3>, values3: ArrayLike<T4>, iteratee: ValueIteratee<T1 | T2 | T3 | T4>): T1[];
/**
* Creates an array of array values not included in the other given arrays using an iteratee function.
*
* @template T1, T2, T3, T4, T5
* @param array The array to inspect
* @param values1 The first array of values to exclude
* @param values2 The second array of values to exclude
* @param values3 The third array of values to exclude
* @param values4 The fourth array of values to exclude
* @param iteratee The iteratee invoked per element
* @returns Returns the new array of filtered values
* @example
* differenceBy([2.1, 1.2, 3.5, 4.8], [2.3], [1.4], [3.2], [4.1], Math.floor)
* // => []
*/
declare function differenceBy<T1, T2, T3, T4, T5>(array: ArrayLike<T1> | null | undefined, values1: ArrayLike<T2>, values2: ArrayLike<T3>, values3: ArrayLike<T4>, values4: ArrayLike<T5>, iteratee: ValueIteratee<T1 | T2 | T3 | T4 | T5>): T1[];
/**
* Creates an array of array values not included in the other given arrays using an iteratee function.
*
* @template T1, T2, T3, T4, T5, T6
* @param array The array to inspect
* @param values1 The first array of values to exclude
* @param values2 The second array of values to exclude
* @param values3 The third array of values to exclude
* @param values4 The fourth array of values to exclude
* @param values5 The fifth array of values to exclude
* @param iteratee The iteratee invoked per element
* @returns Returns the new array of filtered values
* @example
* differenceBy([2.1, 1.2, 3.5, 4.8, 5.3], [2.3], [1.4], [3.2], [4.1], [5.8], Math.floor)
* // => []
*/
declare function differenceBy<T1, T2, T3, T4, T5, T6>(array: ArrayLike<T1> | null | undefined, values1: ArrayLike<T2>, values2: ArrayLike<T3>, values3: ArrayLike<T4>, values4: ArrayLike<T5>, values5: ArrayLike<T6>, iteratee: ValueIteratee<T1 | T2 | T3 | T4 | T5 | T6>): T1[];
/**
* Creates an array of array values not included in the other given arrays using an iteratee function.
*
* @template T1, T2, T3, T4, T5, T6, T7
* @param array The array to inspect
* @param values1 The first array of values to exclude
* @param values2 The second array of values to exclude
* @param values3 The third array of values to exclude
* @param values4 The fourth array of values to exclude
* @param values5 The fifth array of values to exclude
* @param values Additional arrays of values to exclude and iteratee
* @returns Returns the new array of filtered values
* @example
* differenceBy([2.1, 1.2, 3.5, 4.8, 5.3, 6.7], [2.3], [1.4], [3.2], [4.1], [5.8], [6.2], Math.floor)
* // => []
*/
declare function differenceBy<T1, T2, T3, T4, T5, T6, T7>(array: ArrayLike<T1> | null | undefined, values1: ArrayLike<T2>, values2: ArrayLike<T3>, values3: ArrayLike<T4>, values4: ArrayLike<T5>, values5: ArrayLike<T6>, ...values: Array<ArrayLike<T7> | ValueIteratee<T1 | T2 | T3 | T4 | T5 | T6 | T7>>): T1[];
/**
* Creates an array of array values not included in the other given arrays.
*
* @template T
* @param array The array to inspect
* @param values The arrays of values to exclude
* @returns Returns the new array of filtered values
* @example
* differenceBy([2, 1], [2, 3])
* // => [1]
*/
declare function differenceBy<T>(array: ArrayLike<T> | null | undefined, ...values: Array<ArrayLike<T>>): T[];
//#endregion
export { differenceBy };

View file

@ -0,0 +1,109 @@
import { ValueIteratee } from "../_internal/ValueIteratee.js";
//#region src/compat/array/differenceBy.d.ts
/**
* Creates an array of array values not included in the other given arrays using an iteratee function.
*
* @template T1, T2
* @param array The array to inspect
* @param values The values to exclude
* @param iteratee The iteratee invoked per element
* @returns Returns the new array of filtered values
* @example
* differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor)
* // => [1.2]
*/
declare function differenceBy<T1, T2>(array: ArrayLike<T1> | null | undefined, values: ArrayLike<T2>, iteratee: ValueIteratee<T1 | T2>): T1[];
/**
* Creates an array of array values not included in the other given arrays using an iteratee function.
*
* @template T1, T2, T3
* @param array The array to inspect
* @param values1 The first array of values to exclude
* @param values2 The second array of values to exclude
* @param iteratee The iteratee invoked per element
* @returns Returns the new array of filtered values
* @example
* differenceBy([2.1, 1.2], [2.3], [1.4], Math.floor)
* // => []
*/
declare function differenceBy<T1, T2, T3>(array: ArrayLike<T1> | null | undefined, values1: ArrayLike<T2>, values2: ArrayLike<T3>, iteratee: ValueIteratee<T1 | T2 | T3>): T1[];
/**
* Creates an array of array values not included in the other given arrays using an iteratee function.
*
* @template T1, T2, T3, T4
* @param array The array to inspect
* @param values1 The first array of values to exclude
* @param values2 The second array of values to exclude
* @param values3 The third array of values to exclude
* @param iteratee The iteratee invoked per element
* @returns Returns the new array of filtered values
* @example
* differenceBy([2.1, 1.2, 3.5], [2.3], [1.4], [3.2], Math.floor)
* // => []
*/
declare function differenceBy<T1, T2, T3, T4>(array: ArrayLike<T1> | null | undefined, values1: ArrayLike<T2>, values2: ArrayLike<T3>, values3: ArrayLike<T4>, iteratee: ValueIteratee<T1 | T2 | T3 | T4>): T1[];
/**
* Creates an array of array values not included in the other given arrays using an iteratee function.
*
* @template T1, T2, T3, T4, T5
* @param array The array to inspect
* @param values1 The first array of values to exclude
* @param values2 The second array of values to exclude
* @param values3 The third array of values to exclude
* @param values4 The fourth array of values to exclude
* @param iteratee The iteratee invoked per element
* @returns Returns the new array of filtered values
* @example
* differenceBy([2.1, 1.2, 3.5, 4.8], [2.3], [1.4], [3.2], [4.1], Math.floor)
* // => []
*/
declare function differenceBy<T1, T2, T3, T4, T5>(array: ArrayLike<T1> | null | undefined, values1: ArrayLike<T2>, values2: ArrayLike<T3>, values3: ArrayLike<T4>, values4: ArrayLike<T5>, iteratee: ValueIteratee<T1 | T2 | T3 | T4 | T5>): T1[];
/**
* Creates an array of array values not included in the other given arrays using an iteratee function.
*
* @template T1, T2, T3, T4, T5, T6
* @param array The array to inspect
* @param values1 The first array of values to exclude
* @param values2 The second array of values to exclude
* @param values3 The third array of values to exclude
* @param values4 The fourth array of values to exclude
* @param values5 The fifth array of values to exclude
* @param iteratee The iteratee invoked per element
* @returns Returns the new array of filtered values
* @example
* differenceBy([2.1, 1.2, 3.5, 4.8, 5.3], [2.3], [1.4], [3.2], [4.1], [5.8], Math.floor)
* // => []
*/
declare function differenceBy<T1, T2, T3, T4, T5, T6>(array: ArrayLike<T1> | null | undefined, values1: ArrayLike<T2>, values2: ArrayLike<T3>, values3: ArrayLike<T4>, values4: ArrayLike<T5>, values5: ArrayLike<T6>, iteratee: ValueIteratee<T1 | T2 | T3 | T4 | T5 | T6>): T1[];
/**
* Creates an array of array values not included in the other given arrays using an iteratee function.
*
* @template T1, T2, T3, T4, T5, T6, T7
* @param array The array to inspect
* @param values1 The first array of values to exclude
* @param values2 The second array of values to exclude
* @param values3 The third array of values to exclude
* @param values4 The fourth array of values to exclude
* @param values5 The fifth array of values to exclude
* @param values Additional arrays of values to exclude and iteratee
* @returns Returns the new array of filtered values
* @example
* differenceBy([2.1, 1.2, 3.5, 4.8, 5.3, 6.7], [2.3], [1.4], [3.2], [4.1], [5.8], [6.2], Math.floor)
* // => []
*/
declare function differenceBy<T1, T2, T3, T4, T5, T6, T7>(array: ArrayLike<T1> | null | undefined, values1: ArrayLike<T2>, values2: ArrayLike<T3>, values3: ArrayLike<T4>, values4: ArrayLike<T5>, values5: ArrayLike<T6>, ...values: Array<ArrayLike<T7> | ValueIteratee<T1 | T2 | T3 | T4 | T5 | T6 | T7>>): T1[];
/**
* Creates an array of array values not included in the other given arrays.
*
* @template T
* @param array The array to inspect
* @param values The arrays of values to exclude
* @returns Returns the new array of filtered values
* @example
* differenceBy([2, 1], [2, 3])
* // => [1]
*/
declare function differenceBy<T>(array: ArrayLike<T> | null | undefined, ...values: Array<ArrayLike<T>>): T[];
//#endregion
export { differenceBy };

View file

@ -0,0 +1,24 @@
const require_difference = require("../../array/difference.js");
const require_differenceBy = require("../../array/differenceBy.js");
const require_iteratee = require("../util/iteratee.js");
const require_isArrayLikeObject = require("../predicate/isArrayLikeObject.js");
const require_last = require("./last.js");
const require_flattenArrayLike = require("../_internal/flattenArrayLike.js");
//#region src/compat/array/differenceBy.ts
/**
* Computes the difference between an array and multiple arrays using an iteratee function.
*
* @template T
* @param array - The primary array from which to derive the difference.
* @param values - Multiple arrays containing elements to be excluded from the primary array.
* @returns A new array containing the elements that are present in the primary array but not in the values arrays.
*/
function differenceBy(array, ..._values) {
if (!require_isArrayLikeObject.isArrayLikeObject(array)) return [];
const iteratee$1 = require_last.last(_values);
const values = require_flattenArrayLike.flattenArrayLike(_values);
if (require_isArrayLikeObject.isArrayLikeObject(iteratee$1)) return require_difference.difference(Array.from(array), values);
return require_differenceBy.differenceBy(Array.from(array), values, require_iteratee.iteratee(iteratee$1));
}
//#endregion
exports.differenceBy = differenceBy;

View file

@ -0,0 +1,24 @@
import { difference } from "../../array/difference.mjs";
import { differenceBy as differenceBy$1 } from "../../array/differenceBy.mjs";
import { iteratee } from "../util/iteratee.mjs";
import { isArrayLikeObject } from "../predicate/isArrayLikeObject.mjs";
import { last } from "./last.mjs";
import { flattenArrayLike } from "../_internal/flattenArrayLike.mjs";
//#region src/compat/array/differenceBy.ts
/**
* Computes the difference between an array and multiple arrays using an iteratee function.
*
* @template T
* @param array - The primary array from which to derive the difference.
* @param values - Multiple arrays containing elements to be excluded from the primary array.
* @returns A new array containing the elements that are present in the primary array but not in the values arrays.
*/
function differenceBy(array, ..._values) {
if (!isArrayLikeObject(array)) return [];
const iteratee$1 = last(_values);
const values = flattenArrayLike(_values);
if (isArrayLikeObject(iteratee$1)) return difference(Array.from(array), values);
return differenceBy$1(Array.from(array), values, iteratee(iteratee$1));
}
//#endregion
export { differenceBy };

View file

@ -0,0 +1,92 @@
//#region src/compat/array/differenceWith.d.ts
/**
* Computes the difference between the primary array and another array using a comparator function.
*
* @template T1, T2
* @param array - The primary array to compare elements against.
* @param values - The array containing elements to compare with the primary array.
* @param comparator - A function to determine if two elements are considered equal.
* @returns A new array containing the elements from the primary array that do not match any elements in `values` based on the comparator.
*
* @example
* const array = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const values = [{ id: 2 }];
* const comparator = (a, b) => a.id === b.id;
*
* const result = differenceWith(array, values, comparator);
* // result will be [{ id: 1 }, { id: 3 }]
*/
declare function differenceWith<T1, T2>(array: ArrayLike<T1> | null | undefined, values: ArrayLike<T2>, comparator: (a: T1, b: T2) => boolean): T1[];
/**
* Computes the difference between the primary array and two arrays using a comparator function.
*
* @template T1, T2, T3
* @param array - The primary array to compare elements against.
* @param values1 - The first array containing elements to compare with the primary array.
* @param values2 - The second array containing elements to compare with the primary array.
* @param comparator - A function to determine if two elements are considered equal.
* @returns A new array containing the elements from the primary array that do not match any elements in `values1` or `values2` based on the comparator.
*
* @example
* const array = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const values1 = [{ id: 2 }];
* const values2 = [{ id: 3 }];
* const comparator = (a, b) => a.id === b.id;
*
* const result = differenceWith(array, values1, values2, comparator);
* // result will be [{ id: 1 }]
*/
declare function differenceWith<T1, T2, T3>(array: ArrayLike<T1> | null | undefined, values1: ArrayLike<T2>, values2: ArrayLike<T3>, comparator: (a: T1, b: T2 | T3) => boolean): T1[];
/**
* Computes the difference between the primary array and multiple arrays using a comparator function.
*
* @template T1, T2, T3, T4
* @param array - The primary array to compare elements against.
* @param values1 - The first array containing elements to compare with the primary array.
* @param values2 - The second array containing elements to compare with the primary array.
* @param values - Additional arrays and an optional comparator function to determine if two elements are considered equal.
* @returns A new array containing the elements from the primary array that do not match any elements
* in `values1`, `values2`, or subsequent arrays. If a comparator function is provided, it will be used to compare elements;
* otherwise, [SameValueZero](https://tc39.es/ecma262/multipage/abstract-operations.html#sec-samevaluezero) algorithm will be used.
*
* @example
* // Example with comparator function
* const array = [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }];
* const values1 = [{ id: 2 }];
* const values2 = [{ id: 3 }];
* const values3 = [{ id: 4 }];
* const comparator = (a, b) => a.id === b.id;
*
* const result = differenceWith(array, values1, values2, values3, comparator);
* // result will be [{ id: 1 }]
*
* @example
* // Example without comparator function (behaves like `difference`)
* const array = [1, 2, 3, 4];
* const values1 = [2];
* const values2 = [3];
* const values3 = [4];
*
* const result = differenceWith(array, values1, values2, values3);
* // result will be [1]
*/
declare function differenceWith<T1, T2, T3, T4>(array: ArrayLike<T1> | null | undefined, values1: ArrayLike<T2>, values2: ArrayLike<T3>, ...values: Array<ArrayLike<T4> | ((a: T1, b: T2 | T3 | T4) => boolean)>): T1[];
/**
* Computes the difference between the primary array and one or more arrays without using a comparator function.
*
* @template T
* @param array - The primary array to compare elements against.
* @param values - One or more arrays containing elements to compare with the primary array.
* @returns A new array containing the elements from the primary array that do not match any elements in the provided arrays.
*
* @example
* const array = [1, 2, 3];
* const values1 = [2];
* const values2 = [3];
*
* const result = differenceWith(array, values1, values2);
* // result will be [1]
*/
declare function differenceWith<T>(array: ArrayLike<T> | null | undefined, ...values: Array<ArrayLike<T>>): T[];
//#endregion
export { differenceWith };

View file

@ -0,0 +1,92 @@
//#region src/compat/array/differenceWith.d.ts
/**
* Computes the difference between the primary array and another array using a comparator function.
*
* @template T1, T2
* @param array - The primary array to compare elements against.
* @param values - The array containing elements to compare with the primary array.
* @param comparator - A function to determine if two elements are considered equal.
* @returns A new array containing the elements from the primary array that do not match any elements in `values` based on the comparator.
*
* @example
* const array = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const values = [{ id: 2 }];
* const comparator = (a, b) => a.id === b.id;
*
* const result = differenceWith(array, values, comparator);
* // result will be [{ id: 1 }, { id: 3 }]
*/
declare function differenceWith<T1, T2>(array: ArrayLike<T1> | null | undefined, values: ArrayLike<T2>, comparator: (a: T1, b: T2) => boolean): T1[];
/**
* Computes the difference between the primary array and two arrays using a comparator function.
*
* @template T1, T2, T3
* @param array - The primary array to compare elements against.
* @param values1 - The first array containing elements to compare with the primary array.
* @param values2 - The second array containing elements to compare with the primary array.
* @param comparator - A function to determine if two elements are considered equal.
* @returns A new array containing the elements from the primary array that do not match any elements in `values1` or `values2` based on the comparator.
*
* @example
* const array = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const values1 = [{ id: 2 }];
* const values2 = [{ id: 3 }];
* const comparator = (a, b) => a.id === b.id;
*
* const result = differenceWith(array, values1, values2, comparator);
* // result will be [{ id: 1 }]
*/
declare function differenceWith<T1, T2, T3>(array: ArrayLike<T1> | null | undefined, values1: ArrayLike<T2>, values2: ArrayLike<T3>, comparator: (a: T1, b: T2 | T3) => boolean): T1[];
/**
* Computes the difference between the primary array and multiple arrays using a comparator function.
*
* @template T1, T2, T3, T4
* @param array - The primary array to compare elements against.
* @param values1 - The first array containing elements to compare with the primary array.
* @param values2 - The second array containing elements to compare with the primary array.
* @param values - Additional arrays and an optional comparator function to determine if two elements are considered equal.
* @returns A new array containing the elements from the primary array that do not match any elements
* in `values1`, `values2`, or subsequent arrays. If a comparator function is provided, it will be used to compare elements;
* otherwise, [SameValueZero](https://tc39.es/ecma262/multipage/abstract-operations.html#sec-samevaluezero) algorithm will be used.
*
* @example
* // Example with comparator function
* const array = [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }];
* const values1 = [{ id: 2 }];
* const values2 = [{ id: 3 }];
* const values3 = [{ id: 4 }];
* const comparator = (a, b) => a.id === b.id;
*
* const result = differenceWith(array, values1, values2, values3, comparator);
* // result will be [{ id: 1 }]
*
* @example
* // Example without comparator function (behaves like `difference`)
* const array = [1, 2, 3, 4];
* const values1 = [2];
* const values2 = [3];
* const values3 = [4];
*
* const result = differenceWith(array, values1, values2, values3);
* // result will be [1]
*/
declare function differenceWith<T1, T2, T3, T4>(array: ArrayLike<T1> | null | undefined, values1: ArrayLike<T2>, values2: ArrayLike<T3>, ...values: Array<ArrayLike<T4> | ((a: T1, b: T2 | T3 | T4) => boolean)>): T1[];
/**
* Computes the difference between the primary array and one or more arrays without using a comparator function.
*
* @template T
* @param array - The primary array to compare elements against.
* @param values - One or more arrays containing elements to compare with the primary array.
* @returns A new array containing the elements from the primary array that do not match any elements in the provided arrays.
*
* @example
* const array = [1, 2, 3];
* const values1 = [2];
* const values2 = [3];
*
* const result = differenceWith(array, values1, values2);
* // result will be [1]
*/
declare function differenceWith<T>(array: ArrayLike<T> | null | undefined, ...values: Array<ArrayLike<T>>): T[];
//#endregion
export { differenceWith };

View file

@ -0,0 +1,42 @@
const require_difference = require("../../array/difference.js");
const require_differenceWith = require("../../array/differenceWith.js");
const require_isArrayLikeObject = require("../predicate/isArrayLikeObject.js");
const require_last = require("./last.js");
const require_flattenArrayLike = require("../_internal/flattenArrayLike.js");
//#region src/compat/array/differenceWith.ts
/**
* Computes the difference between the primary array and one or more arrays using an optional comparator function.
*
* @template T
* @param array - The primary array to compare elements against.
* @param values - One or more arrays to compare with the primary array, and an optional comparator function to determine if two elements are considered equal.
* @returns A new array containing the elements from the primary array that do not match any elements in the provided arrays or those compared using the comparator function.
*
* @example
* // Example with a comparator function
* const array = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const values1 = [{ id: 2 }];
* const values2 = [{ id: 3 }];
* const comparator = (a, b) => a.id === b.id;
*
* const result = differenceWith(array, values1, values2, comparator);
* // result will be [{ id: 1 }]
*
* @example
* // Example without a comparator function
* const array = [1, 2, 3];
* const values1 = [2];
* const values2 = [3];
*
* const result = differenceWith(array, values1, values2);
* // result will be [1]
*/
function differenceWith(array, ...values) {
if (!require_isArrayLikeObject.isArrayLikeObject(array)) return [];
const comparator = require_last.last(values);
const flattenedValues = require_flattenArrayLike.flattenArrayLike(values);
if (typeof comparator === "function") return require_differenceWith.differenceWith(Array.from(array), flattenedValues, comparator);
return require_difference.difference(Array.from(array), flattenedValues);
}
//#endregion
exports.differenceWith = differenceWith;

View file

@ -0,0 +1,42 @@
import { difference } from "../../array/difference.mjs";
import { differenceWith as differenceWith$1 } from "../../array/differenceWith.mjs";
import { isArrayLikeObject } from "../predicate/isArrayLikeObject.mjs";
import { last } from "./last.mjs";
import { flattenArrayLike } from "../_internal/flattenArrayLike.mjs";
//#region src/compat/array/differenceWith.ts
/**
* Computes the difference between the primary array and one or more arrays using an optional comparator function.
*
* @template T
* @param array - The primary array to compare elements against.
* @param values - One or more arrays to compare with the primary array, and an optional comparator function to determine if two elements are considered equal.
* @returns A new array containing the elements from the primary array that do not match any elements in the provided arrays or those compared using the comparator function.
*
* @example
* // Example with a comparator function
* const array = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const values1 = [{ id: 2 }];
* const values2 = [{ id: 3 }];
* const comparator = (a, b) => a.id === b.id;
*
* const result = differenceWith(array, values1, values2, comparator);
* // result will be [{ id: 1 }]
*
* @example
* // Example without a comparator function
* const array = [1, 2, 3];
* const values1 = [2];
* const values2 = [3];
*
* const result = differenceWith(array, values1, values2);
* // result will be [1]
*/
function differenceWith(array, ...values) {
if (!isArrayLikeObject(array)) return [];
const comparator = last(values);
const flattenedValues = flattenArrayLike(values);
if (typeof comparator === "function") return differenceWith$1(Array.from(array), flattenedValues, comparator);
return difference(Array.from(array), flattenedValues);
}
//#endregion
export { differenceWith };

View file

@ -0,0 +1,20 @@
//#region src/compat/array/drop.d.ts
/**
* Removes a specified number of elements from the beginning of an array and returns the rest.
*
* This function takes an array and a number, and returns a new array with the specified number
* of elements removed from the start.
*
* @template T - The type of elements in the array.
* @param array - The array from which to drop elements.
* @param itemsCount - The number of elements to drop from the beginning of the array.
* @returns A new array with the specified number of elements removed from the start.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = drop(array, 2);
* result will be [3, 4, 5] since the first two elements are dropped.
*/
declare function drop<T>(array: ArrayLike<T> | null | undefined, itemsCount?: number): T[];
//#endregion
export { drop };

View file

@ -0,0 +1,20 @@
//#region src/compat/array/drop.d.ts
/**
* Removes a specified number of elements from the beginning of an array and returns the rest.
*
* This function takes an array and a number, and returns a new array with the specified number
* of elements removed from the start.
*
* @template T - The type of elements in the array.
* @param array - The array from which to drop elements.
* @param itemsCount - The number of elements to drop from the beginning of the array.
* @returns A new array with the specified number of elements removed from the start.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = drop(array, 2);
* result will be [3, 4, 5] since the first two elements are dropped.
*/
declare function drop<T>(array: ArrayLike<T> | null | undefined, itemsCount?: number): T[];
//#endregion
export { drop };

View file

@ -0,0 +1,12 @@
const require_drop = require("../../array/drop.js");
const require_toArray = require("../_internal/toArray.js");
const require_isArrayLike = require("../predicate/isArrayLike.js");
const require_toInteger = require("../util/toInteger.js");
//#region src/compat/array/drop.ts
function drop(array, itemsCount = 1, guard) {
if (!require_isArrayLike.isArrayLike(array)) return [];
itemsCount = guard ? 1 : require_toInteger.toInteger(itemsCount);
return require_drop.drop(require_toArray.toArray(array), itemsCount);
}
//#endregion
exports.drop = drop;

View file

@ -0,0 +1,12 @@
import { drop as drop$1 } from "../../array/drop.mjs";
import { toArray } from "../_internal/toArray.mjs";
import { isArrayLike } from "../predicate/isArrayLike.mjs";
import { toInteger } from "../util/toInteger.mjs";
//#region src/compat/array/drop.ts
function drop(array, itemsCount = 1, guard) {
if (!isArrayLike(array)) return [];
itemsCount = guard ? 1 : toInteger(itemsCount);
return drop$1(toArray(array), itemsCount);
}
//#endregion
export { drop };

View file

@ -0,0 +1,21 @@
//#region src/compat/array/dropRight.d.ts
/**
* Removes a specified number of elements from the end of an array and returns the rest.
*
* This function takes an array and a number, and returns a new array with the specified number
* of elements removed from the end.
*
* @template T - The type of elements in the array.
* @param collection - The array from which to drop elements.
* @param itemsCount - The number of elements to drop from the end of the array.
* @param [guard] - Enables use as an iteratee for methods like `_.map`.
* @returns A new array with the specified number of elements removed from the end.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = dropRight(array, 2);
* // result will be [1, 2, 3] since the last two elements are dropped.
*/
declare function dropRight<T>(array: ArrayLike<T> | null | undefined, n?: number): T[];
//#endregion
export { dropRight };

View file

@ -0,0 +1,21 @@
//#region src/compat/array/dropRight.d.ts
/**
* Removes a specified number of elements from the end of an array and returns the rest.
*
* This function takes an array and a number, and returns a new array with the specified number
* of elements removed from the end.
*
* @template T - The type of elements in the array.
* @param collection - The array from which to drop elements.
* @param itemsCount - The number of elements to drop from the end of the array.
* @param [guard] - Enables use as an iteratee for methods like `_.map`.
* @returns A new array with the specified number of elements removed from the end.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = dropRight(array, 2);
* // result will be [1, 2, 3] since the last two elements are dropped.
*/
declare function dropRight<T>(array: ArrayLike<T> | null | undefined, n?: number): T[];
//#endregion
export { dropRight };

View file

@ -0,0 +1,29 @@
const require_dropRight = require("../../array/dropRight.js");
const require_toArray = require("../_internal/toArray.js");
const require_isArrayLike = require("../predicate/isArrayLike.js");
const require_toInteger = require("../util/toInteger.js");
//#region src/compat/array/dropRight.ts
/**
* Removes a specified number of elements from the end of an array and returns the rest.
*
* This function takes an array and a number, and returns a new array with the specified number
* of elements removed from the end.
*
* @template T - The type of elements in the array.
* @param collection - The array from which to drop elements.
* @param itemsCount - The number of elements to drop from the end of the array.
* @param [guard] - Enables use as an iteratee for methods like `_.map`.
* @returns A new array with the specified number of elements removed from the end.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = dropRight(array, 2);
* // result will be [1, 2, 3] since the last two elements are dropped.
*/
function dropRight(collection, itemsCount = 1, guard) {
if (!require_isArrayLike.isArrayLike(collection)) return [];
itemsCount = guard ? 1 : require_toInteger.toInteger(itemsCount);
return require_dropRight.dropRight(require_toArray.toArray(collection), itemsCount);
}
//#endregion
exports.dropRight = dropRight;

View file

@ -0,0 +1,29 @@
import { dropRight as dropRight$1 } from "../../array/dropRight.mjs";
import { toArray } from "../_internal/toArray.mjs";
import { isArrayLike } from "../predicate/isArrayLike.mjs";
import { toInteger } from "../util/toInteger.mjs";
//#region src/compat/array/dropRight.ts
/**
* Removes a specified number of elements from the end of an array and returns the rest.
*
* This function takes an array and a number, and returns a new array with the specified number
* of elements removed from the end.
*
* @template T - The type of elements in the array.
* @param collection - The array from which to drop elements.
* @param itemsCount - The number of elements to drop from the end of the array.
* @param [guard] - Enables use as an iteratee for methods like `_.map`.
* @returns A new array with the specified number of elements removed from the end.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = dropRight(array, 2);
* // result will be [1, 2, 3] since the last two elements are dropped.
*/
function dropRight(collection, itemsCount = 1, guard) {
if (!isArrayLike(collection)) return [];
itemsCount = guard ? 1 : toInteger(itemsCount);
return dropRight$1(toArray(collection), itemsCount);
}
//#endregion
export { dropRight };

View file

@ -0,0 +1,38 @@
import { ListIteratee } from "../_internal/ListIteratee.mjs";
//#region src/compat/array/dropRightWhile.d.ts
/**
* Creates a slice of array excluding elements dropped from the end until predicate returns falsey.
* The predicate is invoked with three arguments: (value, index, array).
*
* @template T - The type of elements in the array.
* @param array - The array to query.
* @param [predicate] - The function invoked per iteration.
* @returns Returns the slice of array.
* @example
*
* const users = [
* { user: 'barney', active: true },
* { user: 'fred', active: false },
* { user: 'pebbles', active: false }
* ];
*
* // Using function predicate
* dropRightWhile(users, user => !user.active);
* // => [{ user: 'barney', active: true }]
*
* // Using matches shorthand
* dropRightWhile(users, { user: 'pebbles', active: false });
* // => [{ user: 'barney', active: true }, { user: 'fred', active: false }]
*
* // Using matchesProperty shorthand
* dropRightWhile(users, ['active', false]);
* // => [{ user: 'barney', active: true }]
*
* // Using property shorthand
* dropRightWhile(users, 'active');
* // => [{ user: 'barney', active: true }, { user: 'fred', active: false }, { user: 'pebbles', active: false }]
*/
declare function dropRightWhile<T>(array: ArrayLike<T> | null | undefined, predicate?: ListIteratee<T>): T[];
//#endregion
export { dropRightWhile };

View file

@ -0,0 +1,38 @@
import { ListIteratee } from "../_internal/ListIteratee.js";
//#region src/compat/array/dropRightWhile.d.ts
/**
* Creates a slice of array excluding elements dropped from the end until predicate returns falsey.
* The predicate is invoked with three arguments: (value, index, array).
*
* @template T - The type of elements in the array.
* @param array - The array to query.
* @param [predicate] - The function invoked per iteration.
* @returns Returns the slice of array.
* @example
*
* const users = [
* { user: 'barney', active: true },
* { user: 'fred', active: false },
* { user: 'pebbles', active: false }
* ];
*
* // Using function predicate
* dropRightWhile(users, user => !user.active);
* // => [{ user: 'barney', active: true }]
*
* // Using matches shorthand
* dropRightWhile(users, { user: 'pebbles', active: false });
* // => [{ user: 'barney', active: true }, { user: 'fred', active: false }]
*
* // Using matchesProperty shorthand
* dropRightWhile(users, ['active', false]);
* // => [{ user: 'barney', active: true }]
*
* // Using property shorthand
* dropRightWhile(users, 'active');
* // => [{ user: 'barney', active: true }, { user: 'fred', active: false }, { user: 'pebbles', active: false }]
*/
declare function dropRightWhile<T>(array: ArrayLike<T> | null | undefined, predicate?: ListIteratee<T>): T[];
//#endregion
export { dropRightWhile };

View file

@ -0,0 +1,45 @@
const require_dropRightWhile = require("../../array/dropRightWhile.js");
const require_identity = require("../../function/identity.js");
const require_toArray = require("../_internal/toArray.js");
const require_isArrayLike = require("../predicate/isArrayLike.js");
const require_property = require("../object/property.js");
const require_matches = require("../predicate/matches.js");
const require_matchesProperty = require("../predicate/matchesProperty.js");
//#region src/compat/array/dropRightWhile.ts
/**
* Removes elements from the end of an array until the predicate returns false.
*
* This function iterates over an array and drops elements from the end until the provided
* predicate function returns false. It then returns a new array with the remaining elements.
*
* @template T - The type of elements in the array.
* @param array - The array from which to drop elements.
* @param predicate - A predicate function that determines
* whether to continue dropping elements. The function is called with each element, index, and array, and dropping
* continues as long as it returns true.
* @returns A new array with the elements remaining after the predicate returns false.
*
* @example
* const array = [3, 2, 1];
* const result = dropRightWhile(array, (item, index, arr) => index >= 1);
* // Returns: [3]
*/
function dropRightWhile(array, predicate = require_identity.identity) {
if (!require_isArrayLike.isArrayLike(array)) return [];
return dropRightWhileImpl(require_toArray.toArray(array), predicate);
}
function dropRightWhileImpl(arr, predicate) {
switch (typeof predicate) {
case "function": return require_dropRightWhile.dropRightWhile(arr, (item, index, arr) => Boolean(predicate(item, index, arr)));
case "object": if (Array.isArray(predicate) && predicate.length === 2) {
const key = predicate[0];
const value = predicate[1];
return require_dropRightWhile.dropRightWhile(arr, require_matchesProperty.matchesProperty(key, value));
} else return require_dropRightWhile.dropRightWhile(arr, require_matches.matches(predicate));
case "symbol":
case "number":
case "string": return require_dropRightWhile.dropRightWhile(arr, require_property.property(predicate));
}
}
//#endregion
exports.dropRightWhile = dropRightWhile;

View file

@ -0,0 +1,45 @@
import { dropRightWhile as dropRightWhile$1 } from "../../array/dropRightWhile.mjs";
import { identity } from "../../function/identity.mjs";
import { toArray } from "../_internal/toArray.mjs";
import { isArrayLike } from "../predicate/isArrayLike.mjs";
import { property } from "../object/property.mjs";
import { matches } from "../predicate/matches.mjs";
import { matchesProperty } from "../predicate/matchesProperty.mjs";
//#region src/compat/array/dropRightWhile.ts
/**
* Removes elements from the end of an array until the predicate returns false.
*
* This function iterates over an array and drops elements from the end until the provided
* predicate function returns false. It then returns a new array with the remaining elements.
*
* @template T - The type of elements in the array.
* @param array - The array from which to drop elements.
* @param predicate - A predicate function that determines
* whether to continue dropping elements. The function is called with each element, index, and array, and dropping
* continues as long as it returns true.
* @returns A new array with the elements remaining after the predicate returns false.
*
* @example
* const array = [3, 2, 1];
* const result = dropRightWhile(array, (item, index, arr) => index >= 1);
* // Returns: [3]
*/
function dropRightWhile(array, predicate = identity) {
if (!isArrayLike(array)) return [];
return dropRightWhileImpl(toArray(array), predicate);
}
function dropRightWhileImpl(arr, predicate) {
switch (typeof predicate) {
case "function": return dropRightWhile$1(arr, (item, index, arr) => Boolean(predicate(item, index, arr)));
case "object": if (Array.isArray(predicate) && predicate.length === 2) {
const key = predicate[0];
const value = predicate[1];
return dropRightWhile$1(arr, matchesProperty(key, value));
} else return dropRightWhile$1(arr, matches(predicate));
case "symbol":
case "number":
case "string": return dropRightWhile$1(arr, property(predicate));
}
}
//#endregion
export { dropRightWhile };

View file

@ -0,0 +1,29 @@
import { ListIteratee } from "../_internal/ListIteratee.mjs";
//#region src/compat/array/dropWhile.d.ts
/**
* Creates a slice of array excluding elements dropped from the beginning.
* Elements are dropped until predicate returns falsey.
* The predicate is invoked with three arguments: (value, index, array).
*
* @template T - The type of elements in the array
* @param array - The array to query
* @param [predicate=identity] - The function invoked per iteration
* @returns Returns the slice of array
*
* @example
* dropWhile([1, 2, 3], n => n < 3)
* // => [3]
*
* dropWhile([{ a: 1, b: 2 }, { a: 1, b: 3 }], { a: 1 })
* // => []
*
* dropWhile([{ a: 1, b: 2 }, { a: 1, b: 3 }], ['a', 1])
* // => []
*
* dropWhile([{ a: 1, b: 2 }, { a: 1, b: 3 }], 'a')
* // => []
*/
declare function dropWhile<T>(array: ArrayLike<T> | null | undefined, predicate?: ListIteratee<T>): T[];
//#endregion
export { dropWhile };

View file

@ -0,0 +1,29 @@
import { ListIteratee } from "../_internal/ListIteratee.js";
//#region src/compat/array/dropWhile.d.ts
/**
* Creates a slice of array excluding elements dropped from the beginning.
* Elements are dropped until predicate returns falsey.
* The predicate is invoked with three arguments: (value, index, array).
*
* @template T - The type of elements in the array
* @param array - The array to query
* @param [predicate=identity] - The function invoked per iteration
* @returns Returns the slice of array
*
* @example
* dropWhile([1, 2, 3], n => n < 3)
* // => [3]
*
* dropWhile([{ a: 1, b: 2 }, { a: 1, b: 3 }], { a: 1 })
* // => []
*
* dropWhile([{ a: 1, b: 2 }, { a: 1, b: 3 }], ['a', 1])
* // => []
*
* dropWhile([{ a: 1, b: 2 }, { a: 1, b: 3 }], 'a')
* // => []
*/
declare function dropWhile<T>(array: ArrayLike<T> | null | undefined, predicate?: ListIteratee<T>): T[];
//#endregion
export { dropWhile };

View file

@ -0,0 +1,50 @@
const require_dropWhile = require("../../array/dropWhile.js");
const require_identity = require("../../function/identity.js");
const require_toArray = require("../_internal/toArray.js");
const require_isArrayLike = require("../predicate/isArrayLike.js");
const require_property = require("../object/property.js");
const require_matches = require("../predicate/matches.js");
const require_matchesProperty = require("../predicate/matchesProperty.js");
//#region src/compat/array/dropWhile.ts
/**
* Creates a slice of array excluding elements dropped from the beginning.
* Elements are dropped until predicate returns falsey.
* The predicate is invoked with three arguments: (value, index, array).
*
* @template T - The type of elements in the array
* @param array - The array to query
* @param [predicate=identity] - The function invoked per iteration
* @returns Returns the slice of array
*
* @example
* dropWhile([1, 2, 3], n => n < 3)
* // => [3]
*
* dropWhile([{ a: 1, b: 2 }, { a: 1, b: 3 }], { a: 1 })
* // => []
*
* dropWhile([{ a: 1, b: 2 }, { a: 1, b: 3 }], ['a', 1])
* // => []
*
* dropWhile([{ a: 1, b: 2 }, { a: 1, b: 3 }], 'a')
* // => []
*/
function dropWhile(array, predicate = require_identity.identity) {
if (!require_isArrayLike.isArrayLike(array)) return [];
return dropWhileImpl(require_toArray.toArray(array), predicate);
}
function dropWhileImpl(arr, predicate) {
switch (typeof predicate) {
case "function": return require_dropWhile.dropWhile(arr, (item, index, arr) => Boolean(predicate(item, index, arr)));
case "object": if (Array.isArray(predicate) && predicate.length === 2) {
const key = predicate[0];
const value = predicate[1];
return require_dropWhile.dropWhile(arr, require_matchesProperty.matchesProperty(key, value));
} else return require_dropWhile.dropWhile(arr, require_matches.matches(predicate));
case "number":
case "symbol":
case "string": return require_dropWhile.dropWhile(arr, require_property.property(predicate));
}
}
//#endregion
exports.dropWhile = dropWhile;

View file

@ -0,0 +1,50 @@
import { dropWhile as dropWhile$1 } from "../../array/dropWhile.mjs";
import { identity } from "../../function/identity.mjs";
import { toArray } from "../_internal/toArray.mjs";
import { isArrayLike } from "../predicate/isArrayLike.mjs";
import { property } from "../object/property.mjs";
import { matches } from "../predicate/matches.mjs";
import { matchesProperty } from "../predicate/matchesProperty.mjs";
//#region src/compat/array/dropWhile.ts
/**
* Creates a slice of array excluding elements dropped from the beginning.
* Elements are dropped until predicate returns falsey.
* The predicate is invoked with three arguments: (value, index, array).
*
* @template T - The type of elements in the array
* @param array - The array to query
* @param [predicate=identity] - The function invoked per iteration
* @returns Returns the slice of array
*
* @example
* dropWhile([1, 2, 3], n => n < 3)
* // => [3]
*
* dropWhile([{ a: 1, b: 2 }, { a: 1, b: 3 }], { a: 1 })
* // => []
*
* dropWhile([{ a: 1, b: 2 }, { a: 1, b: 3 }], ['a', 1])
* // => []
*
* dropWhile([{ a: 1, b: 2 }, { a: 1, b: 3 }], 'a')
* // => []
*/
function dropWhile(array, predicate = identity) {
if (!isArrayLike(array)) return [];
return dropWhileImpl(toArray(array), predicate);
}
function dropWhileImpl(arr, predicate) {
switch (typeof predicate) {
case "function": return dropWhile$1(arr, (item, index, arr) => Boolean(predicate(item, index, arr)));
case "object": if (Array.isArray(predicate) && predicate.length === 2) {
const key = predicate[0];
const value = predicate[1];
return dropWhile$1(arr, matchesProperty(key, value));
} else return dropWhile$1(arr, matches(predicate));
case "number":
case "symbol":
case "string": return dropWhile$1(arr, property(predicate));
}
}
//#endregion
export { dropWhile };

View file

@ -0,0 +1 @@
import { forEach } from "./forEach.mjs";

View file

@ -0,0 +1 @@
import { forEach } from "./forEach.js";

View file

@ -0,0 +1 @@
require("./forEach.js");

View file

@ -0,0 +1 @@
import "./forEach.mjs";

View file

@ -0,0 +1 @@
import { forEachRight } from "./forEachRight.mjs";

View file

@ -0,0 +1 @@
import { forEachRight } from "./forEachRight.js";

View file

@ -0,0 +1 @@
require("./forEachRight.js");

View file

@ -0,0 +1 @@
import "./forEachRight.mjs";

View file

@ -0,0 +1,65 @@
import { ListIterateeCustom } from "../_internal/ListIterateeCustom.mjs";
import { ObjectIterateeCustom } from "../_internal/ObjectIteratee.mjs";
//#region src/compat/array/every.d.ts
/**
* Checks if all elements in a collection pass the predicate check.
* The predicate is invoked with three arguments: (value, index|key, collection).
*
* @template T - The type of elements in the collection
* @param collection - The collection to iterate over
* @param [predicate=identity] - The function invoked per iteration
* @returns Returns true if all elements pass the predicate check, else false
*
* @example
* // Using a function predicate
* every([true, 1, null, 'yes'], Boolean)
* // => false
*
* // Using property shorthand
* const users = [{ user: 'barney', age: 36 }, { user: 'fred', age: 40 }]
* every(users, 'age')
* // => true
*
* // Using matches shorthand
* every(users, { age: 36 })
* // => false
*
* // Using matchesProperty shorthand
* every(users, ['age', 36])
* // => false
*/
declare function every<T>(collection: ArrayLike<T> | null | undefined, predicate?: ListIterateeCustom<T, boolean>): boolean;
/**
* Checks if all elements in an object pass the predicate check.
* The predicate is invoked with three arguments: (value, key, object).
*
* @template T - The type of the object
* @param collection - The object to iterate over
* @param [predicate=identity] - The function invoked per iteration
* @returns Returns true if all elements pass the predicate check, else false
*
* @example
* // Using a function predicate
* every({ a: true, b: 1, c: null }, Boolean)
* // => false
*
* // Using property shorthand
* const users = {
* barney: { active: true, age: 36 },
* fred: { active: true, age: 40 }
* }
* every(users, 'active')
* // => true
*
* // Using matches shorthand
* every(users, { active: true })
* // => true
*
* // Using matchesProperty shorthand
* every(users, ['age', 36])
* // => false
*/
declare function every<T extends object>(collection: T | null | undefined, predicate?: ObjectIterateeCustom<T, boolean>): boolean;
//#endregion
export { every };

View file

@ -0,0 +1,65 @@
import { ListIterateeCustom } from "../_internal/ListIterateeCustom.js";
import { ObjectIterateeCustom } from "../_internal/ObjectIteratee.js";
//#region src/compat/array/every.d.ts
/**
* Checks if all elements in a collection pass the predicate check.
* The predicate is invoked with three arguments: (value, index|key, collection).
*
* @template T - The type of elements in the collection
* @param collection - The collection to iterate over
* @param [predicate=identity] - The function invoked per iteration
* @returns Returns true if all elements pass the predicate check, else false
*
* @example
* // Using a function predicate
* every([true, 1, null, 'yes'], Boolean)
* // => false
*
* // Using property shorthand
* const users = [{ user: 'barney', age: 36 }, { user: 'fred', age: 40 }]
* every(users, 'age')
* // => true
*
* // Using matches shorthand
* every(users, { age: 36 })
* // => false
*
* // Using matchesProperty shorthand
* every(users, ['age', 36])
* // => false
*/
declare function every<T>(collection: ArrayLike<T> | null | undefined, predicate?: ListIterateeCustom<T, boolean>): boolean;
/**
* Checks if all elements in an object pass the predicate check.
* The predicate is invoked with three arguments: (value, key, object).
*
* @template T - The type of the object
* @param collection - The object to iterate over
* @param [predicate=identity] - The function invoked per iteration
* @returns Returns true if all elements pass the predicate check, else false
*
* @example
* // Using a function predicate
* every({ a: true, b: 1, c: null }, Boolean)
* // => false
*
* // Using property shorthand
* const users = {
* barney: { active: true, age: 36 },
* fred: { active: true, age: 40 }
* }
* every(users, 'active')
* // => true
*
* // Using matches shorthand
* every(users, { active: true })
* // => true
*
* // Using matchesProperty shorthand
* every(users, ['age', 36])
* // => false
*/
declare function every<T extends object>(collection: T | null | undefined, predicate?: ObjectIterateeCustom<T, boolean>): boolean;
//#endregion
export { every };

View file

@ -0,0 +1,58 @@
const require_identity = require("../../function/identity.js");
const require_isArrayLike = require("../predicate/isArrayLike.js");
const require_property = require("../object/property.js");
const require_matches = require("../predicate/matches.js");
const require_matchesProperty = require("../predicate/matchesProperty.js");
const require_isIterateeCall = require("../_internal/isIterateeCall.js");
//#region src/compat/array/every.ts
/**
* Checks if every item in an object has a specific property, where the property name is provided as a PropertyKey.
*
* @template T
* @param object - The object to check through.
* @param source - The source array or object to check through.
* @param doesMatch - The criteria to match. It can be a function, a partial object, a key-value pair, or a property name.
* @param propertyToCheck - The property name to check.
* @param guard - Enables use as an iteratee for methods like `_.map`.
* @returns `true` if every property value has the specified property, or `false` if at least one does not match.
*
* @example
* // Using a property name
* const obj = { a: { id: 1, name: 'Alice' }, b: { id: 2, name: 'Bob' } };
* const result = every(obj, 'name');
* console.log(result); // true
*/
function every(source, doesMatch, guard) {
if (!source) return true;
if (guard && require_isIterateeCall.isIterateeCall(source, doesMatch, guard)) doesMatch = void 0;
if (!doesMatch) doesMatch = require_identity.identity;
let predicate;
switch (typeof doesMatch) {
case "function":
predicate = doesMatch;
break;
case "object":
if (Array.isArray(doesMatch) && doesMatch.length === 2) {
const key = doesMatch[0];
const value = doesMatch[1];
predicate = require_matchesProperty.matchesProperty(key, value);
} else predicate = require_matches.matches(doesMatch);
break;
case "symbol":
case "number":
case "string": predicate = require_property.property(doesMatch);
}
if (!require_isArrayLike.isArrayLike(source)) {
const keys = Object.keys(source);
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
const value = source[key];
if (!predicate(value, key, source)) return false;
}
return true;
}
for (let i = 0; i < source.length; i++) if (!predicate(source[i], i, source)) return false;
return true;
}
//#endregion
exports.every = every;

View file

@ -0,0 +1,58 @@
import { identity } from "../../function/identity.mjs";
import { isArrayLike } from "../predicate/isArrayLike.mjs";
import { property } from "../object/property.mjs";
import { matches } from "../predicate/matches.mjs";
import { matchesProperty } from "../predicate/matchesProperty.mjs";
import { isIterateeCall } from "../_internal/isIterateeCall.mjs";
//#region src/compat/array/every.ts
/**
* Checks if every item in an object has a specific property, where the property name is provided as a PropertyKey.
*
* @template T
* @param object - The object to check through.
* @param source - The source array or object to check through.
* @param doesMatch - The criteria to match. It can be a function, a partial object, a key-value pair, or a property name.
* @param propertyToCheck - The property name to check.
* @param guard - Enables use as an iteratee for methods like `_.map`.
* @returns `true` if every property value has the specified property, or `false` if at least one does not match.
*
* @example
* // Using a property name
* const obj = { a: { id: 1, name: 'Alice' }, b: { id: 2, name: 'Bob' } };
* const result = every(obj, 'name');
* console.log(result); // true
*/
function every(source, doesMatch, guard) {
if (!source) return true;
if (guard && isIterateeCall(source, doesMatch, guard)) doesMatch = void 0;
if (!doesMatch) doesMatch = identity;
let predicate;
switch (typeof doesMatch) {
case "function":
predicate = doesMatch;
break;
case "object":
if (Array.isArray(doesMatch) && doesMatch.length === 2) {
const key = doesMatch[0];
const value = doesMatch[1];
predicate = matchesProperty(key, value);
} else predicate = matches(doesMatch);
break;
case "symbol":
case "number":
case "string": predicate = property(doesMatch);
}
if (!isArrayLike(source)) {
const keys = Object.keys(source);
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
const value = source[key];
if (!predicate(value, key, source)) return false;
}
return true;
}
for (let i = 0; i < source.length; i++) if (!predicate(source[i], i, source)) return false;
return true;
}
//#endregion
export { every };

View file

@ -0,0 +1,54 @@
import { MutableList } from "../_internal/MutableList.mjs";
import { RejectReadonly } from "../_internal/RejectReadonly.mjs";
//#region src/compat/array/fill.d.ts
/**
* Fills an array with a value.
* @template T
* @param array - The array to fill
* @param value - The value to fill array with
* @returns Returns the filled array
* @example
* fill([1, 2, 3], 'a')
* // => ['a', 'a', 'a']
*/
declare function fill<T>(array: any[] | null | undefined, value: T): T[];
/**
* Fills an array-like object with a value.
* @template T, AL
* @param array - The array-like object to fill
* @param value - The value to fill array with
* @returns Returns the filled array-like object
* @example
* fill({ length: 3 }, 2)
* // => { 0: 2, 1: 2, 2: 2, length: 3 }
*/
declare function fill<T, AL extends MutableList<any>>(array: RejectReadonly<AL> | null | undefined, value: T): ArrayLike<T>;
/**
* Fills an array with a value from start up to end.
* @template T, U
* @param array - The array to fill
* @param value - The value to fill array with
* @param [start=0] - The start position
* @param [end=array.length] - The end position
* @returns Returns the filled array
* @example
* fill([1, 2, 3], 'a', 1, 2)
* // => [1, 'a', 3]
*/
declare function fill<T, U>(array: U[] | null | undefined, value: T, start?: number, end?: number): Array<T | U>;
/**
* Fills an array-like object with a value from start up to end.
* @template T, U
* @param array - The array-like object to fill
* @param value - The value to fill array with
* @param [start=0] - The start position
* @param [end=array.length] - The end position
* @returns Returns the filled array-like object
* @example
* fill({ 0: 1, 1: 2, 2: 3, length: 3 }, 'a', 1, 2)
* // => { 0: 1, 1: 'a', 2: 3, length: 3 }
*/
declare function fill<T, U extends MutableList<any>>(array: RejectReadonly<U> | null | undefined, value: T, start?: number, end?: number): ArrayLike<T | U[0]>;
//#endregion
export { fill };

View file

@ -0,0 +1,54 @@
import { MutableList } from "../_internal/MutableList.js";
import { RejectReadonly } from "../_internal/RejectReadonly.js";
//#region src/compat/array/fill.d.ts
/**
* Fills an array with a value.
* @template T
* @param array - The array to fill
* @param value - The value to fill array with
* @returns Returns the filled array
* @example
* fill([1, 2, 3], 'a')
* // => ['a', 'a', 'a']
*/
declare function fill<T>(array: any[] | null | undefined, value: T): T[];
/**
* Fills an array-like object with a value.
* @template T, AL
* @param array - The array-like object to fill
* @param value - The value to fill array with
* @returns Returns the filled array-like object
* @example
* fill({ length: 3 }, 2)
* // => { 0: 2, 1: 2, 2: 2, length: 3 }
*/
declare function fill<T, AL extends MutableList<any>>(array: RejectReadonly<AL> | null | undefined, value: T): ArrayLike<T>;
/**
* Fills an array with a value from start up to end.
* @template T, U
* @param array - The array to fill
* @param value - The value to fill array with
* @param [start=0] - The start position
* @param [end=array.length] - The end position
* @returns Returns the filled array
* @example
* fill([1, 2, 3], 'a', 1, 2)
* // => [1, 'a', 3]
*/
declare function fill<T, U>(array: U[] | null | undefined, value: T, start?: number, end?: number): Array<T | U>;
/**
* Fills an array-like object with a value from start up to end.
* @template T, U
* @param array - The array-like object to fill
* @param value - The value to fill array with
* @param [start=0] - The start position
* @param [end=array.length] - The end position
* @returns Returns the filled array-like object
* @example
* fill({ 0: 1, 1: 2, 2: 3, length: 3 }, 'a', 1, 2)
* // => { 0: 1, 1: 'a', 2: 3, length: 3 }
*/
declare function fill<T, U extends MutableList<any>>(array: RejectReadonly<U> | null | undefined, value: T, start?: number, end?: number): ArrayLike<T | U[0]>;
//#endregion
export { fill };

View file

@ -0,0 +1,42 @@
const require_fill = require("../../array/fill.js");
const require_isArrayLike = require("../predicate/isArrayLike.js");
const require_isString = require("../predicate/isString.js");
//#region src/compat/array/fill.ts
/**
* Fills elements of an array with a specified value from the start position up to, but not including, the end position.
*
* This function mutates the original array and replaces its elements with the provided value, starting from the specified
* start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the
* entire array.
*
* @template T, U
* @param array - The array to fill.
* @param value - The value to fill the array with.
* @param [start=0] - The start position. Defaults to 0.
* @param [end=arr.length] - The end position. Defaults to the array's length.
* @returns The array with the filled values.
*
* @example
* fill([1, 2, 3], 'a');
* // => ['a', 'a', 'a']
*
* fill(Array(3), 2);
* // => [2, 2, 2]
*
* fill([4, 6, 8, 10], '*', 1, 3);
* // => [4, '*', '*', 10]
*
* fill([1, 2, 3], '*', -2, -1);
* // => [1, '*', 3]
*/
function fill(array, value, start = 0, end = array ? array.length : 0) {
if (!require_isArrayLike.isArrayLike(array)) return [];
if (require_isString.isString(array)) return array;
start = Math.floor(start);
end = Math.floor(end);
if (!start) start = 0;
if (!end) end = 0;
return require_fill.fill(array, value, start, end);
}
//#endregion
exports.fill = fill;

View file

@ -0,0 +1,42 @@
import { fill as fill$1 } from "../../array/fill.mjs";
import { isArrayLike } from "../predicate/isArrayLike.mjs";
import { isString } from "../predicate/isString.mjs";
//#region src/compat/array/fill.ts
/**
* Fills elements of an array with a specified value from the start position up to, but not including, the end position.
*
* This function mutates the original array and replaces its elements with the provided value, starting from the specified
* start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the
* entire array.
*
* @template T, U
* @param array - The array to fill.
* @param value - The value to fill the array with.
* @param [start=0] - The start position. Defaults to 0.
* @param [end=arr.length] - The end position. Defaults to the array's length.
* @returns The array with the filled values.
*
* @example
* fill([1, 2, 3], 'a');
* // => ['a', 'a', 'a']
*
* fill(Array(3), 2);
* // => [2, 2, 2]
*
* fill([4, 6, 8, 10], '*', 1, 3);
* // => [4, '*', '*', 10]
*
* fill([1, 2, 3], '*', -2, -1);
* // => [1, '*', 3]
*/
function fill(array, value, start = 0, end = array ? array.length : 0) {
if (!isArrayLike(array)) return [];
if (isString(array)) return array;
start = Math.floor(start);
end = Math.floor(end);
if (!start) start = 0;
if (!end) end = 0;
return fill$1(array, value, start, end);
}
//#endregion
export { fill };

View file

@ -0,0 +1,75 @@
import { ObjectIteratorTypeGuard } from "../_internal/ObjectIterator.mjs";
import { StringIterator } from "../_internal/StringIterator.mjs";
import { ListIterateeCustom } from "../_internal/ListIterateeCustom.mjs";
import { ObjectIterateeCustom } from "../_internal/ObjectIteratee.mjs";
import { ListIteratorTypeGuard } from "../_internal/ListIteratorTypeGuard.mjs";
//#region src/compat/array/filter.d.ts
/**
* Filters characters in a string based on the predicate function.
*
* @param collection - The string to filter
* @param predicate - The function to test each character
* @returns An array of characters that pass the predicate test
*
* @example
* filter('123', char => char === '2')
* // => ['2']
*/
declare function filter(collection: string | null | undefined, predicate?: StringIterator<boolean>): string[];
/**
* Filters elements in an array-like object using a type guard predicate.
*
* @param collection - The array-like object to filter
* @param predicate - The type guard function to test each element
* @returns An array of elements that are of type U
*
* @example
* filter([1, '2', 3], (x): x is number => typeof x === 'number')
* // => [1, 3]
*/
declare function filter<T, U extends T>(collection: ArrayLike<T> | null | undefined, predicate: ListIteratorTypeGuard<T, U>): U[];
/**
* Filters elements in an array-like object based on the predicate.
*
* @param collection - The array-like object to filter
* @param predicate - The function or shorthand to test each element
* @returns An array of elements that pass the predicate test
*
* @example
* filter([1, 2, 3], x => x > 1)
* // => [2, 3]
*
* filter([{ a: 1 }, { a: 2 }], { a: 1 })
* // => [{ a: 1 }]
*/
declare function filter<T>(collection: ArrayLike<T> | null | undefined, predicate?: ListIterateeCustom<T, boolean>): T[];
/**
* Filters values in an object using a type guard predicate.
*
* @param collection - The object to filter
* @param predicate - The type guard function to test each value
* @returns An array of values that are of type U
*
* @example
* filter({ a: 1, b: '2', c: 3 }, (x): x is number => typeof x === 'number')
* // => [1, 3]
*/
declare function filter<T extends object, U extends T[keyof T]>(collection: T | null | undefined, predicate: ObjectIteratorTypeGuard<T, U>): U[];
/**
* Filters values in an object based on the predicate.
*
* @param collection - The object to filter
* @param predicate - The function or shorthand to test each value
* @returns An array of values that pass the predicate test
*
* @example
* filter({ a: 1, b: 2 }, x => x > 1)
* // => [2]
*
* filter({ a: { x: 1 }, b: { x: 2 } }, { x: 1 })
* // => [{ x: 1 }]
*/
declare function filter<T extends object>(collection: T | null | undefined, predicate?: ObjectIterateeCustom<T, boolean>): Array<T[keyof T]>;
//#endregion
export { filter };

View file

@ -0,0 +1,75 @@
import { ObjectIteratorTypeGuard } from "../_internal/ObjectIterator.js";
import { StringIterator } from "../_internal/StringIterator.js";
import { ListIterateeCustom } from "../_internal/ListIterateeCustom.js";
import { ObjectIterateeCustom } from "../_internal/ObjectIteratee.js";
import { ListIteratorTypeGuard } from "../_internal/ListIteratorTypeGuard.js";
//#region src/compat/array/filter.d.ts
/**
* Filters characters in a string based on the predicate function.
*
* @param collection - The string to filter
* @param predicate - The function to test each character
* @returns An array of characters that pass the predicate test
*
* @example
* filter('123', char => char === '2')
* // => ['2']
*/
declare function filter(collection: string | null | undefined, predicate?: StringIterator<boolean>): string[];
/**
* Filters elements in an array-like object using a type guard predicate.
*
* @param collection - The array-like object to filter
* @param predicate - The type guard function to test each element
* @returns An array of elements that are of type U
*
* @example
* filter([1, '2', 3], (x): x is number => typeof x === 'number')
* // => [1, 3]
*/
declare function filter<T, U extends T>(collection: ArrayLike<T> | null | undefined, predicate: ListIteratorTypeGuard<T, U>): U[];
/**
* Filters elements in an array-like object based on the predicate.
*
* @param collection - The array-like object to filter
* @param predicate - The function or shorthand to test each element
* @returns An array of elements that pass the predicate test
*
* @example
* filter([1, 2, 3], x => x > 1)
* // => [2, 3]
*
* filter([{ a: 1 }, { a: 2 }], { a: 1 })
* // => [{ a: 1 }]
*/
declare function filter<T>(collection: ArrayLike<T> | null | undefined, predicate?: ListIterateeCustom<T, boolean>): T[];
/**
* Filters values in an object using a type guard predicate.
*
* @param collection - The object to filter
* @param predicate - The type guard function to test each value
* @returns An array of values that are of type U
*
* @example
* filter({ a: 1, b: '2', c: 3 }, (x): x is number => typeof x === 'number')
* // => [1, 3]
*/
declare function filter<T extends object, U extends T[keyof T]>(collection: T | null | undefined, predicate: ObjectIteratorTypeGuard<T, U>): U[];
/**
* Filters values in an object based on the predicate.
*
* @param collection - The object to filter
* @param predicate - The function or shorthand to test each value
* @returns An array of values that pass the predicate test
*
* @example
* filter({ a: 1, b: 2 }, x => x > 1)
* // => [2]
*
* filter({ a: { x: 1 }, b: { x: 2 } }, { x: 1 })
* // => [{ x: 1 }]
*/
declare function filter<T extends object>(collection: T | null | undefined, predicate?: ObjectIterateeCustom<T, boolean>): Array<T[keyof T]>;
//#endregion
export { filter };

View file

@ -0,0 +1,50 @@
const require_identity = require("../../function/identity.js");
const require_isArrayLike = require("../predicate/isArrayLike.js");
const require_iteratee = require("../util/iteratee.js");
//#region src/compat/array/filter.ts
/**
* Iterates over the collection and filters elements based on the given predicate.
* If a function is provided, it is invoked for each element in the collection.
*
* @template T
* @param source - The array or object to iterate over.
* @param [predicate=identity] - The function invoked per iteration.
* @returns Returns a new array of filtered elements that satisfy the predicate.
*
* @example
* filter([{ a: 1 }, { a: 2 }, { b: 1 }], 'a');
* // => [{ a: 1 }, { a: 2 }]
*
* filter([{ a: 1 }, { a: 2 }, { b: 1 }], { b: 1 });
* // => [{ b: 1 }]
*
* filter({ item1: { a: 0, b: true }, item2: { a: 1, b: true }, item3: { a: 2, b: false }}, { b: false })
* // => [{ a: 2, b: false }]
*
* filter([{ a: 1 }, { a: 2 }, { a: 3 }], ['a', 2]);
* // => [{ a: 2 }]
*/
function filter(source, predicate = require_identity.identity) {
if (!source) return [];
predicate = require_iteratee.iteratee(predicate);
if (!Array.isArray(source)) {
const result = [];
const keys = Object.keys(source);
const length = require_isArrayLike.isArrayLike(source) ? source.length : keys.length;
for (let i = 0; i < length; i++) {
const key = keys[i];
const value = source[key];
if (predicate(value, key, source)) result.push(value);
}
return result;
}
const result = [];
const length = source.length;
for (let i = 0; i < length; i++) {
const value = source[i];
if (predicate(value, i, source)) result.push(value);
}
return result;
}
//#endregion
exports.filter = filter;

View file

@ -0,0 +1,50 @@
import { identity } from "../../function/identity.mjs";
import { isArrayLike } from "../predicate/isArrayLike.mjs";
import { iteratee } from "../util/iteratee.mjs";
//#region src/compat/array/filter.ts
/**
* Iterates over the collection and filters elements based on the given predicate.
* If a function is provided, it is invoked for each element in the collection.
*
* @template T
* @param source - The array or object to iterate over.
* @param [predicate=identity] - The function invoked per iteration.
* @returns Returns a new array of filtered elements that satisfy the predicate.
*
* @example
* filter([{ a: 1 }, { a: 2 }, { b: 1 }], 'a');
* // => [{ a: 1 }, { a: 2 }]
*
* filter([{ a: 1 }, { a: 2 }, { b: 1 }], { b: 1 });
* // => [{ b: 1 }]
*
* filter({ item1: { a: 0, b: true }, item2: { a: 1, b: true }, item3: { a: 2, b: false }}, { b: false })
* // => [{ a: 2, b: false }]
*
* filter([{ a: 1 }, { a: 2 }, { a: 3 }], ['a', 2]);
* // => [{ a: 2 }]
*/
function filter(source, predicate = identity) {
if (!source) return [];
predicate = iteratee(predicate);
if (!Array.isArray(source)) {
const result = [];
const keys = Object.keys(source);
const length = isArrayLike(source) ? source.length : keys.length;
for (let i = 0; i < length; i++) {
const key = keys[i];
const value = source[key];
if (predicate(value, key, source)) result.push(value);
}
return result;
}
const result = [];
const length = source.length;
for (let i = 0; i < length; i++) {
const value = source[i];
if (predicate(value, i, source)) result.push(value);
}
return result;
}
//#endregion
export { filter };

View file

@ -0,0 +1,66 @@
import { ObjectIteratorTypeGuard } from "../_internal/ObjectIterator.mjs";
import { ListIterateeCustom } from "../_internal/ListIterateeCustom.mjs";
import { ObjectIterateeCustom } from "../_internal/ObjectIteratee.mjs";
import { ListIteratorTypeGuard } from "../_internal/ListIteratorTypeGuard.mjs";
//#region src/compat/array/find.d.ts
/**
* Finds the first element in an array-like object that matches a type guard predicate.
*
* @param collection - The array-like object to search
* @param predicate - The type guard function to test each element
* @param fromIndex - The index to start searching from
* @returns The first element that matches the type guard, or undefined if none found
*
* @example
* find([1, '2', 3], (x): x is number => typeof x === 'number')
* // => 1
*/
declare function find<T, U extends T>(collection: ArrayLike<T> | null | undefined, predicate: ListIteratorTypeGuard<T, U>, fromIndex?: number): U | undefined;
/**
* Finds the first element in an array-like object that matches a predicate.
*
* @param collection - The array-like object to search
* @param predicate - The function or shorthand to test each element
* @param fromIndex - The index to start searching from
* @returns The first matching element, or undefined if none found
*
* @example
* find([1, 2, 3], x => x > 2)
* // => 3
*
* find([{ a: 1 }, { a: 2 }], { a: 2 })
* // => { a: 2 }
*/
declare function find<T>(collection: ArrayLike<T> | null | undefined, predicate?: ListIterateeCustom<T, boolean>, fromIndex?: number): T | undefined;
/**
* Finds the first value in an object that matches a type guard predicate.
*
* @param collection - The object to search
* @param predicate - The type guard function to test each value
* @param fromIndex - The index to start searching from
* @returns The first value that matches the type guard, or undefined if none found
*
* @example
* find({ a: 1, b: '2', c: 3 }, (x): x is number => typeof x === 'number')
* // => 1
*/
declare function find<T extends object, U extends T[keyof T]>(collection: T | null | undefined, predicate: ObjectIteratorTypeGuard<T, U>, fromIndex?: number): U | undefined;
/**
* Finds the first value in an object that matches a predicate.
*
* @param collection - The object to search
* @param predicate - The function or shorthand to test each value
* @param fromIndex - The index to start searching from
* @returns The first matching value, or undefined if none found
*
* @example
* find({ a: 1, b: 2 }, x => x > 1)
* // => 2
*
* find({ a: { x: 1 }, b: { x: 2 } }, { x: 2 })
* // => { x: 2 }
*/
declare function find<T extends object>(collection: T | null | undefined, predicate?: ObjectIterateeCustom<T, boolean>, fromIndex?: number): T[keyof T] | undefined;
//#endregion
export { find };

View file

@ -0,0 +1,66 @@
import { ObjectIteratorTypeGuard } from "../_internal/ObjectIterator.js";
import { ListIterateeCustom } from "../_internal/ListIterateeCustom.js";
import { ObjectIterateeCustom } from "../_internal/ObjectIteratee.js";
import { ListIteratorTypeGuard } from "../_internal/ListIteratorTypeGuard.js";
//#region src/compat/array/find.d.ts
/**
* Finds the first element in an array-like object that matches a type guard predicate.
*
* @param collection - The array-like object to search
* @param predicate - The type guard function to test each element
* @param fromIndex - The index to start searching from
* @returns The first element that matches the type guard, or undefined if none found
*
* @example
* find([1, '2', 3], (x): x is number => typeof x === 'number')
* // => 1
*/
declare function find<T, U extends T>(collection: ArrayLike<T> | null | undefined, predicate: ListIteratorTypeGuard<T, U>, fromIndex?: number): U | undefined;
/**
* Finds the first element in an array-like object that matches a predicate.
*
* @param collection - The array-like object to search
* @param predicate - The function or shorthand to test each element
* @param fromIndex - The index to start searching from
* @returns The first matching element, or undefined if none found
*
* @example
* find([1, 2, 3], x => x > 2)
* // => 3
*
* find([{ a: 1 }, { a: 2 }], { a: 2 })
* // => { a: 2 }
*/
declare function find<T>(collection: ArrayLike<T> | null | undefined, predicate?: ListIterateeCustom<T, boolean>, fromIndex?: number): T | undefined;
/**
* Finds the first value in an object that matches a type guard predicate.
*
* @param collection - The object to search
* @param predicate - The type guard function to test each value
* @param fromIndex - The index to start searching from
* @returns The first value that matches the type guard, or undefined if none found
*
* @example
* find({ a: 1, b: '2', c: 3 }, (x): x is number => typeof x === 'number')
* // => 1
*/
declare function find<T extends object, U extends T[keyof T]>(collection: T | null | undefined, predicate: ObjectIteratorTypeGuard<T, U>, fromIndex?: number): U | undefined;
/**
* Finds the first value in an object that matches a predicate.
*
* @param collection - The object to search
* @param predicate - The function or shorthand to test each value
* @param fromIndex - The index to start searching from
* @returns The first matching value, or undefined if none found
*
* @example
* find({ a: 1, b: 2 }, x => x > 1)
* // => 2
*
* find({ a: { x: 1 }, b: { x: 2 } }, { x: 2 })
* // => { x: 2 }
*/
declare function find<T extends object>(collection: T | null | undefined, predicate?: ObjectIterateeCustom<T, boolean>, fromIndex?: number): T[keyof T] | undefined;
//#endregion
export { find };

View file

@ -0,0 +1,35 @@
const require_identity = require("../../function/identity.js");
const require_iteratee = require("../util/iteratee.js");
//#region src/compat/array/find.ts
/**
* Finds the first item in an object that has a specific property, where the property name is provided as a PropertyKey.
*
* @template T
* @param source - The source array or object to search through.
* @param doesMatch - The criteria to match. It can be a function, a partial object, a key-value pair, or a property name.
* @param [fromIndex=0] - The index to start the search from, defaults to 0.
* @returns The first property value that has the specified property, or `undefined` if no match is found.
*
* @example
* // Using a property name
* const obj = { a: { id: 1, name: 'Alice' }, b: { id: 2, name: 'Bob' } };
* const result = find(obj, 'name');
* console.log(result); // { id: 1, name: 'Alice' }
*/
function find(source, _doesMatch = require_identity.identity, fromIndex = 0) {
if (!source) return;
if (fromIndex < 0) fromIndex = Math.max(source.length + fromIndex, 0);
const doesMatch = require_iteratee.iteratee(_doesMatch);
if (!Array.isArray(source)) {
const keys = Object.keys(source);
for (let i = fromIndex; i < keys.length; i++) {
const key = keys[i];
const value = source[key];
if (doesMatch(value, key, source)) return value;
}
return;
}
return source.slice(fromIndex).find(doesMatch);
}
//#endregion
exports.find = find;

View file

@ -0,0 +1,35 @@
import { identity } from "../../function/identity.mjs";
import { iteratee } from "../util/iteratee.mjs";
//#region src/compat/array/find.ts
/**
* Finds the first item in an object that has a specific property, where the property name is provided as a PropertyKey.
*
* @template T
* @param source - The source array or object to search through.
* @param doesMatch - The criteria to match. It can be a function, a partial object, a key-value pair, or a property name.
* @param [fromIndex=0] - The index to start the search from, defaults to 0.
* @returns The first property value that has the specified property, or `undefined` if no match is found.
*
* @example
* // Using a property name
* const obj = { a: { id: 1, name: 'Alice' }, b: { id: 2, name: 'Bob' } };
* const result = find(obj, 'name');
* console.log(result); // { id: 1, name: 'Alice' }
*/
function find(source, _doesMatch = identity, fromIndex = 0) {
if (!source) return;
if (fromIndex < 0) fromIndex = Math.max(source.length + fromIndex, 0);
const doesMatch = iteratee(_doesMatch);
if (!Array.isArray(source)) {
const keys = Object.keys(source);
for (let i = fromIndex; i < keys.length; i++) {
const key = keys[i];
const value = source[key];
if (doesMatch(value, key, source)) return value;
}
return;
}
return source.slice(fromIndex).find(doesMatch);
}
//#endregion
export { find };

View file

@ -0,0 +1,22 @@
import { ListIterateeCustom } from "../_internal/ListIterateeCustom.mjs";
//#region src/compat/array/findIndex.d.ts
/**
* Finds the index of the first item in an array that has a specific property, where the property name is provided as a PropertyKey.
*
* @template T
* @param arr - The array to search through.
* @param doesMatch - The criteria to match against the items in the array. This can be a function, a partial object, a key-value pair, or a property name.
* @param propertyToCheck - The property name to check for in the items of the array.
* @param [fromIndex=0] - The index to start the search from, defaults to 0.
* @returns The index of the first item that has the specified property, or `-1` if no match is found.
*
* @example
* // Using a property name
* const items = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];
* const result = findIndex(items, 'name');
* console.log(result); // 0
*/
declare function findIndex<T>(arr: ArrayLike<T> | null | undefined, doesMatch?: ListIterateeCustom<T, boolean>, fromIndex?: number): number;
//#endregion
export { findIndex };

View file

@ -0,0 +1,22 @@
import { ListIterateeCustom } from "../_internal/ListIterateeCustom.js";
//#region src/compat/array/findIndex.d.ts
/**
* Finds the index of the first item in an array that has a specific property, where the property name is provided as a PropertyKey.
*
* @template T
* @param arr - The array to search through.
* @param doesMatch - The criteria to match against the items in the array. This can be a function, a partial object, a key-value pair, or a property name.
* @param propertyToCheck - The property name to check for in the items of the array.
* @param [fromIndex=0] - The index to start the search from, defaults to 0.
* @returns The index of the first item that has the specified property, or `-1` if no match is found.
*
* @example
* // Using a property name
* const items = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];
* const result = findIndex(items, 'name');
* console.log(result); // 0
*/
declare function findIndex<T>(arr: ArrayLike<T> | null | undefined, doesMatch?: ListIterateeCustom<T, boolean>, fromIndex?: number): number;
//#endregion
export { findIndex };

View file

@ -0,0 +1,45 @@
const require_property = require("../object/property.js");
const require_matches = require("../predicate/matches.js");
const require_matchesProperty = require("../predicate/matchesProperty.js");
const require_identity = require("../function/identity.js");
//#region src/compat/array/findIndex.ts
/**
* Finds the index of the first item in an array that has a specific property, where the property name is provided as a PropertyKey.
*
* @template T
* @param arr - The array to search through.
* @param doesMatch - The criteria to match against the items in the array. This can be a function, a partial object, a key-value pair, or a property name.
* @param propertyToCheck - The property name to check for in the items of the array.
* @param [fromIndex=0] - The index to start the search from, defaults to 0.
* @returns The index of the first item that has the specified property, or `-1` if no match is found.
*
* @example
* // Using a property name
* const items = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];
* const result = findIndex(items, 'name');
* console.log(result); // 0
*/
function findIndex(arr, doesMatch = require_identity.identity, fromIndex = 0) {
if (!arr) return -1;
if (fromIndex < 0) fromIndex = Math.max(arr.length + fromIndex, 0);
const subArray = Array.from(arr).slice(fromIndex);
let index = -1;
switch (typeof doesMatch) {
case "function":
index = subArray.findIndex(doesMatch);
break;
case "object":
if (Array.isArray(doesMatch) && doesMatch.length === 2) {
const key = doesMatch[0];
const value = doesMatch[1];
index = subArray.findIndex(require_matchesProperty.matchesProperty(key, value));
} else index = subArray.findIndex(require_matches.matches(doesMatch));
break;
case "number":
case "symbol":
case "string": index = subArray.findIndex(require_property.property(doesMatch));
}
return index === -1 ? -1 : index + fromIndex;
}
//#endregion
exports.findIndex = findIndex;

View file

@ -0,0 +1,45 @@
import { property } from "../object/property.mjs";
import { matches } from "../predicate/matches.mjs";
import { matchesProperty } from "../predicate/matchesProperty.mjs";
import { identity } from "../function/identity.mjs";
//#region src/compat/array/findIndex.ts
/**
* Finds the index of the first item in an array that has a specific property, where the property name is provided as a PropertyKey.
*
* @template T
* @param arr - The array to search through.
* @param doesMatch - The criteria to match against the items in the array. This can be a function, a partial object, a key-value pair, or a property name.
* @param propertyToCheck - The property name to check for in the items of the array.
* @param [fromIndex=0] - The index to start the search from, defaults to 0.
* @returns The index of the first item that has the specified property, or `-1` if no match is found.
*
* @example
* // Using a property name
* const items = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];
* const result = findIndex(items, 'name');
* console.log(result); // 0
*/
function findIndex(arr, doesMatch = identity, fromIndex = 0) {
if (!arr) return -1;
if (fromIndex < 0) fromIndex = Math.max(arr.length + fromIndex, 0);
const subArray = Array.from(arr).slice(fromIndex);
let index = -1;
switch (typeof doesMatch) {
case "function":
index = subArray.findIndex(doesMatch);
break;
case "object":
if (Array.isArray(doesMatch) && doesMatch.length === 2) {
const key = doesMatch[0];
const value = doesMatch[1];
index = subArray.findIndex(matchesProperty(key, value));
} else index = subArray.findIndex(matches(doesMatch));
break;
case "number":
case "symbol":
case "string": index = subArray.findIndex(property(doesMatch));
}
return index === -1 ? -1 : index + fromIndex;
}
//#endregion
export { findIndex };

View file

@ -0,0 +1,83 @@
import { ObjectIteratorTypeGuard } from "../_internal/ObjectIterator.mjs";
import { ListIterateeCustom } from "../_internal/ListIterateeCustom.mjs";
import { ObjectIterateeCustom } from "../_internal/ObjectIteratee.mjs";
import { ListIteratorTypeGuard } from "../_internal/ListIteratorTypeGuard.mjs";
//#region src/compat/array/findLast.d.ts
/**
* Finds the last element in a collection that satisfies the predicate.
*
* @template T, S
* @param collection - The collection to search.
* @param predicate - The predicate function with type guard.
* @param [fromIndex] - The index to start searching from.
* @returns The last element that satisfies the predicate.
*
* @example
* const users = [{ user: 'barney', age: 36 }, { user: 'fred', age: 40 }, { user: 'pebbles', age: 18 }];
* findLast(users, (o): o is { user: string; age: number } => o.age < 40);
* // => { user: 'pebbles', age: 18 }
*/
declare function findLast<T, S extends T>(collection: ArrayLike<T> | null | undefined, predicate: ListIteratorTypeGuard<T, S>, fromIndex?: number): S | undefined;
/**
* Finds the last element in a collection that satisfies the predicate.
*
* @template T
* @param collection - The collection to search.
* @param [predicate] - The predicate function, partial object, property-value pair, or property name.
* @param [fromIndex] - The index to start searching from.
* @returns The last element that satisfies the predicate.
*
* @example
* const users = [{ user: 'barney', age: 36 }, { user: 'fred', age: 40 }, { user: 'pebbles', age: 18 }];
* findLast(users, o => o.age < 40);
* // => { user: 'pebbles', age: 18 }
*
* findLast(users, { age: 36 });
* // => { user: 'barney', age: 36 }
*
* findLast(users, ['age', 18]);
* // => { user: 'pebbles', age: 18 }
*
* findLast(users, 'age');
* // => { user: 'fred', age: 40 }
*/
declare function findLast<T>(collection: ArrayLike<T> | null | undefined, predicate?: ListIterateeCustom<T, boolean>, fromIndex?: number): T | undefined;
/**
* Finds the last element in an object that satisfies the predicate with type guard.
*
* @template T, S
* @param collection - The object to search.
* @param predicate - The predicate function with type guard.
* @param [fromIndex] - The index to start searching from.
* @returns The last element that satisfies the predicate.
*
* @example
* const obj = { a: 1, b: 'hello', c: 3 };
* findLast(obj, (value): value is string => typeof value === 'string');
* // => 'hello'
*/
declare function findLast<T extends object, S extends T[keyof T]>(collection: T | null | undefined, predicate: ObjectIteratorTypeGuard<T, S>, fromIndex?: number): S | undefined;
/**
* Finds the last element in an object that satisfies the predicate.
*
* @template T
* @param collection - The object to search.
* @param [predicate] - The predicate function, partial object, property-value pair, or property name.
* @param [fromIndex] - The index to start searching from.
* @returns The last element that satisfies the predicate.
*
* @example
* const obj = { a: { id: 1, name: 'Alice' }, b: { id: 2 }, c: { id: 3, name: 'Bob' } };
* findLast(obj, o => o.id > 1);
* // => { id: 3, name: 'Bob' }
*
* findLast(obj, { name: 'Bob' });
* // => { id: 3, name: 'Bob' }
*
* findLast(obj, 'name');
* // => { id: 3, name: 'Bob' }
*/
declare function findLast<T extends object>(collection: T | null | undefined, predicate?: ObjectIterateeCustom<T, boolean>, fromIndex?: number): T[keyof T] | undefined;
//#endregion
export { findLast };

View file

@ -0,0 +1,83 @@
import { ObjectIteratorTypeGuard } from "../_internal/ObjectIterator.js";
import { ListIterateeCustom } from "../_internal/ListIterateeCustom.js";
import { ObjectIterateeCustom } from "../_internal/ObjectIteratee.js";
import { ListIteratorTypeGuard } from "../_internal/ListIteratorTypeGuard.js";
//#region src/compat/array/findLast.d.ts
/**
* Finds the last element in a collection that satisfies the predicate.
*
* @template T, S
* @param collection - The collection to search.
* @param predicate - The predicate function with type guard.
* @param [fromIndex] - The index to start searching from.
* @returns The last element that satisfies the predicate.
*
* @example
* const users = [{ user: 'barney', age: 36 }, { user: 'fred', age: 40 }, { user: 'pebbles', age: 18 }];
* findLast(users, (o): o is { user: string; age: number } => o.age < 40);
* // => { user: 'pebbles', age: 18 }
*/
declare function findLast<T, S extends T>(collection: ArrayLike<T> | null | undefined, predicate: ListIteratorTypeGuard<T, S>, fromIndex?: number): S | undefined;
/**
* Finds the last element in a collection that satisfies the predicate.
*
* @template T
* @param collection - The collection to search.
* @param [predicate] - The predicate function, partial object, property-value pair, or property name.
* @param [fromIndex] - The index to start searching from.
* @returns The last element that satisfies the predicate.
*
* @example
* const users = [{ user: 'barney', age: 36 }, { user: 'fred', age: 40 }, { user: 'pebbles', age: 18 }];
* findLast(users, o => o.age < 40);
* // => { user: 'pebbles', age: 18 }
*
* findLast(users, { age: 36 });
* // => { user: 'barney', age: 36 }
*
* findLast(users, ['age', 18]);
* // => { user: 'pebbles', age: 18 }
*
* findLast(users, 'age');
* // => { user: 'fred', age: 40 }
*/
declare function findLast<T>(collection: ArrayLike<T> | null | undefined, predicate?: ListIterateeCustom<T, boolean>, fromIndex?: number): T | undefined;
/**
* Finds the last element in an object that satisfies the predicate with type guard.
*
* @template T, S
* @param collection - The object to search.
* @param predicate - The predicate function with type guard.
* @param [fromIndex] - The index to start searching from.
* @returns The last element that satisfies the predicate.
*
* @example
* const obj = { a: 1, b: 'hello', c: 3 };
* findLast(obj, (value): value is string => typeof value === 'string');
* // => 'hello'
*/
declare function findLast<T extends object, S extends T[keyof T]>(collection: T | null | undefined, predicate: ObjectIteratorTypeGuard<T, S>, fromIndex?: number): S | undefined;
/**
* Finds the last element in an object that satisfies the predicate.
*
* @template T
* @param collection - The object to search.
* @param [predicate] - The predicate function, partial object, property-value pair, or property name.
* @param [fromIndex] - The index to start searching from.
* @returns The last element that satisfies the predicate.
*
* @example
* const obj = { a: { id: 1, name: 'Alice' }, b: { id: 2 }, c: { id: 3, name: 'Bob' } };
* findLast(obj, o => o.id > 1);
* // => { id: 3, name: 'Bob' }
*
* findLast(obj, { name: 'Bob' });
* // => { id: 3, name: 'Bob' }
*
* findLast(obj, 'name');
* // => { id: 3, name: 'Bob' }
*/
declare function findLast<T extends object>(collection: T | null | undefined, predicate?: ObjectIterateeCustom<T, boolean>, fromIndex?: number): T[keyof T] | undefined;
//#endregion
export { findLast };

View file

@ -0,0 +1,39 @@
const require_identity = require("../../function/identity.js");
const require_iteratee = require("../util/iteratee.js");
const require_toInteger = require("../util/toInteger.js");
//#region src/compat/array/findLast.ts
/**
* Finds the last item in an object that has a specific property, where the property name is provided as a PropertyKey.
*
* @template T
* @param source - The source array or object to search through.
* @param doesMatch - The criteria to match. It can be a function, a partial object, a key-value pair, or a property name.
* @param [fromIndex] - The index to start the search from, defaults to source.length-1 for arrays or Object.keys(source).length-1 for objects.
* @returns The last property value that has the specified property, or `undefined` if no match is found.
*
* @example
* // Using a property name
* const obj = { a: { id: 1, name: 'Alice' }, b: { id: 2 }, c: { id: 3, name: 'Bob' } };
* const result = findLast(obj, 'name');
* console.log(result); // { id: 3, name: 'Bob' }
*/
function findLast(source, _doesMatch = require_identity.identity, fromIndex) {
if (!source) return;
const length = Array.isArray(source) ? source.length : Object.keys(source).length;
fromIndex = require_toInteger.toInteger(fromIndex ?? length - 1);
if (fromIndex < 0) fromIndex = Math.max(length + fromIndex, 0);
else fromIndex = Math.min(fromIndex, length - 1);
const doesMatch = require_iteratee.iteratee(_doesMatch);
if (!Array.isArray(source)) {
const keys = Object.keys(source);
for (let i = fromIndex; i >= 0; i--) {
const key = keys[i];
const value = source[key];
if (doesMatch(value, key, source)) return value;
}
return;
}
return source.slice(0, fromIndex + 1).findLast(doesMatch);
}
//#endregion
exports.findLast = findLast;

View file

@ -0,0 +1,39 @@
import { identity } from "../../function/identity.mjs";
import { iteratee } from "../util/iteratee.mjs";
import { toInteger } from "../util/toInteger.mjs";
//#region src/compat/array/findLast.ts
/**
* Finds the last item in an object that has a specific property, where the property name is provided as a PropertyKey.
*
* @template T
* @param source - The source array or object to search through.
* @param doesMatch - The criteria to match. It can be a function, a partial object, a key-value pair, or a property name.
* @param [fromIndex] - The index to start the search from, defaults to source.length-1 for arrays or Object.keys(source).length-1 for objects.
* @returns The last property value that has the specified property, or `undefined` if no match is found.
*
* @example
* // Using a property name
* const obj = { a: { id: 1, name: 'Alice' }, b: { id: 2 }, c: { id: 3, name: 'Bob' } };
* const result = findLast(obj, 'name');
* console.log(result); // { id: 3, name: 'Bob' }
*/
function findLast(source, _doesMatch = identity, fromIndex) {
if (!source) return;
const length = Array.isArray(source) ? source.length : Object.keys(source).length;
fromIndex = toInteger(fromIndex ?? length - 1);
if (fromIndex < 0) fromIndex = Math.max(length + fromIndex, 0);
else fromIndex = Math.min(fromIndex, length - 1);
const doesMatch = iteratee(_doesMatch);
if (!Array.isArray(source)) {
const keys = Object.keys(source);
for (let i = fromIndex; i >= 0; i--) {
const key = keys[i];
const value = source[key];
if (doesMatch(value, key, source)) return value;
}
return;
}
return source.slice(0, fromIndex + 1).findLast(doesMatch);
}
//#endregion
export { findLast };

View file

@ -0,0 +1,34 @@
import { ListIterateeCustom } from "../_internal/ListIterateeCustom.mjs";
//#region src/compat/array/findLastIndex.d.ts
/**
* Finds the index of the last element in the array that satisfies the predicate.
*
* @template T
* @param array - The array to search through.
* @param [predicate] - The predicate function, partial object, property-value pair, or property name.
* @param [fromIndex] - The index to start searching from.
* @returns The index of the last matching element, or -1 if not found.
*
* @example
* const users = [
* { user: 'barney', active: true },
* { user: 'fred', active: false },
* { user: 'pebbles', active: false }
* ];
*
* findLastIndex(users, o => o.user === 'pebbles');
* // => 2
*
* findLastIndex(users, { user: 'barney', active: true });
* // => 0
*
* findLastIndex(users, ['active', false]);
* // => 2
*
* findLastIndex(users, 'active');
* // => 0
*/
declare function findLastIndex<T>(array: ArrayLike<T> | null | undefined, predicate?: ListIterateeCustom<T, boolean>, fromIndex?: number): number;
//#endregion
export { findLastIndex };

View file

@ -0,0 +1,34 @@
import { ListIterateeCustom } from "../_internal/ListIterateeCustom.js";
//#region src/compat/array/findLastIndex.d.ts
/**
* Finds the index of the last element in the array that satisfies the predicate.
*
* @template T
* @param array - The array to search through.
* @param [predicate] - The predicate function, partial object, property-value pair, or property name.
* @param [fromIndex] - The index to start searching from.
* @returns The index of the last matching element, or -1 if not found.
*
* @example
* const users = [
* { user: 'barney', active: true },
* { user: 'fred', active: false },
* { user: 'pebbles', active: false }
* ];
*
* findLastIndex(users, o => o.user === 'pebbles');
* // => 2
*
* findLastIndex(users, { user: 'barney', active: true });
* // => 0
*
* findLastIndex(users, ['active', false]);
* // => 2
*
* findLastIndex(users, 'active');
* // => 0
*/
declare function findLastIndex<T>(array: ArrayLike<T> | null | undefined, predicate?: ListIterateeCustom<T, boolean>, fromIndex?: number): number;
//#endregion
export { findLastIndex };

View file

@ -0,0 +1,39 @@
const require_identity = require("../../function/identity.js");
const require_toArray = require("../_internal/toArray.js");
const require_property = require("../object/property.js");
const require_matches = require("../predicate/matches.js");
const require_matchesProperty = require("../predicate/matchesProperty.js");
//#region src/compat/array/findLastIndex.ts
/**
* Finds the index of the last element in the array that satisfies the predicate.
*
* @template T
* @param arr - The array to search through.
* @param doesMatch - The predicate function, partial object, property-value pair, or property name.
* @param [fromIndex=arr.length - 1] - The index to start the search from, defaults to the last index of the array.
* @returns The index of the last matching element, or -1 if not found.
*
* @example
* const items = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];
* findLastIndex(items, 'name');
* // => 1
*/
function findLastIndex(arr, doesMatch = require_identity.identity, fromIndex = arr ? arr.length - 1 : 0) {
if (!arr) return -1;
if (fromIndex < 0) fromIndex = Math.max(arr.length + fromIndex, 0);
else fromIndex = Math.min(fromIndex, arr.length - 1);
const subArray = require_toArray.toArray(arr).slice(0, fromIndex + 1);
switch (typeof doesMatch) {
case "function": return subArray.findLastIndex(doesMatch);
case "object": if (Array.isArray(doesMatch) && doesMatch.length === 2) {
const key = doesMatch[0];
const value = doesMatch[1];
return subArray.findLastIndex(require_matchesProperty.matchesProperty(key, value));
} else return subArray.findLastIndex(require_matches.matches(doesMatch));
case "number":
case "symbol":
case "string": return subArray.findLastIndex(require_property.property(doesMatch));
}
}
//#endregion
exports.findLastIndex = findLastIndex;

View file

@ -0,0 +1,39 @@
import { identity } from "../../function/identity.mjs";
import { toArray } from "../_internal/toArray.mjs";
import { property } from "../object/property.mjs";
import { matches } from "../predicate/matches.mjs";
import { matchesProperty } from "../predicate/matchesProperty.mjs";
//#region src/compat/array/findLastIndex.ts
/**
* Finds the index of the last element in the array that satisfies the predicate.
*
* @template T
* @param arr - The array to search through.
* @param doesMatch - The predicate function, partial object, property-value pair, or property name.
* @param [fromIndex=arr.length - 1] - The index to start the search from, defaults to the last index of the array.
* @returns The index of the last matching element, or -1 if not found.
*
* @example
* const items = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];
* findLastIndex(items, 'name');
* // => 1
*/
function findLastIndex(arr, doesMatch = identity, fromIndex = arr ? arr.length - 1 : 0) {
if (!arr) return -1;
if (fromIndex < 0) fromIndex = Math.max(arr.length + fromIndex, 0);
else fromIndex = Math.min(fromIndex, arr.length - 1);
const subArray = toArray(arr).slice(0, fromIndex + 1);
switch (typeof doesMatch) {
case "function": return subArray.findLastIndex(doesMatch);
case "object": if (Array.isArray(doesMatch) && doesMatch.length === 2) {
const key = doesMatch[0];
const value = doesMatch[1];
return subArray.findLastIndex(matchesProperty(key, value));
} else return subArray.findLastIndex(matches(doesMatch));
case "number":
case "symbol":
case "string": return subArray.findLastIndex(property(doesMatch));
}
}
//#endregion
export { findLastIndex };

View file

@ -0,0 +1 @@
import { head } from "./head.mjs";

View file

@ -0,0 +1 @@
import { head } from "./head.js";

View file

@ -0,0 +1 @@
require("./head.js");

View file

@ -0,0 +1 @@
import "./head.mjs";

View file

@ -0,0 +1,94 @@
import { ListIterator } from "../_internal/ListIterator.mjs";
import { ObjectIterator } from "../_internal/ObjectIterator.mjs";
import { Many } from "../_internal/Many.mjs";
//#region src/compat/array/flatMap.d.ts
/**
* Creates a flattened array of values by running each element in collection through iteratee and flattening the mapped results.
*
* @template T
* @param collection - The collection to iterate over.
* @returns Returns the new flattened array.
*
* @example
* const obj = { a: [1, 2], b: [3, 4] };
* flatMap(obj);
* // => [1, 2, 3, 4]
*/
declare function flatMap<T>(collection: Record<string, Many<T>> | Record<number, Many<T>> | null | undefined): T[];
/**
* Creates a flattened array of values by running each element in collection through iteratee and flattening the mapped results.
*
* @param collection - The collection to iterate over.
* @returns Returns the new flattened array.
*
* @example
* flatMap({ a: 1, b: 2 });
* // => [1, 2]
*/
declare function flatMap(collection: object | null | undefined): any[];
/**
* Creates a flattened array of values by running each element in collection through iteratee and flattening the mapped results.
*
* @template T, R
* @param collection - The collection to iterate over.
* @param iteratee - The function invoked per iteration.
* @returns Returns the new flattened array.
*
* @example
* function duplicate(n) {
* return [n, n];
* }
*
* flatMap([1, 2], duplicate);
* // => [1, 1, 2, 2]
*/
declare function flatMap<T, R>(collection: ArrayLike<T> | null | undefined, iteratee: ListIterator<T, Many<R>>): R[];
/**
* Creates a flattened array of values by running each element in collection through iteratee and flattening the mapped results.
*
* @template T, R
* @param collection - The object to iterate over.
* @param iteratee - The function invoked per iteration.
* @returns Returns the new flattened array.
*
* @example
* const obj = { a: 1, b: 2 };
* flatMap(obj, (value, key) => [key, value]);
* // => ['a', 1, 'b', 2]
*/
declare function flatMap<T extends object, R>(collection: T | null | undefined, iteratee: ObjectIterator<T, Many<R>>): R[];
/**
* Creates a flattened array of values by running each element in collection through iteratee and flattening the mapped results.
*
* @param collection - The collection to iterate over.
* @param iteratee - The property name to use as iteratee.
* @returns Returns the new flattened array.
*
* @example
* const users = [
* { user: 'barney', hobbies: ['hiking', 'coding'] },
* { user: 'fred', hobbies: ['reading'] }
* ];
* flatMap(users, 'hobbies');
* // => ['hiking', 'coding', 'reading']
*/
declare function flatMap(collection: object | null | undefined, iteratee: string): any[];
/**
* Creates a flattened array of values by running each element in collection through iteratee and flattening the mapped results.
*
* @param collection - The collection to iterate over.
* @param iteratee - The object properties to match.
* @returns Returns the new flattened array.
*
* @example
* const users = [
* { user: 'barney', age: 36, active: true },
* { user: 'fred', age: 40, active: false }
* ];
* flatMap(users, { active: false });
* // => [false]
*/
declare function flatMap(collection: object | null | undefined, iteratee: object): boolean[];
//#endregion
export { flatMap };

View file

@ -0,0 +1,94 @@
import { ListIterator } from "../_internal/ListIterator.js";
import { ObjectIterator } from "../_internal/ObjectIterator.js";
import { Many } from "../_internal/Many.js";
//#region src/compat/array/flatMap.d.ts
/**
* Creates a flattened array of values by running each element in collection through iteratee and flattening the mapped results.
*
* @template T
* @param collection - The collection to iterate over.
* @returns Returns the new flattened array.
*
* @example
* const obj = { a: [1, 2], b: [3, 4] };
* flatMap(obj);
* // => [1, 2, 3, 4]
*/
declare function flatMap<T>(collection: Record<string, Many<T>> | Record<number, Many<T>> | null | undefined): T[];
/**
* Creates a flattened array of values by running each element in collection through iteratee and flattening the mapped results.
*
* @param collection - The collection to iterate over.
* @returns Returns the new flattened array.
*
* @example
* flatMap({ a: 1, b: 2 });
* // => [1, 2]
*/
declare function flatMap(collection: object | null | undefined): any[];
/**
* Creates a flattened array of values by running each element in collection through iteratee and flattening the mapped results.
*
* @template T, R
* @param collection - The collection to iterate over.
* @param iteratee - The function invoked per iteration.
* @returns Returns the new flattened array.
*
* @example
* function duplicate(n) {
* return [n, n];
* }
*
* flatMap([1, 2], duplicate);
* // => [1, 1, 2, 2]
*/
declare function flatMap<T, R>(collection: ArrayLike<T> | null | undefined, iteratee: ListIterator<T, Many<R>>): R[];
/**
* Creates a flattened array of values by running each element in collection through iteratee and flattening the mapped results.
*
* @template T, R
* @param collection - The object to iterate over.
* @param iteratee - The function invoked per iteration.
* @returns Returns the new flattened array.
*
* @example
* const obj = { a: 1, b: 2 };
* flatMap(obj, (value, key) => [key, value]);
* // => ['a', 1, 'b', 2]
*/
declare function flatMap<T extends object, R>(collection: T | null | undefined, iteratee: ObjectIterator<T, Many<R>>): R[];
/**
* Creates a flattened array of values by running each element in collection through iteratee and flattening the mapped results.
*
* @param collection - The collection to iterate over.
* @param iteratee - The property name to use as iteratee.
* @returns Returns the new flattened array.
*
* @example
* const users = [
* { user: 'barney', hobbies: ['hiking', 'coding'] },
* { user: 'fred', hobbies: ['reading'] }
* ];
* flatMap(users, 'hobbies');
* // => ['hiking', 'coding', 'reading']
*/
declare function flatMap(collection: object | null | undefined, iteratee: string): any[];
/**
* Creates a flattened array of values by running each element in collection through iteratee and flattening the mapped results.
*
* @param collection - The collection to iterate over.
* @param iteratee - The object properties to match.
* @returns Returns the new flattened array.
*
* @example
* const users = [
* { user: 'barney', age: 36, active: true },
* { user: 'fred', age: 40, active: false }
* ];
* flatMap(users, { active: false });
* // => [false]
*/
declare function flatMap(collection: object | null | undefined, iteratee: object): boolean[];
//#endregion
export { flatMap };

View file

@ -0,0 +1,23 @@
const require_isNil = require("../../predicate/isNil.js");
const require_flattenDepth = require("./flattenDepth.js");
const require_map = require("./map.js");
//#region src/compat/array/flatMap.ts
/**
* Creates a flattened array of values by running each element in collection through iteratee and flattening the mapped results.
*
* @template R
* @param collection - The collection to iterate over.
* @param [iteratee] - The function invoked per iteration.
* @returns Returns the new flattened array.
*
* @example
* flatMap([1, 2], n => [n, n * 2]);
* // => [1, 2, 2, 4]
*/
function flatMap(collection, iteratee) {
if (require_isNil.isNil(collection)) return [];
const mapped = require_isNil.isNil(iteratee) ? require_map.map(collection) : require_map.map(collection, iteratee);
return require_flattenDepth.flattenDepth(mapped, 1);
}
//#endregion
exports.flatMap = flatMap;

View file

@ -0,0 +1,22 @@
import { isNil } from "../../predicate/isNil.mjs";
import { flattenDepth } from "./flattenDepth.mjs";
import { map } from "./map.mjs";
//#region src/compat/array/flatMap.ts
/**
* Creates a flattened array of values by running each element in collection through iteratee and flattening the mapped results.
*
* @template R
* @param collection - The collection to iterate over.
* @param [iteratee] - The function invoked per iteration.
* @returns Returns the new flattened array.
*
* @example
* flatMap([1, 2], n => [n, n * 2]);
* // => [1, 2, 2, 4]
*/
function flatMap(collection, iteratee) {
if (isNil(collection)) return [];
return flattenDepth(isNil(iteratee) ? map(collection) : map(collection, iteratee), 1);
}
//#endregion
export { flatMap };

View file

@ -0,0 +1,83 @@
import { ListIterator } from "../_internal/ListIterator.mjs";
import { ObjectIterator } from "../_internal/ObjectIterator.mjs";
import { ListOfRecursiveArraysOrValues } from "../_internal/ListOfRecursiveArraysOrValues.mjs";
//#region src/compat/array/flatMapDeep.d.ts
/**
* Creates a flattened array of values by running each element through iteratee and recursively flattening the mapped results.
*
* @template T
* @param collection - The collection to iterate over.
* @returns Returns the new deeply flattened array.
*
* @example
* const obj = { a: [[1, 2]], b: [[[3]]] };
* flatMapDeep(obj);
* // => [1, 2, 3]
*/
declare function flatMapDeep<T>(collection: Record<string, ListOfRecursiveArraysOrValues<T> | T> | Record<number, ListOfRecursiveArraysOrValues<T> | T> | null | undefined): T[];
/**
* Creates a flattened array of values by running each element through iteratee and recursively flattening the mapped results.
*
* @template T, R
* @param collection - The collection to iterate over.
* @param iteratee - The function invoked per iteration.
* @returns Returns the new deeply flattened array.
*
* @example
* function duplicate(n) {
* return [[[n, n]]];
* }
*
* flatMapDeep([1, 2], duplicate);
* // => [1, 1, 2, 2]
*/
declare function flatMapDeep<T, R>(collection: ArrayLike<T> | null | undefined, iteratee: ListIterator<T, ListOfRecursiveArraysOrValues<R> | R>): R[];
/**
* Creates a flattened array of values by running each element through iteratee and recursively flattening the mapped results.
*
* @template T, R
* @param collection - The object to iterate over.
* @param iteratee - The function invoked per iteration.
* @returns Returns the new deeply flattened array.
*
* @example
* const obj = { a: 1, b: 2 };
* flatMapDeep(obj, (value, key) => [[[key, value]]]);
* // => ['a', 1, 'b', 2]
*/
declare function flatMapDeep<T extends object, R>(collection: T | null | undefined, iteratee: ObjectIterator<T, ListOfRecursiveArraysOrValues<R> | R>): R[];
/**
* Creates a flattened array of values by running each element through iteratee and recursively flattening the mapped results.
*
* @param collection - The collection to iterate over.
* @param iteratee - The property name to use as iteratee.
* @returns Returns the new deeply flattened array.
*
* @example
* const users = [
* { user: 'barney', hobbies: [['hiking', 'coding']] },
* { user: 'fred', hobbies: [['reading']] }
* ];
* flatMapDeep(users, 'hobbies');
* // => ['hiking', 'coding', 'reading']
*/
declare function flatMapDeep(collection: object | null | undefined, iteratee: string): any[];
/**
* Creates a flattened array of values by running each element through iteratee and recursively flattening the mapped results.
*
* @param collection - The collection to iterate over.
* @param iteratee - The object properties to match.
* @returns Returns the new deeply flattened array.
*
* @example
* const users = [
* { user: 'barney', active: [true, false] },
* { user: 'fred', active: [false] }
* ];
* flatMapDeep(users, { active: [false] });
* // => [false]
*/
declare function flatMapDeep(collection: object | null | undefined, iteratee: object): boolean[];
//#endregion
export { flatMapDeep };

View file

@ -0,0 +1,83 @@
import { ListIterator } from "../_internal/ListIterator.js";
import { ObjectIterator } from "../_internal/ObjectIterator.js";
import { ListOfRecursiveArraysOrValues } from "../_internal/ListOfRecursiveArraysOrValues.js";
//#region src/compat/array/flatMapDeep.d.ts
/**
* Creates a flattened array of values by running each element through iteratee and recursively flattening the mapped results.
*
* @template T
* @param collection - The collection to iterate over.
* @returns Returns the new deeply flattened array.
*
* @example
* const obj = { a: [[1, 2]], b: [[[3]]] };
* flatMapDeep(obj);
* // => [1, 2, 3]
*/
declare function flatMapDeep<T>(collection: Record<string, ListOfRecursiveArraysOrValues<T> | T> | Record<number, ListOfRecursiveArraysOrValues<T> | T> | null | undefined): T[];
/**
* Creates a flattened array of values by running each element through iteratee and recursively flattening the mapped results.
*
* @template T, R
* @param collection - The collection to iterate over.
* @param iteratee - The function invoked per iteration.
* @returns Returns the new deeply flattened array.
*
* @example
* function duplicate(n) {
* return [[[n, n]]];
* }
*
* flatMapDeep([1, 2], duplicate);
* // => [1, 1, 2, 2]
*/
declare function flatMapDeep<T, R>(collection: ArrayLike<T> | null | undefined, iteratee: ListIterator<T, ListOfRecursiveArraysOrValues<R> | R>): R[];
/**
* Creates a flattened array of values by running each element through iteratee and recursively flattening the mapped results.
*
* @template T, R
* @param collection - The object to iterate over.
* @param iteratee - The function invoked per iteration.
* @returns Returns the new deeply flattened array.
*
* @example
* const obj = { a: 1, b: 2 };
* flatMapDeep(obj, (value, key) => [[[key, value]]]);
* // => ['a', 1, 'b', 2]
*/
declare function flatMapDeep<T extends object, R>(collection: T | null | undefined, iteratee: ObjectIterator<T, ListOfRecursiveArraysOrValues<R> | R>): R[];
/**
* Creates a flattened array of values by running each element through iteratee and recursively flattening the mapped results.
*
* @param collection - The collection to iterate over.
* @param iteratee - The property name to use as iteratee.
* @returns Returns the new deeply flattened array.
*
* @example
* const users = [
* { user: 'barney', hobbies: [['hiking', 'coding']] },
* { user: 'fred', hobbies: [['reading']] }
* ];
* flatMapDeep(users, 'hobbies');
* // => ['hiking', 'coding', 'reading']
*/
declare function flatMapDeep(collection: object | null | undefined, iteratee: string): any[];
/**
* Creates a flattened array of values by running each element through iteratee and recursively flattening the mapped results.
*
* @param collection - The collection to iterate over.
* @param iteratee - The object properties to match.
* @returns Returns the new deeply flattened array.
*
* @example
* const users = [
* { user: 'barney', active: [true, false] },
* { user: 'fred', active: [false] }
* ];
* flatMapDeep(users, { active: [false] });
* // => [false]
*/
declare function flatMapDeep(collection: object | null | undefined, iteratee: object): boolean[];
//#endregion
export { flatMapDeep };

View file

@ -0,0 +1,19 @@
const require_flatMapDepth = require("./flatMapDepth.js");
//#region src/compat/array/flatMapDeep.ts
/**
* Creates a flattened array of values by running each element through iteratee and recursively flattening the mapped results.
*
* @template T, R
* @param collection - The array or object to iterate over.
* @param [iteratee] - The function that produces the new array elements.
* @returns A new array that has been deeply flattened.
*
* @example
* flatMapDeep([1, 2, 3], n => [[n, n]]);
* // => [1, 1, 2, 2, 3, 3]
*/
function flatMapDeep(collection, iteratee) {
return require_flatMapDepth.flatMapDepth(collection, iteratee, Infinity);
}
//#endregion
exports.flatMapDeep = flatMapDeep;

View file

@ -0,0 +1,19 @@
import { flatMapDepth } from "./flatMapDepth.mjs";
//#region src/compat/array/flatMapDeep.ts
/**
* Creates a flattened array of values by running each element through iteratee and recursively flattening the mapped results.
*
* @template T, R
* @param collection - The array or object to iterate over.
* @param [iteratee] - The function that produces the new array elements.
* @returns A new array that has been deeply flattened.
*
* @example
* flatMapDeep([1, 2, 3], n => [[n, n]]);
* // => [1, 1, 2, 2, 3, 3]
*/
function flatMapDeep(collection, iteratee) {
return flatMapDepth(collection, iteratee, Infinity);
}
//#endregion
export { flatMapDeep };

View file

@ -0,0 +1,87 @@
import { ListIterator } from "../_internal/ListIterator.mjs";
import { ObjectIterator } from "../_internal/ObjectIterator.mjs";
import { ListOfRecursiveArraysOrValues } from "../_internal/ListOfRecursiveArraysOrValues.mjs";
//#region src/compat/array/flatMapDepth.d.ts
/**
* Creates a flattened array of values by running each element through iteratee and flattening the mapped results up to depth times.
*
* @template T
* @param collection - The collection to iterate over.
* @returns Returns the new flattened array.
*
* @example
* const obj = { a: [[1, 2]], b: [[[3]]] };
* flatMapDepth(obj);
* // => [1, 2, [3]]
*/
declare function flatMapDepth<T>(collection: Record<string, ListOfRecursiveArraysOrValues<T> | T> | Record<number, ListOfRecursiveArraysOrValues<T> | T> | null | undefined): T[];
/**
* Creates a flattened array of values by running each element through iteratee and flattening the mapped results up to depth times.
*
* @template T, R
* @param collection - The collection to iterate over.
* @param iteratee - The function invoked per iteration.
* @param [depth=1] - The maximum recursion depth.
* @returns Returns the new flattened array.
*
* @example
* function duplicate(n) {
* return [[n, n]];
* }
*
* flatMapDepth([1, 2], duplicate, 2);
* // => [1, 1, 2, 2]
*/
declare function flatMapDepth<T, R>(collection: ArrayLike<T> | null | undefined, iteratee: ListIterator<T, ListOfRecursiveArraysOrValues<R> | R>, depth?: number): R[];
/**
* Creates a flattened array of values by running each element through iteratee and flattening the mapped results up to depth times.
*
* @template T, R
* @param collection - The object to iterate over.
* @param iteratee - The function invoked per iteration.
* @param [depth=1] - The maximum recursion depth.
* @returns Returns the new flattened array.
*
* @example
* const obj = { a: 1, b: 2 };
* flatMapDepth(obj, (value, key) => [[key, value]], 2);
* // => ['a', 1, 'b', 2]
*/
declare function flatMapDepth<T extends object, R>(collection: T | null | undefined, iteratee: ObjectIterator<T, ListOfRecursiveArraysOrValues<R> | R>, depth?: number): R[];
/**
* Creates a flattened array of values by running each element through iteratee and flattening the mapped results up to depth times.
*
* @param collection - The collection to iterate over.
* @param iteratee - The property name to use as iteratee.
* @param [depth=1] - The maximum recursion depth.
* @returns Returns the new flattened array.
*
* @example
* const users = [
* { user: 'barney', hobbies: [['hiking'], ['coding']] },
* { user: 'fred', hobbies: [['reading']] }
* ];
* flatMapDepth(users, 'hobbies', 2);
* // => ['hiking', 'coding', 'reading']
*/
declare function flatMapDepth(collection: object | null | undefined, iteratee: string, depth?: number): any[];
/**
* Creates a flattened array of values by running each element through iteratee and flattening the mapped results up to depth times.
*
* @param collection - The collection to iterate over.
* @param iteratee - The object properties to match.
* @param [depth=1] - The maximum recursion depth.
* @returns Returns the new flattened array.
*
* @example
* const users = [
* { user: 'barney', active: [[true], [false]] },
* { user: 'fred', active: [[false]] }
* ];
* flatMapDepth(users, { active: [[false]] });
* // => [false]
*/
declare function flatMapDepth(collection: object | null | undefined, iteratee: object, depth?: number): boolean[];
//#endregion
export { flatMapDepth };

View file

@ -0,0 +1,87 @@
import { ListIterator } from "../_internal/ListIterator.js";
import { ObjectIterator } from "../_internal/ObjectIterator.js";
import { ListOfRecursiveArraysOrValues } from "../_internal/ListOfRecursiveArraysOrValues.js";
//#region src/compat/array/flatMapDepth.d.ts
/**
* Creates a flattened array of values by running each element through iteratee and flattening the mapped results up to depth times.
*
* @template T
* @param collection - The collection to iterate over.
* @returns Returns the new flattened array.
*
* @example
* const obj = { a: [[1, 2]], b: [[[3]]] };
* flatMapDepth(obj);
* // => [1, 2, [3]]
*/
declare function flatMapDepth<T>(collection: Record<string, ListOfRecursiveArraysOrValues<T> | T> | Record<number, ListOfRecursiveArraysOrValues<T> | T> | null | undefined): T[];
/**
* Creates a flattened array of values by running each element through iteratee and flattening the mapped results up to depth times.
*
* @template T, R
* @param collection - The collection to iterate over.
* @param iteratee - The function invoked per iteration.
* @param [depth=1] - The maximum recursion depth.
* @returns Returns the new flattened array.
*
* @example
* function duplicate(n) {
* return [[n, n]];
* }
*
* flatMapDepth([1, 2], duplicate, 2);
* // => [1, 1, 2, 2]
*/
declare function flatMapDepth<T, R>(collection: ArrayLike<T> | null | undefined, iteratee: ListIterator<T, ListOfRecursiveArraysOrValues<R> | R>, depth?: number): R[];
/**
* Creates a flattened array of values by running each element through iteratee and flattening the mapped results up to depth times.
*
* @template T, R
* @param collection - The object to iterate over.
* @param iteratee - The function invoked per iteration.
* @param [depth=1] - The maximum recursion depth.
* @returns Returns the new flattened array.
*
* @example
* const obj = { a: 1, b: 2 };
* flatMapDepth(obj, (value, key) => [[key, value]], 2);
* // => ['a', 1, 'b', 2]
*/
declare function flatMapDepth<T extends object, R>(collection: T | null | undefined, iteratee: ObjectIterator<T, ListOfRecursiveArraysOrValues<R> | R>, depth?: number): R[];
/**
* Creates a flattened array of values by running each element through iteratee and flattening the mapped results up to depth times.
*
* @param collection - The collection to iterate over.
* @param iteratee - The property name to use as iteratee.
* @param [depth=1] - The maximum recursion depth.
* @returns Returns the new flattened array.
*
* @example
* const users = [
* { user: 'barney', hobbies: [['hiking'], ['coding']] },
* { user: 'fred', hobbies: [['reading']] }
* ];
* flatMapDepth(users, 'hobbies', 2);
* // => ['hiking', 'coding', 'reading']
*/
declare function flatMapDepth(collection: object | null | undefined, iteratee: string, depth?: number): any[];
/**
* Creates a flattened array of values by running each element through iteratee and flattening the mapped results up to depth times.
*
* @param collection - The collection to iterate over.
* @param iteratee - The object properties to match.
* @param [depth=1] - The maximum recursion depth.
* @returns Returns the new flattened array.
*
* @example
* const users = [
* { user: 'barney', active: [[true], [false]] },
* { user: 'fred', active: [[false]] }
* ];
* flatMapDepth(users, { active: [[false]] });
* // => [false]
*/
declare function flatMapDepth(collection: object | null | undefined, iteratee: object, depth?: number): boolean[];
//#endregion
export { flatMapDepth };

View file

@ -0,0 +1,26 @@
const require_identity = require("../../function/identity.js");
const require_iteratee = require("../util/iteratee.js");
const require_flatten = require("./flatten.js");
const require_map = require("./map.js");
//#region src/compat/array/flatMapDepth.ts
/**
* Creates a flattened array of values by running each element through iteratee and flattening the mapped results up to depth times.
*
* @template T, R
* @param collection - The array or object to iterate over.
* @param [iteratee] - The function that produces the new array elements.
* @param [depth=1] - The maximum recursion depth.
* @returns A new array that has been flattened up to the specified depth.
*
* @example
* flatMapDepth([1, 2, 3], n => [[n, n]], 2);
* // => [1, 1, 2, 2, 3, 3]
*/
function flatMapDepth(collection, iteratee$1 = require_identity.identity, depth = 1) {
if (collection == null) return [];
const iterateeFn = require_iteratee.iteratee(iteratee$1);
const mapped = require_map.map(collection, iterateeFn);
return require_flatten.flatten(mapped, depth);
}
//#endregion
exports.flatMapDepth = flatMapDepth;

View file

@ -0,0 +1,24 @@
import { identity } from "../../function/identity.mjs";
import { iteratee } from "../util/iteratee.mjs";
import { flatten } from "./flatten.mjs";
import { map } from "./map.mjs";
//#region src/compat/array/flatMapDepth.ts
/**
* Creates a flattened array of values by running each element through iteratee and flattening the mapped results up to depth times.
*
* @template T, R
* @param collection - The array or object to iterate over.
* @param [iteratee] - The function that produces the new array elements.
* @param [depth=1] - The maximum recursion depth.
* @returns A new array that has been flattened up to the specified depth.
*
* @example
* flatMapDepth([1, 2, 3], n => [[n, n]], 2);
* // => [1, 1, 2, 2, 3, 3]
*/
function flatMapDepth(collection, iteratee$1 = identity, depth = 1) {
if (collection == null) return [];
return flatten(map(collection, iteratee(iteratee$1)), depth);
}
//#endregion
export { flatMapDepth };

Some files were not shown because too many files have changed in this diff Show more