Socket
Socket
Sign inDemoInstall

es-toolkit

Package Overview
Dependencies
Maintainers
2
Versions
722
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es-toolkit - npm Package Compare versions

Comparing version 1.0.3-dev.35 to 1.0.3-dev.37

dist/array/chunk.d.mts

4

dist/array/chunk.d.ts

@@ -24,2 +24,4 @@ /**

*/
export declare function chunk<T>(arr: T[], size: number): T[][];
declare function chunk<T>(arr: T[], size: number): T[][];
export { chunk };

@@ -23,2 +23,4 @@ /**

*/
export declare function difference<T>(firstArr: T[], secondArr: T[]): T[];
declare function difference<T>(firstArr: T[], secondArr: T[]): T[];
export { difference };

@@ -26,2 +26,4 @@ /**

*/
export declare function differenceBy<T, U>(firstArr: T[], secondArr: T[], mapper: (value: T) => U): T[];
declare function differenceBy<T, U>(firstArr: T[], secondArr: T[], mapper: (value: T) => U): T[];
export { differenceBy };

@@ -22,2 +22,4 @@ /**

*/
export declare function differenceWith<T>(firstArr: T[], secondArr: T[], areItemsEqual: (x: T, y: T) => boolean): T[];
declare function differenceWith<T>(firstArr: T[], secondArr: T[], areItemsEqual: (x: T, y: T) => boolean): T[];
export { differenceWith };

@@ -16,2 +16,4 @@ /**

*/
export declare function drop<T>(arr: T[], itemsCount: number): T[];
declare function drop<T>(arr: T[], itemsCount: number): T[];
export { drop };

@@ -16,2 +16,4 @@ /**

*/
export declare function dropRight<T>(arr: T[], itemsCount: number): T[];
declare function dropRight<T>(arr: T[], itemsCount: number): T[];
export { dropRight };

@@ -18,2 +18,4 @@ /**

*/
export declare function dropRightWhile<T>(arr: T[], canContinueDropping: (item: T) => boolean): T[];
declare function dropRightWhile<T>(arr: T[], canContinueDropping: (item: T) => boolean): T[];
export { dropRightWhile };

@@ -18,2 +18,4 @@ /**

*/
export declare function dropWhile<T>(arr: T[], canContinueDropping: (item: T) => boolean): T[];
declare function dropWhile<T>(arr: T[], canContinueDropping: (item: T) => boolean): T[];
export { dropWhile };

@@ -31,2 +31,4 @@ /**

*/
export declare function groupBy<T, K extends string>(arr: T[], getKeyFromItem: (item: T) => K): Record<K, T[]>;
declare function groupBy<T, K extends string>(arr: T[], getKeyFromItem: (item: T) => K): Record<K, T[]>;
export { groupBy };

@@ -1,30 +0,30 @@

export { chunk } from './chunk';
export { difference } from './difference';
export { differenceBy } from './differenceBy';
export { differenceWith } from './differenceWith';
export { drop } from './drop';
export { dropRight } from './dropRight';
export { dropRightWhile } from './dropRightWhile';
export { dropWhile } from './dropWhile';
export { groupBy } from './groupBy';
export { intersection } from './intersection';
export { intersectionBy } from './intersectionBy';
export { intersectionWith } from './intersectionWith';
export { partition } from './partition';
export { sample } from './sample';
export { shuffle } from './shuffle';
export { take } from './take';
export { takeRight } from './takeRight';
export { takeRightWhile } from './takeRightWhile';
export { takeWhile } from './takeWhile';
export { union } from './union';
export { unionBy } from './unionBy';
export { unionWith } from './unionWith';
export { uniq } from './uniq';
export { uniqBy } from './uniqBy';
export { uniqWith } from './uniqWith';
export { xor } from './xor';
export { xorBy } from './xorBy';
export { xorWith } from './xorWith';
export { zip } from './zip';
export { zipWith } from './zipWith';
export { chunk } from './chunk.js';
export { difference } from './difference.js';
export { differenceBy } from './differenceBy.js';
export { differenceWith } from './differenceWith.js';
export { drop } from './drop.js';
export { dropRight } from './dropRight.js';
export { dropRightWhile } from './dropRightWhile.js';
export { dropWhile } from './dropWhile.js';
export { groupBy } from './groupBy.js';
export { intersection } from './intersection.js';
export { intersectionBy } from './intersectionBy.js';
export { intersectionWith } from './intersectionWith.js';
export { partition } from './partition.js';
export { sample } from './sample.js';
export { shuffle } from './shuffle.js';
export { take } from './take.js';
export { takeRight } from './takeRight.js';
export { takeRightWhile } from './takeRightWhile.js';
export { takeWhile } from './takeWhile.js';
export { union } from './union.js';
export { unionBy } from './unionBy.js';
export { unionWith } from './unionWith.js';
export { uniq } from './uniq.js';
export { uniqBy } from './uniqBy.js';
export { uniqWith } from './uniqWith.js';
export { xor } from './xor.js';
export { xorBy } from './xorBy.js';
export { xorWith } from './xorWith.js';
export { zip } from './zip.js';
export { zipWith } from './zipWith.js';

@@ -1,37 +0,66 @@

'use strict';
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
Object.defineProperty(exports, '__esModule', { value: true });
// src/array/index.ts
var array_exports = {};
__export(array_exports, {
chunk: () => chunk,
difference: () => difference,
differenceBy: () => differenceBy,
differenceWith: () => differenceWith,
drop: () => drop,
dropRight: () => dropRight,
dropRightWhile: () => dropRightWhile,
dropWhile: () => dropWhile,
groupBy: () => groupBy,
intersection: () => intersection,
intersectionBy: () => intersectionBy,
intersectionWith: () => intersectionWith,
partition: () => partition,
sample: () => sample,
shuffle: () => shuffle,
take: () => take,
takeRight: () => takeRight,
takeRightWhile: () => takeRightWhile,
takeWhile: () => takeWhile,
union: () => union,
unionBy: () => unionBy,
unionWith: () => unionWith,
uniq: () => uniq,
uniqBy: () => uniqBy,
uniqWith: () => uniqWith,
xor: () => xor,
xorBy: () => xorBy,
xorWith: () => xorWith,
zip: () => zip,
zipWith: () => zipWith
});
module.exports = __toCommonJS(array_exports);
/**
* 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 {T[]} arr - The array to be chunked into smaller arrays.
* @param {number} size - The size of each smaller array. Must be a positive integer.
* @returns {T[][]} A two-dimensional array where each sub-array has a maximum length of `size`.
* @throws {Error} Throws an error if `size` is not a positive integer.
*
* @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']]
*/
// src/array/chunk.ts
function chunk(arr, size) {
if (!Number.isInteger(size) || size <= 0) {
throw new Error('Size must be an integer greater than zero.');
throw new Error("Size must be an integer greater than zero.");
}
var chunkLength = Math.ceil(arr.length / size);
var result = Array(chunkLength);
for (var index = 0; index < chunkLength; index++) {
var start = index * size;
var end = start + size;
const chunkLength = Math.ceil(arr.length / size);
const result = Array(chunkLength);
for (let index = 0; index < chunkLength; index++) {
const start = index * size;
const end = start + size;
result[index] = arr.slice(start, end);

@@ -42,26 +71,5 @@ }

/**
* Computes the difference between two arrays.
*
* This function takes two arrays and returns a new array containing the elements
* that are present in the first array but not in the second array. It effectively
* filters out any elements from the first array that also appear in the second array.
*
* @template T
* @param {T[]} firstArr - The array from which to derive the difference. This is the primary array
* from which elements will be compared and filtered.
* @param {T[]} secondArr - The array containing elements to be excluded from the first array.
* Each element in this array will be checked against the first array, and if a match is found,
* that element will be excluded from the result.
* @returns {T[]} A new array containing the elements that are present in the first array but not
* in the second array.
*
* @example
* * const array1 = [1, 2, 3, 4, 5];
* const array2 = [2, 4];
* const result = difference(array1, array2);
* // result will be [1, 3, 5] since 2 and 4 are in both arrays and are excluded from the result.
*/
// src/array/difference.ts
function difference(firstArr, secondArr) {
return firstArr.filter(function (item) {
return firstArr.filter((item) => {
return !secondArr.includes(item);

@@ -71,32 +79,6 @@ });

/**
* Computes the difference between two arrays after mapping their elements through a provided function.
*
* This function takes two arrays and a mapper function. It returns a new array containing the elements
* that are present in the first array but not in the second array, based on the identity calculated
* by the mapper function.
*
* Essentially, it filters out any elements from the first array that, when
* mapped, match an element in the mapped version of the second array.
*
* @template T, U
* @param {T[]} firstArr - The primary array from which to derive the difference.
* @param {T[]} secondArr - The array containing elements to be excluded from the first array.
* @param {(value: T) => U} mapper - The function to map the elements of both arrays. This function
* is applied to each element in both arrays, and the comparison is made based on the mapped values.
* @returns {T[]} A new array containing the elements from the first array that do not have a corresponding
* mapped identity in the second array.
*
* @example
* * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const array2 = [{ id: 2 }, { id: 4 }];
* const mapper = item => item.id;
* const result = differenceBy(array1, array2, mapper);
* // result will be [{ id: 1 }, { id: 3 }] since the elements with id 2 are in both arrays and are excluded from the result.
*/
// src/array/differenceBy.ts
function differenceBy(firstArr, secondArr, mapper) {
var mappedSecondArr = secondArr.map(function (item) {
return mapper(item);
});
return firstArr.filter(function (item) {
const mappedSecondArr = secondArr.map((item) => mapper(item));
return firstArr.filter((item) => {
return !mappedSecondArr.includes(mapper(item));

@@ -106,26 +88,6 @@ });

/**
* Computes the difference between two arrays based on a custom equality function.
*
* This function takes two arrays and a custom comparison function. It returns a new array containing
* the elements that are present in the first array but not in the second array. The comparison to determine
* if elements are equal is made using the provided custom function.
*
* @template T
* @param {T[]} firstArr - The array from which to get the difference.
* @param {T[]} secondArr - The array containing elements to exclude from the first array.
* @param {(x: T, y: T) => boolean} areItemsEqual - A function to determine if two items are equal.
* @returns {T[]} A new array containing the elements from the first array that do not match any elements in the second array
* according to the custom equality function.
*
* @example
* * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const array2 = [{ id: 2 }, { id: 4 }];
* const areItemsEqual = (a, b) => a.id === b.id;
* const result = differenceWith(array1, array2, areItemsEqual);
* // result will be [{ id: 1 }, { id: 3 }] since the elements with id 2 are considered equal and are excluded from the result.
*/
// src/array/differenceWith.ts
function differenceWith(firstArr, secondArr, areItemsEqual) {
return firstArr.filter(function (firstItem) {
return secondArr.every(function (secondItem) {
return firstArr.filter((firstItem) => {
return secondArr.every((secondItem) => {
return !areItemsEqual(firstItem, secondItem);

@@ -136,17 +98,3 @@ });

/**
* 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.
*
* @param {T[]} arr - The array from which to drop elements.
* @param {number} itemsCount - The number of elements to drop from the beginning of the array.
* @returns {T[]} 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.
*/
// src/array/drop.ts
function drop(arr, itemsCount) {

@@ -156,17 +104,3 @@ return arr.slice(itemsCount);

/**
* 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.
*
* @param {T[]} arr - The array from which to drop elements.
* @param {number} itemsCount - The number of elements to drop from the end of the array.
* @returns {T[]} 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.
*/
// src/array/dropRight.ts
function dropRight(arr, itemsCount) {

@@ -176,173 +110,24 @@ return arr.slice(0, -itemsCount);

/**
* Removes elements from the beginning of an array until the predicate returns false.
*
* This function iterates over an array and drops elements from the start until the provided
* predicate function returns false. It then returns a new array with the remaining elements.
*
* @param {T[]} arr - The array from which to drop elements.
* @param {(item: T) => boolean} canContinueDropping - A predicate function that determines
* whether to continue dropping elements. The function is called with each element, and dropping
* continues as long as it returns true.
* @returns {T[]} A new array with the elements remaining after the predicate returns false.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = dropWhile(array, x => x < 3);
* // result will be [3, 4, 5] since elements less than 3 are dropped.
*/
// src/array/dropWhile.ts
function dropWhile(arr, canContinueDropping) {
var dropEndIndex = arr.findIndex(function (item) {
return !canContinueDropping(item);
});
const dropEndIndex = arr.findIndex((item) => !canContinueDropping(item));
return arr.slice(dropEndIndex);
}
/**
* Removes elements from the end of an array until the predicate returns false.
*
* This function iterates over an array from the end and drops elements until the provided
* predicate function returns false. It then returns a new array with the remaining elements.
*
* @param {T[]} arr - The array from which to drop elements.
* @param {function(item: T): boolean} canContinueDropping - A predicate function that determines
* whether to continue dropping elements. The function is called with each element from the end,
* and dropping continues as long as it returns true.
* @returns {T[]} A new array with the elements remaining after the predicate returns false.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = dropRightWhile(array, x => x > 3);
* // result will be [1, 2, 3] since elements greater than 3 are dropped from the end.
*/
// src/array/dropRightWhile.ts
function dropRightWhile(arr, canContinueDropping) {
var reversed = arr.slice().reverse();
var dropped = dropWhile(reversed, canContinueDropping);
const reversed = arr.slice().reverse();
const dropped = dropWhile(reversed, canContinueDropping);
return dropped.slice().reverse();
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
}
function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _createForOfIteratorHelper(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (!it) {
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;
var F = function () {};
return {
s: F,
n: function () {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
},
e: function (e) {
throw e;
},
f: F
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var normalCompletion = true,
didErr = false,
err;
return {
s: function () {
it = it.call(o);
},
n: function () {
var step = it.next();
normalCompletion = step.done;
return step;
},
e: function (e) {
didErr = true;
err = e;
},
f: function () {
try {
if (!normalCompletion && it.return != null) it.return();
} finally {
if (didErr) throw err;
}
}
};
}
/**
* Groups the elements of an array based on a provided key-generating function.
*
* This function takes an array and a function that generates a key from each element. It returns
* an object where the keys are the generated keys and the values are arrays of elements that share
* the same key.
*
* @param {T[]} arr - The array to group.
* @param {(item: T) => K} getKeyFromItem - A function that generates a key from an element.
* @returns {Record<K, T[]>} An object where each key is associated with an array of elements that
* share that key.
*
* @example
* const array = [
* { category: 'fruit', name: 'apple' },
* { category: 'fruit', name: 'banana' },
* { category: 'vegetable', name: 'carrot' }
* ];
* const result = groupBy(array, item => item.category);
* // result will be:
* // {
* // fruit: [
* // { category: 'fruit', name: 'apple' },
* // { category: 'fruit', name: 'banana' }
* // ],
* // vegetable: [
* // { category: 'vegetable', name: 'carrot' }
* // ]
* // }
*/
// src/array/groupBy.ts
function groupBy(arr, getKeyFromItem) {
var result = {};
var _iterator = _createForOfIteratorHelper(arr),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var item = _step.value;
var key = getKeyFromItem(item);
if (result[key] == null) {
result[key] = [];
}
result[key].push(item);
const result = {};
for (const item of arr) {
const key = getKeyFromItem(item);
if (result[key] == null) {
result[key] = [];
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
result[key].push(item);
}

@@ -352,21 +137,5 @@ return result;

/**
* Returns the intersection of two arrays.
*
* This function takes two arrays and returns a new array containing the elements that are
* present in both arrays. It effectively filters out any elements from the first array that
* are not found in the second array.
*
* @param {T[]} firstArr - The first array to compare.
* @param {T[]} secondArr - The second array to compare.
* @returns {T[]} A new array containing the elements that are present in both arrays.
*
* @example
* const array1 = [1, 2, 3, 4, 5];
* const array2 = [3, 4, 5, 6, 7];
* const result = intersection(array1, array2);
* // result will be [3, 4, 5] since these elements are in both arrays.
*/
// src/array/intersection.ts
function intersection(firstArr, secondArr) {
return firstArr.filter(function (item) {
return firstArr.filter((item) => {
return secondArr.includes(item);

@@ -376,27 +145,6 @@ });

/**
* Returns the intersection of two arrays based on a mapping function.
*
* This function takes two arrays and a mapping function. It returns a new array containing
* the elements from the first array that, when mapped using the provided function, have matching
* mapped elements in the second array. It effectively filters out any elements from the first array
* that do not have corresponding mapped values in the second array.
*
* @param {T[]} firstArr - The first array to compare.
* @param {T[]} secondArr - The second array to compare.
* @param {(item: T) => U} mapper - A function to map the elements of both arrays for comparison.
* @returns {T[]} A new array containing the elements from the first array that have corresponding mapped values in the second array.
*
* @example
* const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const array2 = [{ id: 2 }, { id: 4 }];
* const mapper = item => item.id;
* const result = intersectionBy(array1, array2, mapper);
* // result will be [{ id: 2 }] since only this element has a matching id in both arrays.
*/
// src/array/intersectionBy.ts
function intersectionBy(firstArr, secondArr, mapper) {
var mappedSecondArr = secondArr.map(function (x) {
return mapper(x);
});
return firstArr.filter(function (item) {
const mappedSecondArr = secondArr.map((x) => mapper(x));
return firstArr.filter((item) => {
return mappedSecondArr.includes(mapper(item));

@@ -406,26 +154,6 @@ });

/**
* Returns the intersection of two arrays based on a custom equality function.
*
* This function takes two arrays and a custom equality function. It returns a new array containing
* the elements from the first array that have matching elements in the second array, as determined
* by the custom equality function. It effectively filters out any elements from the first array that
* do not have corresponding matches in the second array according to the equality function.
*
* @param {T[]} firstArr - The first array to compare.
* @param {T[]} secondArr - The second array to compare.
* @param {(x: T, y: T) => boolean} areItemsEqual - A custom function to determine if two elements are equal.
* This function takes two arguments, one from each array, and returns `true` if the elements are considered equal, and `false` otherwise.
* @returns {T[]} A new array containing the elements from the first array that have corresponding matches in the second array according to the custom equality function.
*
* @example
* * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const array2 = [{ id: 2 }, { id: 4 }];
* const areItemsEqual = (a, b) => a.id === b.id;
* const result = intersectionWith(array1, array2, areItemsEqual);
* // result will be [{ id: 2 }] since this element has a matching id in both arrays.
*/
// src/array/intersectionWith.ts
function intersectionWith(firstArr, secondArr, areItemsEqual) {
return firstArr.filter(function (firstItem) {
return secondArr.some(function (secondItem) {
return firstArr.filter((firstItem) => {
return secondArr.some((secondItem) => {
return areItemsEqual(firstItem, secondItem);

@@ -436,41 +164,12 @@ });

/**
* Splits an array into two groups based on a predicate function.
*
* This function takes an array and a predicate function. It returns a tuple of two arrays:
* the first array contains elements for which the predicate function returns true, and
* the second array contains elements for which the predicate function returns false.
*
* @param {T[]} arr - The array to partition.
* @param {(value: T) => boolean} isInTruthy - A predicate function that determines
* whether an element should be placed in the truthy array. The function is called with each
* element of the array.
* @returns {[T[], T[]]} A tuple containing two arrays: the first array contains elements for
* which the predicate returned true, and the second array contains elements for which the
* predicate returned false.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const isEven = x => x % 2 === 0;
* const [even, odd] = partition(array, isEven);
* // even will be [2, 4], and odd will be [1, 3, 5]
*/
// src/array/partition.ts
function partition(arr, isInTruthy) {
var truthy = [];
var falsy = [];
var _iterator = _createForOfIteratorHelper(arr),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var item = _step.value;
if (isInTruthy(item)) {
truthy.push(item);
} else {
falsy.push(item);
}
const truthy = [];
const falsy = [];
for (const item of arr) {
if (isInTruthy(item)) {
truthy.push(item);
} else {
falsy.push(item);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}

@@ -480,42 +179,13 @@ return [truthy, falsy];

/**
* Returns a random element from an array.
*
* This function takes an array and returns a single element selected randomly from the array.
*
* @param {T[]} arr - The array to sample from.
* @returns {T} A random element from the array.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const randomElement = sample(array);
* // randomElement will be one of the elements from the array, selected randomly.
*/
// src/array/sample.ts
function sample(arr) {
var randomIndex = Math.floor(Math.random() * arr.length);
const randomIndex = Math.floor(Math.random() * arr.length);
return arr[randomIndex];
}
/**
* Randomizes the order of elements in an array using the Fisher-Yates algorithm.
*
* This function takes an array and returns a new array with its elements shuffled in a random order.
*
* @param {T[]} arr - The array to shuffle.
* @returns {T[]} A new array with its elements shuffled in random order.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const shuffledArray = shuffle(array);
* // shuffledArray will be a new array with elements of array in random order, e.g., [3, 1, 4, 5, 2]
*/
// src/array/shuffle.ts
function shuffle(arr) {
/**
* https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm
*/
for (var i = arr.length - 1; i >= 1; i--) {
var j = Math.floor(Math.random() * (i + 1));
var _ref = [arr[j], arr[i]];
arr[i] = _ref[0];
arr[j] = _ref[1];
for (let i = arr.length - 1; i >= 1; i--) {
const j = Math.floor(Math.random() * (i + 1));
[arr[i], arr[j]] = [arr[j], arr[i]];
}

@@ -525,24 +195,3 @@ return arr;

/**
* Returns a new array containing the first `count` elements from the input array `arr`.
* If `count` is greater than the length of `arr`, the entire array is returned.
*
* @template T - Type of elements in the input array.
*
* @param {T[]} arr - The array to take elements from.
* @param {number} count - The number of elements to take.
* @returns {T[]} A new array containing the first `count` elements from `arr`.
*
* @example
* // Returns [1, 2, 3]
* take([1, 2, 3, 4, 5], 3);
*
* @example
* // Returns ['a', 'b']
* take(['a', 'b', 'c'], 2);
*
* @example
* // Returns [1, 2, 3]
* take([1, 2, 3], 5);
*/
// src/array/take.ts
function take(arr, count) {

@@ -552,22 +201,3 @@ return arr.slice(0, count);

/**
* Returns a new array containing the last `count` elements from the input array `arr`.
* If `count` is greater than the length of `arr`, the entire array is returned.
*
* @param {T[]} arr - The array to take elements from.
* @param {number} count - The number of elements to take.
* @returns {T[]} A new array containing the last `count` elements from `arr`.
*
* @example
* // Returns [4, 5]
* takeRight([1, 2, 3, 4, 5], 2);
*
* @example
* // Returns ['b', 'c']
* takeRight(['a', 'b', 'c'], 2);
*
* @example
* // Returns [1, 2, 3]
* takeRight([1, 2, 3], 5);
*/
// src/array/takeRight.ts
function takeRight(arr, count) {

@@ -580,21 +210,5 @@ if (count === 0) {

/**
* Takes elements from the end of the array while the predicate function returns `true`.
*
* @template T - Type of elements in the input array.
*
* @param {T[]} arr - The array to take elements from.
* @param {function(T): boolean} shouldContinueTaking - The function invoked per element.
* @returns {T[]} A new array containing the elements taken from the end while the predicate returns `true`.
*
* @example
* // Returns [3, 2, 1]
* takeRightWhile([5, 4, 3, 2, 1], n => n < 4);
*
* @example
* // Returns []
* takeRightWhile([1, 2, 3], n => n > 3);
*/
// src/array/takeRightWhile.ts
function takeRightWhile(arr, shouldContinueTaking) {
for (var i = arr.length - 1; i >= 0; i--) {
for (let i = arr.length - 1; i >= 0; i--) {
if (!shouldContinueTaking(arr[i])) {

@@ -607,36 +221,10 @@ return arr.slice(i + 1);

/**
* Returns a new array containing the leading elements of the provided array
* that satisfy the provided predicate function. It stops taking elements as soon
* as an element does not satisfy the predicate.
*
* @template T - The type of elements in the array.
* @param {T[]} arr - The array to process.
* @param {(element: T) => boolean} shouldContinueTaking - The predicate function that is called with each element. Elements are included in the result as long as this function returns true.
* @returns {T[]} A new array containing the leading elements that satisfy the predicate.
*
* @example
* // Returns [1, 2]
* takeWhile([1, 2, 3, 4], x => x < 3);
*
* @example
* // Returns []
* takeWhile([1, 2, 3, 4], x => x > 3);
*/
// src/array/takeWhile.ts
function takeWhile(arr, shouldContinueTaking) {
var result = [];
var _iterator = _createForOfIteratorHelper(arr),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var item = _step.value;
if (!shouldContinueTaking(item)) {
break;
}
result.push(item);
const result = [];
for (const item of arr) {
if (!shouldContinueTaking(item)) {
break;
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
result.push(item);
}

@@ -646,32 +234,10 @@ return result;

/**
* Creates a duplicate-free version of an array.
*
* This function takes an array and returns a new array containing only the unique values
* from the original array, preserving the order of first occurrence.
*
* @param {T[]} arr - The array to process.
* @returns {T[]} A new array with only unique values from the original array.
*
* @example
* * const array = [1, 2, 2, 3, 4, 4, 5];
* const result = uniq(array);
* // result will be [1, 2, 3, 4, 5]
*/
// src/array/uniq.ts
function uniq(arr) {
var result = [];
var _iterator = _createForOfIteratorHelper(arr),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var item = _step.value;
if (result.includes(item)) {
continue;
}
result.push(item);
const result = [];
for (const item of arr) {
if (result.includes(item)) {
continue;
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
result.push(item);
}

@@ -681,18 +247,3 @@ return result;

/**
* Creates an array of unique values from all given arrays.
*
* This function takes two arrays, merges them into a single array, and returns a new array
* containing only the unique values from the merged array.
*
* @param {T[]} arr1 - The first array to merge and filter for unique values.
* @param {T[]} arr2 - The second array to merge and filter for unique values.
* @returns {T[]} A new array of unique values.
*
* @example
* const array1 = [1, 2, 3];
* const array2 = [3, 4, 5];
* const result = union(array1, array2);
* // result will be [1, 2, 3, 4, 5]
*/
// src/array/union.ts
function union(arr1, arr2) {

@@ -702,27 +253,7 @@ return uniq(arr1.concat(arr2));

/**
* Creates an array of unique values, in order, from all given arrays using a provided mapping function to determine equality.
*
* @param {T[]} arr1 - The first array.
* @param {T[]} arr2 - The second array.
* @param {function(item: T): U} mapper - The function to map array elements to comparison values.
* @returns {T[]} A new array containing the union of unique elements from `arr1` and `arr2`, based on the values returned by the mapping function.
*
* @example
* // Custom mapping function for numbers (modulo comparison)
* const moduloMapper = (x) => x % 3;
* unionBy([1, 2, 3], [4, 5, 6], moduloMapper);
* // Returns [1, 2, 3]
*
* @example
* // Custom mapping function for objects with an 'id' property
* const idMapper = (obj) => obj.id;
* unionBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);
* // Returns [{ id: 1 }, { id: 2 }, { id: 3 }]
*/
// src/array/unionBy.ts
function unionBy(arr1, arr2, mapper) {
var map = new Map();
for (var _i = 0, _arr = [].concat(_toConsumableArray(arr1), _toConsumableArray(arr2)); _i < _arr.length; _i++) {
var item = _arr[_i];
var key = mapper(item);
const map = /* @__PURE__ */ new Map();
for (const item of [...arr1, ...arr2]) {
const key = mapper(item);
if (!map.has(key)) {

@@ -732,37 +263,13 @@ map.set(key, item);

}
return _toConsumableArray(map.values());
return [...map.values()];
}
/**
* The `uniqWith` function takes an array as its first argument and a 'comparator' function as the second.
*
* It evaluates the elements of the array using the comparator function, and if true is returned, it considers those elements as duplicates and removes them.
*
* @example
* ```ts
* uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => Math.abs(a - b) < 1);
* // [1, 2, 3, 5, 7]
* ```
*/
// src/array/uniqWith.ts
function uniqWith(arr, areItemsEqual) {
var result = [];
var _iterator = _createForOfIteratorHelper(arr),
_step;
try {
var _loop = function _loop() {
var item = _step.value;
var isUniq = result.every(function (v) {
return !areItemsEqual(v, item);
});
if (isUniq) {
result.push(item);
}
};
for (_iterator.s(); !(_step = _iterator.n()).done;) {
_loop();
const result = [];
for (const item of arr) {
const isUniq = result.every((v) => !areItemsEqual(v, item));
if (isUniq) {
result.push(item);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}

@@ -772,21 +279,3 @@ return result;

/**
* Creates an array of unique values from two given arrays based on a custom equality function.
*
* This function takes two arrays and a custom equality function, merges the arrays, and returns
* a new array containing only the unique values as determined by the custom equality function.
*
* @param {T[]} arr1 - The first array to merge and filter for unique values.
* @param {T[]} arr2 - The second array to merge and filter for unique values.
* @param {(item1: T, item2: T) => boolean} areItemsEqual - A custom function to determine if two elements are equal.
* It takes two arguments and returns `true` if the elements are considered equal, and `false` otherwise.
* @returns {T[]} A new array of unique values based on the custom equality function.
*
* @example
* const array1 = [{ id: 1 }, { id: 2 }];
* const array2 = [{ id: 2 }, { id: 3 }];
* const areItemsEqual = (a, b) => a.id === b.id;
* const result = unionWith(array1, array2, areItemsEqual);
* // result will be [{ id: 1 }, { id: 2 }, { id: 3 }] since { id: 2 } is considered equal in both arrays
*/
// src/array/unionWith.ts
function unionWith(arr1, arr2, areItemsEqual) {

@@ -796,35 +285,8 @@ return uniqWith(arr1.concat(arr2), areItemsEqual);

/**
* The `uniqBy` function takes an array as its first argument and a 'converter' function as the second. It maps the array elements using the converter function, then removes any duplicates.
*
* It filters out elements with the same value, meaning it does not check for duplicates in data types like Objects.
*
* @example
* ```ts
* uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);
* // [1.2, 2.1, 3.3, 5.7, 7.19]
* ```
*/
// src/array/uniqBy.ts
function uniqBy(arr, converter) {
return uniqWith(arr, function (item1, item2) {
return converter(item1) === converter(item2);
});
return uniqWith(arr, (item1, item2) => converter(item1) === converter(item2));
}
/**
* Computes the symmetric difference between two arrays. The symmetric difference is the set of elements
* which are in either of the arrays, but not in their intersection.
*
* @param {T[]} arr1 - The first array.
* @param {T[]} arr2 - The second array.
* @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both.
*
* @example
* // Returns [1, 2, 5, 6]
* xor([1, 2, 3, 4], [3, 4, 5, 6]);
*
* @example
* // Returns ['a', 'c']
* xor(['a', 'b'], ['b', 'c']);
*/
// src/array/xor.ts
function xor(arr1, arr2) {

@@ -834,94 +296,24 @@ return difference(union(arr1, arr2), intersection(arr1, arr2));

/**
* Computes the symmetric difference between two arrays using a custom mapping function.
* The symmetric difference is the set of elements which are in either of the arrays,
* but not in their intersection, determined by the result of the mapping function.
*
* @template T - Type of elements in the input arrays.
* @template U - Type of the values returned by the mapping function.
*
* @param {T[]} arr1 - The first array.
* @param {T[]} arr2 - The second array.
* @param {function(item: T): U} mapper - The function to map array elements to comparison values.
* @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both, based on the values returned by the mapping function.
*
* @example
* // Custom mapping function for objects with an 'id' property
* const idMapper = obj => obj.id;
* xorBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);
* // Returns [{ id: 1 }, { id: 3 }]
*/
// src/array/xorBy.ts
function xorBy(arr1, arr2, mapper) {
var union = unionBy(arr1, arr2, mapper);
var intersection = intersectionBy(arr1, arr2, mapper);
return differenceBy(union, intersection, mapper);
const union2 = unionBy(arr1, arr2, mapper);
const intersection2 = intersectionBy(arr1, arr2, mapper);
return differenceBy(union2, intersection2, mapper);
}
/**
* Computes the symmetric difference between two arrays using a custom equality function.
* The symmetric difference is the set of elements which are in either of the arrays,
* but not in their intersection.
*
* @template T - Type of elements in the input arrays.
*
* @param {T[]} arr1 - The first array.
* @param {T[]} arr2 - The second array.
* @param {(item1: T, item2: T) => boolean} areElementsEqual - The custom equality function to compare elements.
* @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both, based on the custom equality function.
*
* @example
* // Custom equality function for objects with an 'id' property
* const areObjectsEqual = (a, b) => a.id === b.id;
* xorWith([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], areObjectsEqual);
* // Returns [{ id: 1 }, { id: 3 }]
*/
// src/array/xorWith.ts
function xorWith(arr1, arr2, areElementsEqual) {
var union = unionWith(arr1, arr2, areElementsEqual);
var intersection = intersectionWith(arr1, arr2, areElementsEqual);
return differenceWith(union, intersection, areElementsEqual);
const union2 = unionWith(arr1, arr2, areElementsEqual);
const intersection2 = intersectionWith(arr1, arr2, areElementsEqual);
return differenceWith(union2, intersection2, areElementsEqual);
}
/**
* Combines multiple arrays into a single array of tuples.
*
* This function takes multiple arrays and returns a new array where each element is a tuple
* containing the corresponding elements from the input arrays. If the input arrays are of
* different lengths, the resulting array will have the length of the longest input array,
* with undefined values for missing elements.
*
* @param {...T[][]} arrs - The arrays to zip together.
* @returns {T[][]} A new array of tuples containing the corresponding elements from the input arrays.
*
* @example
* const arr1 = [1, 2, 3];
* const arr2 = ['a', 'b', 'c'];
* const result = zip(arr1, arr2);
* // result will be [[1, 'a'], [2, 'b'], [3, 'c']]
*
* const arr3 = [true, false];
* const result2 = zip(arr1, arr2, arr3);
* // result2 will be [[1, 'a', true], [2, 'b', false], [3, 'c', undefined]]
*/
function zip() {
var result = [];
for (var _len = arguments.length, arrs = new Array(_len), _key = 0; _key < _len; _key++) {
arrs[_key] = arguments[_key];
}
var maxIndex = Math.max.apply(Math, _toConsumableArray(arrs.map(function (x) {
return x.length;
})));
for (var i = 0; i < maxIndex; i++) {
var element = [];
var _iterator = _createForOfIteratorHelper(arrs),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var arr = _step.value;
element.push(arr[i]);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
// src/array/zip.ts
function zip(...arrs) {
const result = [];
const maxIndex = Math.max(...arrs.map((x) => x.length));
for (let i = 0; i < maxIndex; i++) {
const element = [];
for (const arr of arrs) {
element.push(arr[i]);
}

@@ -933,82 +325,47 @@ result.push(element);

/**
* Combines multiple arrays into a single array using a custom combiner function.
*
* This function takes multiple arrays and a combiner function, and returns a new array where each element
* is the result of applying the combiner function to the corresponding elements of the input arrays.
*
* @param {T[]} arr1 - The first array to zip.
* @param {U[]} [arr2] - The second array to zip (optional).
* @param {V[]} [arr3] - The third array to zip (optional).
* @param {W[]} [arr4] - The fourth array to zip (optional).
* @param {function} combine - The combiner function that takes corresponding elements from each array and returns a single value.
* @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.
*
* @example
* // Example usage with two arrays:
* const arr1 = [1, 2, 3];
* const arr2 = [4, 5, 6];
* const result = zipWith(arr1, arr2, (a, b) => a + b);
* // result will be [5, 7, 9]
*
* @example
* // Example usage with three arrays:
* const arr1 = [1, 2];
* const arr2 = [3, 4];
* const arr3 = [5, 6];
* const result = zipWith(arr1, arr2, arr3, (a, b, c) => `${a}${b}${c}`);
* // result will be [`135`, `246`]
*/
function zipWith(arr1) {
for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
rest[_key - 1] = arguments[_key];
// src/array/zipWith.ts
function zipWith(arr1, ...rest) {
const arrs = [arr1, ...rest.slice(0, -1)];
const combine = rest[rest.length - 1];
const result = [];
const maxIndex = Math.max(...arrs.map((arr) => arr.length));
for (let i = 0; i < maxIndex; i++) {
const elements = arrs.map((arr) => arr[i]);
result.push(combine(...elements));
}
var arrs = [arr1].concat(_toConsumableArray(rest.slice(0, -1)));
var combine = rest[rest.length - 1];
var result = [];
var maxIndex = Math.max.apply(Math, _toConsumableArray(arrs.map(function (arr) {
return arr.length;
})));
var _loop = function _loop(i) {
var elements = arrs.map(function (arr) {
return arr[i];
});
result.push(combine.apply(void 0, _toConsumableArray(elements)));
};
for (var i = 0; i < maxIndex; i++) {
_loop(i);
}
return result;
}
exports.chunk = chunk;
exports.difference = difference;
exports.differenceBy = differenceBy;
exports.differenceWith = differenceWith;
exports.drop = drop;
exports.dropRight = dropRight;
exports.dropRightWhile = dropRightWhile;
exports.dropWhile = dropWhile;
exports.groupBy = groupBy;
exports.intersection = intersection;
exports.intersectionBy = intersectionBy;
exports.intersectionWith = intersectionWith;
exports.partition = partition;
exports.sample = sample;
exports.shuffle = shuffle;
exports.take = take;
exports.takeRight = takeRight;
exports.takeRightWhile = takeRightWhile;
exports.takeWhile = takeWhile;
exports.union = union;
exports.unionBy = unionBy;
exports.unionWith = unionWith;
exports.uniq = uniq;
exports.uniqBy = uniqBy;
exports.uniqWith = uniqWith;
exports.xor = xor;
exports.xorBy = xorBy;
exports.xorWith = xorWith;
exports.zip = zip;
exports.zipWith = zipWith;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
chunk,
difference,
differenceBy,
differenceWith,
drop,
dropRight,
dropRightWhile,
dropWhile,
groupBy,
intersection,
intersectionBy,
intersectionWith,
partition,
sample,
shuffle,
take,
takeRight,
takeRightWhile,
takeWhile,
union,
unionBy,
unionWith,
uniq,
uniqBy,
uniqWith,
xor,
xorBy,
xorWith,
zip,
zipWith
});
//# sourceMappingURL=index.js.map

@@ -18,2 +18,4 @@ /**

*/
export declare function intersection<T>(firstArr: T[], secondArr: T[]): T[];
declare function intersection<T>(firstArr: T[], secondArr: T[]): T[];
export { intersection };

@@ -21,2 +21,4 @@ /**

*/
export declare function intersectionBy<T, U>(firstArr: T[], secondArr: T[], mapper: (item: T) => U): T[];
declare function intersectionBy<T, U>(firstArr: T[], secondArr: T[], mapper: (item: T) => U): T[];
export { intersectionBy };

@@ -22,2 +22,4 @@ /**

*/
export declare function intersectionWith<T>(firstArr: T[], secondArr: T[], areItemsEqual: (x: T, y: T) => boolean): T[];
declare function intersectionWith<T>(firstArr: T[], secondArr: T[], areItemsEqual: (x: T, y: T) => boolean): T[];
export { intersectionWith };

@@ -22,2 +22,4 @@ /**

*/
export declare function partition<T>(arr: T[], isInTruthy: (value: T) => boolean): [truthy: T[], falsy: T[]];
declare function partition<T>(arr: T[], isInTruthy: (value: T) => boolean): [truthy: T[], falsy: T[]];
export { partition };

@@ -14,2 +14,4 @@ /**

*/
export declare function sample<T>(arr: T[]): T;
declare function sample<T>(arr: T[]): T;
export { sample };

@@ -14,2 +14,4 @@ /**

*/
export declare function shuffle<T>(arr: T[]): T[];
declare function shuffle<T>(arr: T[]): T[];
export { shuffle };

@@ -23,2 +23,4 @@ /**

*/
export declare function take<T>(arr: T[], count: number): T[];
declare function take<T>(arr: T[], count: number): T[];
export { take };

@@ -21,2 +21,4 @@ /**

*/
export declare function takeRight<T>(arr: T[], count: number): T[];
declare function takeRight<T>(arr: T[], count: number): T[];
export { takeRight };

@@ -18,2 +18,4 @@ /**

*/
export declare function takeRightWhile<T>(arr: T[], shouldContinueTaking: (item: T) => boolean): T[];
declare function takeRightWhile<T>(arr: T[], shouldContinueTaking: (item: T) => boolean): T[];
export { takeRightWhile };

@@ -19,2 +19,4 @@ /**

*/
export declare function takeWhile<T>(arr: T[], shouldContinueTaking: (element: T) => boolean): T[];
declare function takeWhile<T>(arr: T[], shouldContinueTaking: (element: T) => boolean): T[];
export { takeWhile };

@@ -17,2 +17,4 @@ /**

*/
export declare function union<T>(arr1: T[], arr2: T[]): T[];
declare function union<T>(arr1: T[], arr2: T[]): T[];
export { union };

@@ -21,2 +21,4 @@ /**

*/
export declare function unionBy<T, U>(arr1: T[], arr2: T[], mapper: (item: T) => U): T[];
declare function unionBy<T, U>(arr1: T[], arr2: T[], mapper: (item: T) => U): T[];
export { unionBy };

@@ -20,2 +20,4 @@ /**

*/
export declare function unionWith<T>(arr1: T[], arr2: T[], areItemsEqual: (item1: T, item2: T) => boolean): T[];
declare function unionWith<T>(arr1: T[], arr2: T[], areItemsEqual: (item1: T, item2: T) => boolean): T[];
export { unionWith };

@@ -15,2 +15,4 @@ /**

*/
export declare function uniq<T>(arr: T[]): T[];
declare function uniq<T>(arr: T[]): T[];
export { uniq };

@@ -12,2 +12,4 @@ /**

*/
export declare function uniqBy<T, U>(arr: T[], converter: (item: T) => U): T[];
declare function uniqBy<T, U>(arr: T[], converter: (item: T) => U): T[];
export { uniqBy };

@@ -12,2 +12,4 @@ /**

*/
export declare function uniqWith<T>(arr: T[], areItemsEqual: (item1: T, item2: T) => boolean): T[];
declare function uniqWith<T>(arr: T[], areItemsEqual: (item1: T, item2: T) => boolean): T[];
export { uniqWith };

@@ -17,2 +17,4 @@ /**

*/
export declare function xor<T>(arr1: T[], arr2: T[]): T[];
declare function xor<T>(arr1: T[], arr2: T[]): T[];
export { xor };

@@ -20,2 +20,4 @@ /**

*/
export declare function xorBy<T, U>(arr1: T[], arr2: T[], mapper: (item: T) => U): T[];
declare function xorBy<T, U>(arr1: T[], arr2: T[], mapper: (item: T) => U): T[];
export { xorBy };

@@ -19,2 +19,4 @@ /**

*/
export declare function xorWith<T>(arr1: T[], arr2: T[], areElementsEqual: (item1: T, item2: T) => boolean): T[];
declare function xorWith<T>(arr1: T[], arr2: T[], areElementsEqual: (item1: T, item2: T) => boolean): T[];
export { xorWith };

@@ -22,5 +22,7 @@ /**

*/
export declare function zip<T>(arr1: T[]): [T][];
export declare function zip<T, U>(arr1: T[], arr2: U[]): [T, U][];
export declare function zip<T, U, V>(arr1: T[], arr2: U[], arr3: V[]): [T, U, V][];
export declare function zip<T, U, V, W>(arr1: T[], arr2: U[], arr3: V[], arr4: W[]): [T, U, V, W][];
declare function zip<T>(arr1: T[]): [T][];
declare function zip<T, U>(arr1: T[], arr2: U[]): [T, U][];
declare function zip<T, U, V>(arr1: T[], arr2: U[], arr3: V[]): [T, U, V][];
declare function zip<T, U, V, W>(arr1: T[], arr2: U[], arr3: V[], arr4: W[]): [T, U, V, W][];
export { zip };

@@ -29,5 +29,7 @@ /**

*/
export declare function zipWith<T, R>(arr1: T[], combine: (item: T) => R): R[];
export declare function zipWith<T, U, R>(arr1: T[], arr2: U[], combine: (item1: T, item2: U) => R): R[];
export declare function zipWith<T, U, V, R>(arr1: T[], arr2: U[], arr3: V[], combine: (item1: T, item2: U, item3: V) => R): R[];
export declare function zipWith<T, U, V, W, R>(arr1: T[], arr2: U[], arr3: V[], arr4: W[], combine: (item1: T, item2: U, item3: V, item4: W) => R): R[];
declare function zipWith<T, R>(arr1: T[], combine: (item: T) => R): R[];
declare function zipWith<T, U, R>(arr1: T[], arr2: U[], combine: (item1: T, item2: U) => R): R[];
declare function zipWith<T, U, V, R>(arr1: T[], arr2: U[], arr3: V[], combine: (item1: T, item2: U, item3: V) => R): R[];
declare function zipWith<T, U, V, W, R>(arr1: T[], arr2: U[], arr3: V[], arr4: W[], combine: (item1: T, item2: U, item3: V, item4: W) => R): R[];
export { zipWith };

@@ -21,5 +21,7 @@ /**

*/
export declare function debounce(func: () => void, debounceMs: number): {
declare function debounce(func: () => void, debounceMs: number): {
(): void;
cancel: () => void;
};
export { debounce };

@@ -1,3 +0,3 @@

export { debounce } from './debounce';
export { once } from './once';
export { throttle } from './throttle';
export { debounce } from './debounce.js';
export { once } from './once.js';
export { throttle } from './throttle.js';

@@ -1,36 +0,41 @@

'use strict';
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
Object.defineProperty(exports, '__esModule', { value: true });
// src/function/index.ts
var function_exports = {};
__export(function_exports, {
debounce: () => debounce,
once: () => once,
throttle: () => throttle
});
module.exports = __toCommonJS(function_exports);
/**
* Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds
* have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`
* method to cancel any pending execution.
*
* @param {() => void} func - The function to debounce.
* @param {number} debounceMs - The number of milliseconds to delay.
* @returns {{ (): void; cancel: () => void }} A new debounced function with a `cancel` method.
*
* @example
* const debouncedFunction = debounce(() => {
* console.log('Function executed');
* }, 1000);
*
* // Will log 'Function executed' after 1 second if not called again in that time
* debouncedFunction();
*
* // Will not log anything as the previous call is canceled
* debouncedFunction.cancel();
*/
// src/function/debounce.ts
function debounce(func, debounceMs) {
var timeoutId = null;
var debounced = function debounced() {
let timeoutId = null;
const debounced = function() {
if (timeoutId != null) {
clearTimeout(timeoutId);
}
timeoutId = setTimeout(function () {
timeoutId = setTimeout(() => {
func();
}, debounceMs);
};
debounced.cancel = function () {
debounced.cancel = function() {
if (timeoutId != null) {

@@ -43,26 +48,11 @@ clearTimeout(timeoutId);

/**
* Creates a function that is restricted to invoking the provided function `func` once.
* Repeated calls to the function will return the value from the first invocation.
*
* @param {F} func - The function to restrict.
* @returns {F} A new function that invokes `func` once and caches the result.
*
* @example
* const initialize = once(() => {
* console.log('Initialized!');
* return true;
* });
*
* initialize(); // Logs: 'Initialized!' and returns true
* initialize(); // Returns true without logging
*/
// src/function/once.ts
function once(func) {
var called = false;
var cache;
return function () {
let called = false;
let cache;
return function() {
if (called) {
return cache;
}
var result = func();
const result = func();
called = true;

@@ -74,31 +64,7 @@ cache = result;

/**
* Creates a throttled function that only invokes the provided function at most once
* per every `throttleMs` milliseconds. Subsequent calls to the throttled function
* within the wait time will not trigger the execution of the original function.
*
* @param {() => void} func - The function to throttle.
* @param {number} throttleMs - The number of milliseconds to throttle executions to.
* @returns {() => void} A new throttled function.
*
* @example
* const throttledFunction = throttle(() => {
* console.log('Function executed');
* }, 1000);
*
* // Will log 'Function executed' immediately
* throttledFunction();
*
* // Will not log anything as it is within the throttle time
* throttledFunction();
*
* // After 1 second
* setTimeout(() => {
* throttledFunction(); // Will log 'Function executed'
* }, 1000);
*/
// src/function/throttle.ts
function throttle(func, throttleMs) {
var lastCallTime;
var throttledFunction = function throttledFunction() {
var now = Date.now();
let lastCallTime;
const throttledFunction = function() {
const now = Date.now();
if (lastCallTime == null || now - lastCallTime >= throttleMs) {

@@ -111,5 +77,8 @@ lastCallTime = now;

}
exports.debounce = debounce;
exports.once = once;
exports.throttle = throttle;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
debounce,
once,
throttle
});
//# sourceMappingURL=index.js.map

@@ -17,2 +17,4 @@ /**

*/
export declare function once<F extends () => any>(func: F): F;
declare function once<F extends () => any>(func: F): F;
export { once };

@@ -26,2 +26,4 @@ /**

*/
export declare function throttle(func: () => void, throttleMs: number): () => void;
declare function throttle(func: () => void, throttleMs: number): () => void;
export { throttle };

@@ -1,6 +0,45 @@

export * from './array';
export * from './function';
export * from './math';
export * from './object';
export * from './predicate';
export * from './promise';
export { chunk } from './array/chunk.js';
export { difference } from './array/difference.js';
export { differenceBy } from './array/differenceBy.js';
export { differenceWith } from './array/differenceWith.js';
export { drop } from './array/drop.js';
export { dropRight } from './array/dropRight.js';
export { dropRightWhile } from './array/dropRightWhile.js';
export { dropWhile } from './array/dropWhile.js';
export { groupBy } from './array/groupBy.js';
export { intersection } from './array/intersection.js';
export { intersectionBy } from './array/intersectionBy.js';
export { intersectionWith } from './array/intersectionWith.js';
export { partition } from './array/partition.js';
export { sample } from './array/sample.js';
export { shuffle } from './array/shuffle.js';
export { take } from './array/take.js';
export { takeRight } from './array/takeRight.js';
export { takeRightWhile } from './array/takeRightWhile.js';
export { takeWhile } from './array/takeWhile.js';
export { union } from './array/union.js';
export { unionBy } from './array/unionBy.js';
export { unionWith } from './array/unionWith.js';
export { uniq } from './array/uniq.js';
export { uniqBy } from './array/uniqBy.js';
export { uniqWith } from './array/uniqWith.js';
export { xor } from './array/xor.js';
export { xorBy } from './array/xorBy.js';
export { xorWith } from './array/xorWith.js';
export { zip } from './array/zip.js';
export { zipWith } from './array/zipWith.js';
export { debounce } from './function/debounce.js';
export { once } from './function/once.js';
export { throttle } from './function/throttle.js';
export { clamp } from './math/clamp.js';
export { round } from './math/round.js';
export { sum } from './math/sum.js';
export { omit } from './object/omit.js';
export { omitBy } from './object/omitBy.js';
export { pick } from './object/pick.js';
export { pickBy } from './object/pickBy.js';
export { isNil } from './predicate/isNil.js';
export { isNotNil } from './predicate/isNotNil.js';
export { isNull } from './predicate/isNull.js';
export { isUndefined } from './predicate/isUndefined.js';
export { delay } from './promise/delay.js';

@@ -1,37 +0,95 @@

'use strict';
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
Object.defineProperty(exports, '__esModule', { value: true });
// src/index.ts
var src_exports = {};
__export(src_exports, {
chunk: () => chunk,
clamp: () => clamp,
debounce: () => debounce,
delay: () => delay,
difference: () => difference,
differenceBy: () => differenceBy,
differenceWith: () => differenceWith,
drop: () => drop,
dropRight: () => dropRight,
dropRightWhile: () => dropRightWhile,
dropWhile: () => dropWhile,
groupBy: () => groupBy,
intersection: () => intersection,
intersectionBy: () => intersectionBy,
intersectionWith: () => intersectionWith,
isNil: () => isNil,
isNotNil: () => isNotNil,
isNull: () => isNull,
isUndefined: () => isUndefined,
omit: () => omit,
omitBy: () => omitBy,
once: () => once,
partition: () => partition,
pick: () => pick,
pickBy: () => pickBy,
round: () => round,
sample: () => sample,
shuffle: () => shuffle,
sum: () => sum,
take: () => take,
takeRight: () => takeRight,
takeRightWhile: () => takeRightWhile,
takeWhile: () => takeWhile,
throttle: () => throttle,
union: () => union,
unionBy: () => unionBy,
unionWith: () => unionWith,
uniq: () => uniq,
uniqBy: () => uniqBy,
uniqWith: () => uniqWith,
xor: () => xor,
xorBy: () => xorBy,
xorWith: () => xorWith,
zip: () => zip,
zipWith: () => zipWith
});
module.exports = __toCommonJS(src_exports);
/**
* 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 {T[]} arr - The array to be chunked into smaller arrays.
* @param {number} size - The size of each smaller array. Must be a positive integer.
* @returns {T[][]} A two-dimensional array where each sub-array has a maximum length of `size`.
* @throws {Error} Throws an error if `size` is not a positive integer.
*
* @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']]
*/
// src/array/chunk.ts
function chunk(arr, size) {
if (!Number.isInteger(size) || size <= 0) {
throw new Error('Size must be an integer greater than zero.');
throw new Error("Size must be an integer greater than zero.");
}
var chunkLength = Math.ceil(arr.length / size);
var result = Array(chunkLength);
for (var index = 0; index < chunkLength; index++) {
var start = index * size;
var end = start + size;
const chunkLength = Math.ceil(arr.length / size);
const result = Array(chunkLength);
for (let index = 0; index < chunkLength; index++) {
const start = index * size;
const end = start + size;
result[index] = arr.slice(start, end);

@@ -42,26 +100,5 @@ }

/**
* Computes the difference between two arrays.
*
* This function takes two arrays and returns a new array containing the elements
* that are present in the first array but not in the second array. It effectively
* filters out any elements from the first array that also appear in the second array.
*
* @template T
* @param {T[]} firstArr - The array from which to derive the difference. This is the primary array
* from which elements will be compared and filtered.
* @param {T[]} secondArr - The array containing elements to be excluded from the first array.
* Each element in this array will be checked against the first array, and if a match is found,
* that element will be excluded from the result.
* @returns {T[]} A new array containing the elements that are present in the first array but not
* in the second array.
*
* @example
* * const array1 = [1, 2, 3, 4, 5];
* const array2 = [2, 4];
* const result = difference(array1, array2);
* // result will be [1, 3, 5] since 2 and 4 are in both arrays and are excluded from the result.
*/
// src/array/difference.ts
function difference(firstArr, secondArr) {
return firstArr.filter(function (item) {
return firstArr.filter((item) => {
return !secondArr.includes(item);

@@ -71,32 +108,6 @@ });

/**
* Computes the difference between two arrays after mapping their elements through a provided function.
*
* This function takes two arrays and a mapper function. It returns a new array containing the elements
* that are present in the first array but not in the second array, based on the identity calculated
* by the mapper function.
*
* Essentially, it filters out any elements from the first array that, when
* mapped, match an element in the mapped version of the second array.
*
* @template T, U
* @param {T[]} firstArr - The primary array from which to derive the difference.
* @param {T[]} secondArr - The array containing elements to be excluded from the first array.
* @param {(value: T) => U} mapper - The function to map the elements of both arrays. This function
* is applied to each element in both arrays, and the comparison is made based on the mapped values.
* @returns {T[]} A new array containing the elements from the first array that do not have a corresponding
* mapped identity in the second array.
*
* @example
* * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const array2 = [{ id: 2 }, { id: 4 }];
* const mapper = item => item.id;
* const result = differenceBy(array1, array2, mapper);
* // result will be [{ id: 1 }, { id: 3 }] since the elements with id 2 are in both arrays and are excluded from the result.
*/
// src/array/differenceBy.ts
function differenceBy(firstArr, secondArr, mapper) {
var mappedSecondArr = secondArr.map(function (item) {
return mapper(item);
});
return firstArr.filter(function (item) {
const mappedSecondArr = secondArr.map((item) => mapper(item));
return firstArr.filter((item) => {
return !mappedSecondArr.includes(mapper(item));

@@ -106,26 +117,6 @@ });

/**
* Computes the difference between two arrays based on a custom equality function.
*
* This function takes two arrays and a custom comparison function. It returns a new array containing
* the elements that are present in the first array but not in the second array. The comparison to determine
* if elements are equal is made using the provided custom function.
*
* @template T
* @param {T[]} firstArr - The array from which to get the difference.
* @param {T[]} secondArr - The array containing elements to exclude from the first array.
* @param {(x: T, y: T) => boolean} areItemsEqual - A function to determine if two items are equal.
* @returns {T[]} A new array containing the elements from the first array that do not match any elements in the second array
* according to the custom equality function.
*
* @example
* * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const array2 = [{ id: 2 }, { id: 4 }];
* const areItemsEqual = (a, b) => a.id === b.id;
* const result = differenceWith(array1, array2, areItemsEqual);
* // result will be [{ id: 1 }, { id: 3 }] since the elements with id 2 are considered equal and are excluded from the result.
*/
// src/array/differenceWith.ts
function differenceWith(firstArr, secondArr, areItemsEqual) {
return firstArr.filter(function (firstItem) {
return secondArr.every(function (secondItem) {
return firstArr.filter((firstItem) => {
return secondArr.every((secondItem) => {
return !areItemsEqual(firstItem, secondItem);

@@ -136,17 +127,3 @@ });

/**
* 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.
*
* @param {T[]} arr - The array from which to drop elements.
* @param {number} itemsCount - The number of elements to drop from the beginning of the array.
* @returns {T[]} 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.
*/
// src/array/drop.ts
function drop(arr, itemsCount) {

@@ -156,17 +133,3 @@ return arr.slice(itemsCount);

/**
* 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.
*
* @param {T[]} arr - The array from which to drop elements.
* @param {number} itemsCount - The number of elements to drop from the end of the array.
* @returns {T[]} 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.
*/
// src/array/dropRight.ts
function dropRight(arr, itemsCount) {

@@ -176,258 +139,24 @@ return arr.slice(0, -itemsCount);

/**
* Removes elements from the beginning of an array until the predicate returns false.
*
* This function iterates over an array and drops elements from the start until the provided
* predicate function returns false. It then returns a new array with the remaining elements.
*
* @param {T[]} arr - The array from which to drop elements.
* @param {(item: T) => boolean} canContinueDropping - A predicate function that determines
* whether to continue dropping elements. The function is called with each element, and dropping
* continues as long as it returns true.
* @returns {T[]} A new array with the elements remaining after the predicate returns false.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = dropWhile(array, x => x < 3);
* // result will be [3, 4, 5] since elements less than 3 are dropped.
*/
// src/array/dropWhile.ts
function dropWhile(arr, canContinueDropping) {
var dropEndIndex = arr.findIndex(function (item) {
return !canContinueDropping(item);
});
const dropEndIndex = arr.findIndex((item) => !canContinueDropping(item));
return arr.slice(dropEndIndex);
}
/**
* Removes elements from the end of an array until the predicate returns false.
*
* This function iterates over an array from the end and drops elements until the provided
* predicate function returns false. It then returns a new array with the remaining elements.
*
* @param {T[]} arr - The array from which to drop elements.
* @param {function(item: T): boolean} canContinueDropping - A predicate function that determines
* whether to continue dropping elements. The function is called with each element from the end,
* and dropping continues as long as it returns true.
* @returns {T[]} A new array with the elements remaining after the predicate returns false.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const result = dropRightWhile(array, x => x > 3);
* // result will be [1, 2, 3] since elements greater than 3 are dropped from the end.
*/
// src/array/dropRightWhile.ts
function dropRightWhile(arr, canContinueDropping) {
var reversed = arr.slice().reverse();
var dropped = dropWhile(reversed, canContinueDropping);
const reversed = arr.slice().reverse();
const dropped = dropWhile(reversed, canContinueDropping);
return dropped.slice().reverse();
}
function _iterableToArrayLimit(r, l) {
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (null != t) {
var e,
n,
i,
u,
a = [],
f = !0,
o = !1;
try {
if (i = (t = t.call(r)).next, 0 === l) {
if (Object(t) !== t) return;
f = !1;
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
} catch (r) {
o = !0, n = r;
} finally {
try {
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
} finally {
if (o) throw n;
}
}
return a;
}
}
function ownKeys(e, r) {
var t = Object.keys(e);
if (Object.getOwnPropertySymbols) {
var o = Object.getOwnPropertySymbols(e);
r && (o = o.filter(function (r) {
return Object.getOwnPropertyDescriptor(e, r).enumerable;
})), t.push.apply(t, o);
}
return t;
}
function _objectSpread2(e) {
for (var r = 1; r < arguments.length; r++) {
var t = null != arguments[r] ? arguments[r] : {};
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
_defineProperty(e, r, t[r]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
});
}
return e;
}
function _toPrimitive(t, r) {
if ("object" != typeof t || !t) return t;
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r || "default");
if ("object" != typeof i) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === r ? String : Number)(t);
}
function _toPropertyKey(t) {
var i = _toPrimitive(t, "string");
return "symbol" == typeof i ? i : i + "";
}
function _defineProperty(obj, key, value) {
key = _toPropertyKey(key);
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _createForOfIteratorHelper(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (!it) {
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;
var F = function () {};
return {
s: F,
n: function () {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
},
e: function (e) {
throw e;
},
f: F
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var normalCompletion = true,
didErr = false,
err;
return {
s: function () {
it = it.call(o);
},
n: function () {
var step = it.next();
normalCompletion = step.done;
return step;
},
e: function (e) {
didErr = true;
err = e;
},
f: function () {
try {
if (!normalCompletion && it.return != null) it.return();
} finally {
if (didErr) throw err;
}
}
};
}
/**
* Groups the elements of an array based on a provided key-generating function.
*
* This function takes an array and a function that generates a key from each element. It returns
* an object where the keys are the generated keys and the values are arrays of elements that share
* the same key.
*
* @param {T[]} arr - The array to group.
* @param {(item: T) => K} getKeyFromItem - A function that generates a key from an element.
* @returns {Record<K, T[]>} An object where each key is associated with an array of elements that
* share that key.
*
* @example
* const array = [
* { category: 'fruit', name: 'apple' },
* { category: 'fruit', name: 'banana' },
* { category: 'vegetable', name: 'carrot' }
* ];
* const result = groupBy(array, item => item.category);
* // result will be:
* // {
* // fruit: [
* // { category: 'fruit', name: 'apple' },
* // { category: 'fruit', name: 'banana' }
* // ],
* // vegetable: [
* // { category: 'vegetable', name: 'carrot' }
* // ]
* // }
*/
// src/array/groupBy.ts
function groupBy(arr, getKeyFromItem) {
var result = {};
var _iterator = _createForOfIteratorHelper(arr),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var item = _step.value;
var key = getKeyFromItem(item);
if (result[key] == null) {
result[key] = [];
}
result[key].push(item);
const result = {};
for (const item of arr) {
const key = getKeyFromItem(item);
if (result[key] == null) {
result[key] = [];
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
result[key].push(item);
}

@@ -437,21 +166,5 @@ return result;

/**
* Returns the intersection of two arrays.
*
* This function takes two arrays and returns a new array containing the elements that are
* present in both arrays. It effectively filters out any elements from the first array that
* are not found in the second array.
*
* @param {T[]} firstArr - The first array to compare.
* @param {T[]} secondArr - The second array to compare.
* @returns {T[]} A new array containing the elements that are present in both arrays.
*
* @example
* const array1 = [1, 2, 3, 4, 5];
* const array2 = [3, 4, 5, 6, 7];
* const result = intersection(array1, array2);
* // result will be [3, 4, 5] since these elements are in both arrays.
*/
// src/array/intersection.ts
function intersection(firstArr, secondArr) {
return firstArr.filter(function (item) {
return firstArr.filter((item) => {
return secondArr.includes(item);

@@ -461,27 +174,6 @@ });

/**
* Returns the intersection of two arrays based on a mapping function.
*
* This function takes two arrays and a mapping function. It returns a new array containing
* the elements from the first array that, when mapped using the provided function, have matching
* mapped elements in the second array. It effectively filters out any elements from the first array
* that do not have corresponding mapped values in the second array.
*
* @param {T[]} firstArr - The first array to compare.
* @param {T[]} secondArr - The second array to compare.
* @param {(item: T) => U} mapper - A function to map the elements of both arrays for comparison.
* @returns {T[]} A new array containing the elements from the first array that have corresponding mapped values in the second array.
*
* @example
* const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const array2 = [{ id: 2 }, { id: 4 }];
* const mapper = item => item.id;
* const result = intersectionBy(array1, array2, mapper);
* // result will be [{ id: 2 }] since only this element has a matching id in both arrays.
*/
// src/array/intersectionBy.ts
function intersectionBy(firstArr, secondArr, mapper) {
var mappedSecondArr = secondArr.map(function (x) {
return mapper(x);
});
return firstArr.filter(function (item) {
const mappedSecondArr = secondArr.map((x) => mapper(x));
return firstArr.filter((item) => {
return mappedSecondArr.includes(mapper(item));

@@ -491,26 +183,6 @@ });

/**
* Returns the intersection of two arrays based on a custom equality function.
*
* This function takes two arrays and a custom equality function. It returns a new array containing
* the elements from the first array that have matching elements in the second array, as determined
* by the custom equality function. It effectively filters out any elements from the first array that
* do not have corresponding matches in the second array according to the equality function.
*
* @param {T[]} firstArr - The first array to compare.
* @param {T[]} secondArr - The second array to compare.
* @param {(x: T, y: T) => boolean} areItemsEqual - A custom function to determine if two elements are equal.
* This function takes two arguments, one from each array, and returns `true` if the elements are considered equal, and `false` otherwise.
* @returns {T[]} A new array containing the elements from the first array that have corresponding matches in the second array according to the custom equality function.
*
* @example
* * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
* const array2 = [{ id: 2 }, { id: 4 }];
* const areItemsEqual = (a, b) => a.id === b.id;
* const result = intersectionWith(array1, array2, areItemsEqual);
* // result will be [{ id: 2 }] since this element has a matching id in both arrays.
*/
// src/array/intersectionWith.ts
function intersectionWith(firstArr, secondArr, areItemsEqual) {
return firstArr.filter(function (firstItem) {
return secondArr.some(function (secondItem) {
return firstArr.filter((firstItem) => {
return secondArr.some((secondItem) => {
return areItemsEqual(firstItem, secondItem);

@@ -521,41 +193,12 @@ });

/**
* Splits an array into two groups based on a predicate function.
*
* This function takes an array and a predicate function. It returns a tuple of two arrays:
* the first array contains elements for which the predicate function returns true, and
* the second array contains elements for which the predicate function returns false.
*
* @param {T[]} arr - The array to partition.
* @param {(value: T) => boolean} isInTruthy - A predicate function that determines
* whether an element should be placed in the truthy array. The function is called with each
* element of the array.
* @returns {[T[], T[]]} A tuple containing two arrays: the first array contains elements for
* which the predicate returned true, and the second array contains elements for which the
* predicate returned false.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const isEven = x => x % 2 === 0;
* const [even, odd] = partition(array, isEven);
* // even will be [2, 4], and odd will be [1, 3, 5]
*/
// src/array/partition.ts
function partition(arr, isInTruthy) {
var truthy = [];
var falsy = [];
var _iterator = _createForOfIteratorHelper(arr),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var item = _step.value;
if (isInTruthy(item)) {
truthy.push(item);
} else {
falsy.push(item);
}
const truthy = [];
const falsy = [];
for (const item of arr) {
if (isInTruthy(item)) {
truthy.push(item);
} else {
falsy.push(item);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}

@@ -565,42 +208,13 @@ return [truthy, falsy];

/**
* Returns a random element from an array.
*
* This function takes an array and returns a single element selected randomly from the array.
*
* @param {T[]} arr - The array to sample from.
* @returns {T} A random element from the array.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const randomElement = sample(array);
* // randomElement will be one of the elements from the array, selected randomly.
*/
// src/array/sample.ts
function sample(arr) {
var randomIndex = Math.floor(Math.random() * arr.length);
const randomIndex = Math.floor(Math.random() * arr.length);
return arr[randomIndex];
}
/**
* Randomizes the order of elements in an array using the Fisher-Yates algorithm.
*
* This function takes an array and returns a new array with its elements shuffled in a random order.
*
* @param {T[]} arr - The array to shuffle.
* @returns {T[]} A new array with its elements shuffled in random order.
*
* @example
* const array = [1, 2, 3, 4, 5];
* const shuffledArray = shuffle(array);
* // shuffledArray will be a new array with elements of array in random order, e.g., [3, 1, 4, 5, 2]
*/
// src/array/shuffle.ts
function shuffle(arr) {
/**
* https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm
*/
for (var i = arr.length - 1; i >= 1; i--) {
var j = Math.floor(Math.random() * (i + 1));
var _ref = [arr[j], arr[i]];
arr[i] = _ref[0];
arr[j] = _ref[1];
for (let i = arr.length - 1; i >= 1; i--) {
const j = Math.floor(Math.random() * (i + 1));
[arr[i], arr[j]] = [arr[j], arr[i]];
}

@@ -610,24 +224,3 @@ return arr;

/**
* Returns a new array containing the first `count` elements from the input array `arr`.
* If `count` is greater than the length of `arr`, the entire array is returned.
*
* @template T - Type of elements in the input array.
*
* @param {T[]} arr - The array to take elements from.
* @param {number} count - The number of elements to take.
* @returns {T[]} A new array containing the first `count` elements from `arr`.
*
* @example
* // Returns [1, 2, 3]
* take([1, 2, 3, 4, 5], 3);
*
* @example
* // Returns ['a', 'b']
* take(['a', 'b', 'c'], 2);
*
* @example
* // Returns [1, 2, 3]
* take([1, 2, 3], 5);
*/
// src/array/take.ts
function take(arr, count) {

@@ -637,22 +230,3 @@ return arr.slice(0, count);

/**
* Returns a new array containing the last `count` elements from the input array `arr`.
* If `count` is greater than the length of `arr`, the entire array is returned.
*
* @param {T[]} arr - The array to take elements from.
* @param {number} count - The number of elements to take.
* @returns {T[]} A new array containing the last `count` elements from `arr`.
*
* @example
* // Returns [4, 5]
* takeRight([1, 2, 3, 4, 5], 2);
*
* @example
* // Returns ['b', 'c']
* takeRight(['a', 'b', 'c'], 2);
*
* @example
* // Returns [1, 2, 3]
* takeRight([1, 2, 3], 5);
*/
// src/array/takeRight.ts
function takeRight(arr, count) {

@@ -665,21 +239,5 @@ if (count === 0) {

/**
* Takes elements from the end of the array while the predicate function returns `true`.
*
* @template T - Type of elements in the input array.
*
* @param {T[]} arr - The array to take elements from.
* @param {function(T): boolean} shouldContinueTaking - The function invoked per element.
* @returns {T[]} A new array containing the elements taken from the end while the predicate returns `true`.
*
* @example
* // Returns [3, 2, 1]
* takeRightWhile([5, 4, 3, 2, 1], n => n < 4);
*
* @example
* // Returns []
* takeRightWhile([1, 2, 3], n => n > 3);
*/
// src/array/takeRightWhile.ts
function takeRightWhile(arr, shouldContinueTaking) {
for (var i = arr.length - 1; i >= 0; i--) {
for (let i = arr.length - 1; i >= 0; i--) {
if (!shouldContinueTaking(arr[i])) {

@@ -692,36 +250,10 @@ return arr.slice(i + 1);

/**
* Returns a new array containing the leading elements of the provided array
* that satisfy the provided predicate function. It stops taking elements as soon
* as an element does not satisfy the predicate.
*
* @template T - The type of elements in the array.
* @param {T[]} arr - The array to process.
* @param {(element: T) => boolean} shouldContinueTaking - The predicate function that is called with each element. Elements are included in the result as long as this function returns true.
* @returns {T[]} A new array containing the leading elements that satisfy the predicate.
*
* @example
* // Returns [1, 2]
* takeWhile([1, 2, 3, 4], x => x < 3);
*
* @example
* // Returns []
* takeWhile([1, 2, 3, 4], x => x > 3);
*/
// src/array/takeWhile.ts
function takeWhile(arr, shouldContinueTaking) {
var result = [];
var _iterator = _createForOfIteratorHelper(arr),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var item = _step.value;
if (!shouldContinueTaking(item)) {
break;
}
result.push(item);
const result = [];
for (const item of arr) {
if (!shouldContinueTaking(item)) {
break;
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
result.push(item);
}

@@ -731,32 +263,10 @@ return result;

/**
* Creates a duplicate-free version of an array.
*
* This function takes an array and returns a new array containing only the unique values
* from the original array, preserving the order of first occurrence.
*
* @param {T[]} arr - The array to process.
* @returns {T[]} A new array with only unique values from the original array.
*
* @example
* * const array = [1, 2, 2, 3, 4, 4, 5];
* const result = uniq(array);
* // result will be [1, 2, 3, 4, 5]
*/
// src/array/uniq.ts
function uniq(arr) {
var result = [];
var _iterator = _createForOfIteratorHelper(arr),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var item = _step.value;
if (result.includes(item)) {
continue;
}
result.push(item);
const result = [];
for (const item of arr) {
if (result.includes(item)) {
continue;
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
result.push(item);
}

@@ -766,18 +276,3 @@ return result;

/**
* Creates an array of unique values from all given arrays.
*
* This function takes two arrays, merges them into a single array, and returns a new array
* containing only the unique values from the merged array.
*
* @param {T[]} arr1 - The first array to merge and filter for unique values.
* @param {T[]} arr2 - The second array to merge and filter for unique values.
* @returns {T[]} A new array of unique values.
*
* @example
* const array1 = [1, 2, 3];
* const array2 = [3, 4, 5];
* const result = union(array1, array2);
* // result will be [1, 2, 3, 4, 5]
*/
// src/array/union.ts
function union(arr1, arr2) {

@@ -787,27 +282,7 @@ return uniq(arr1.concat(arr2));

/**
* Creates an array of unique values, in order, from all given arrays using a provided mapping function to determine equality.
*
* @param {T[]} arr1 - The first array.
* @param {T[]} arr2 - The second array.
* @param {function(item: T): U} mapper - The function to map array elements to comparison values.
* @returns {T[]} A new array containing the union of unique elements from `arr1` and `arr2`, based on the values returned by the mapping function.
*
* @example
* // Custom mapping function for numbers (modulo comparison)
* const moduloMapper = (x) => x % 3;
* unionBy([1, 2, 3], [4, 5, 6], moduloMapper);
* // Returns [1, 2, 3]
*
* @example
* // Custom mapping function for objects with an 'id' property
* const idMapper = (obj) => obj.id;
* unionBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);
* // Returns [{ id: 1 }, { id: 2 }, { id: 3 }]
*/
// src/array/unionBy.ts
function unionBy(arr1, arr2, mapper) {
var map = new Map();
for (var _i = 0, _arr = [].concat(_toConsumableArray(arr1), _toConsumableArray(arr2)); _i < _arr.length; _i++) {
var item = _arr[_i];
var key = mapper(item);
const map = /* @__PURE__ */ new Map();
for (const item of [...arr1, ...arr2]) {
const key = mapper(item);
if (!map.has(key)) {

@@ -817,37 +292,13 @@ map.set(key, item);

}
return _toConsumableArray(map.values());
return [...map.values()];
}
/**
* The `uniqWith` function takes an array as its first argument and a 'comparator' function as the second.
*
* It evaluates the elements of the array using the comparator function, and if true is returned, it considers those elements as duplicates and removes them.
*
* @example
* ```ts
* uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => Math.abs(a - b) < 1);
* // [1, 2, 3, 5, 7]
* ```
*/
// src/array/uniqWith.ts
function uniqWith(arr, areItemsEqual) {
var result = [];
var _iterator = _createForOfIteratorHelper(arr),
_step;
try {
var _loop = function _loop() {
var item = _step.value;
var isUniq = result.every(function (v) {
return !areItemsEqual(v, item);
});
if (isUniq) {
result.push(item);
}
};
for (_iterator.s(); !(_step = _iterator.n()).done;) {
_loop();
const result = [];
for (const item of arr) {
const isUniq = result.every((v) => !areItemsEqual(v, item));
if (isUniq) {
result.push(item);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}

@@ -857,21 +308,3 @@ return result;

/**
* Creates an array of unique values from two given arrays based on a custom equality function.
*
* This function takes two arrays and a custom equality function, merges the arrays, and returns
* a new array containing only the unique values as determined by the custom equality function.
*
* @param {T[]} arr1 - The first array to merge and filter for unique values.
* @param {T[]} arr2 - The second array to merge and filter for unique values.
* @param {(item1: T, item2: T) => boolean} areItemsEqual - A custom function to determine if two elements are equal.
* It takes two arguments and returns `true` if the elements are considered equal, and `false` otherwise.
* @returns {T[]} A new array of unique values based on the custom equality function.
*
* @example
* const array1 = [{ id: 1 }, { id: 2 }];
* const array2 = [{ id: 2 }, { id: 3 }];
* const areItemsEqual = (a, b) => a.id === b.id;
* const result = unionWith(array1, array2, areItemsEqual);
* // result will be [{ id: 1 }, { id: 2 }, { id: 3 }] since { id: 2 } is considered equal in both arrays
*/
// src/array/unionWith.ts
function unionWith(arr1, arr2, areItemsEqual) {

@@ -881,35 +314,8 @@ return uniqWith(arr1.concat(arr2), areItemsEqual);

/**
* The `uniqBy` function takes an array as its first argument and a 'converter' function as the second. It maps the array elements using the converter function, then removes any duplicates.
*
* It filters out elements with the same value, meaning it does not check for duplicates in data types like Objects.
*
* @example
* ```ts
* uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);
* // [1.2, 2.1, 3.3, 5.7, 7.19]
* ```
*/
// src/array/uniqBy.ts
function uniqBy(arr, converter) {
return uniqWith(arr, function (item1, item2) {
return converter(item1) === converter(item2);
});
return uniqWith(arr, (item1, item2) => converter(item1) === converter(item2));
}
/**
* Computes the symmetric difference between two arrays. The symmetric difference is the set of elements
* which are in either of the arrays, but not in their intersection.
*
* @param {T[]} arr1 - The first array.
* @param {T[]} arr2 - The second array.
* @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both.
*
* @example
* // Returns [1, 2, 5, 6]
* xor([1, 2, 3, 4], [3, 4, 5, 6]);
*
* @example
* // Returns ['a', 'c']
* xor(['a', 'b'], ['b', 'c']);
*/
// src/array/xor.ts
function xor(arr1, arr2) {

@@ -919,94 +325,24 @@ return difference(union(arr1, arr2), intersection(arr1, arr2));

/**
* Computes the symmetric difference between two arrays using a custom mapping function.
* The symmetric difference is the set of elements which are in either of the arrays,
* but not in their intersection, determined by the result of the mapping function.
*
* @template T - Type of elements in the input arrays.
* @template U - Type of the values returned by the mapping function.
*
* @param {T[]} arr1 - The first array.
* @param {T[]} arr2 - The second array.
* @param {function(item: T): U} mapper - The function to map array elements to comparison values.
* @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both, based on the values returned by the mapping function.
*
* @example
* // Custom mapping function for objects with an 'id' property
* const idMapper = obj => obj.id;
* xorBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);
* // Returns [{ id: 1 }, { id: 3 }]
*/
// src/array/xorBy.ts
function xorBy(arr1, arr2, mapper) {
var union = unionBy(arr1, arr2, mapper);
var intersection = intersectionBy(arr1, arr2, mapper);
return differenceBy(union, intersection, mapper);
const union2 = unionBy(arr1, arr2, mapper);
const intersection2 = intersectionBy(arr1, arr2, mapper);
return differenceBy(union2, intersection2, mapper);
}
/**
* Computes the symmetric difference between two arrays using a custom equality function.
* The symmetric difference is the set of elements which are in either of the arrays,
* but not in their intersection.
*
* @template T - Type of elements in the input arrays.
*
* @param {T[]} arr1 - The first array.
* @param {T[]} arr2 - The second array.
* @param {(item1: T, item2: T) => boolean} areElementsEqual - The custom equality function to compare elements.
* @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both, based on the custom equality function.
*
* @example
* // Custom equality function for objects with an 'id' property
* const areObjectsEqual = (a, b) => a.id === b.id;
* xorWith([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], areObjectsEqual);
* // Returns [{ id: 1 }, { id: 3 }]
*/
// src/array/xorWith.ts
function xorWith(arr1, arr2, areElementsEqual) {
var union = unionWith(arr1, arr2, areElementsEqual);
var intersection = intersectionWith(arr1, arr2, areElementsEqual);
return differenceWith(union, intersection, areElementsEqual);
const union2 = unionWith(arr1, arr2, areElementsEqual);
const intersection2 = intersectionWith(arr1, arr2, areElementsEqual);
return differenceWith(union2, intersection2, areElementsEqual);
}
/**
* Combines multiple arrays into a single array of tuples.
*
* This function takes multiple arrays and returns a new array where each element is a tuple
* containing the corresponding elements from the input arrays. If the input arrays are of
* different lengths, the resulting array will have the length of the longest input array,
* with undefined values for missing elements.
*
* @param {...T[][]} arrs - The arrays to zip together.
* @returns {T[][]} A new array of tuples containing the corresponding elements from the input arrays.
*
* @example
* const arr1 = [1, 2, 3];
* const arr2 = ['a', 'b', 'c'];
* const result = zip(arr1, arr2);
* // result will be [[1, 'a'], [2, 'b'], [3, 'c']]
*
* const arr3 = [true, false];
* const result2 = zip(arr1, arr2, arr3);
* // result2 will be [[1, 'a', true], [2, 'b', false], [3, 'c', undefined]]
*/
function zip() {
var result = [];
for (var _len = arguments.length, arrs = new Array(_len), _key = 0; _key < _len; _key++) {
arrs[_key] = arguments[_key];
}
var maxIndex = Math.max.apply(Math, _toConsumableArray(arrs.map(function (x) {
return x.length;
})));
for (var i = 0; i < maxIndex; i++) {
var element = [];
var _iterator = _createForOfIteratorHelper(arrs),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var arr = _step.value;
element.push(arr[i]);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
// src/array/zip.ts
function zip(...arrs) {
const result = [];
const maxIndex = Math.max(...arrs.map((x) => x.length));
for (let i = 0; i < maxIndex; i++) {
const element = [];
for (const arr of arrs) {
element.push(arr[i]);
}

@@ -1018,84 +354,27 @@ result.push(element);

/**
* Combines multiple arrays into a single array using a custom combiner function.
*
* This function takes multiple arrays and a combiner function, and returns a new array where each element
* is the result of applying the combiner function to the corresponding elements of the input arrays.
*
* @param {T[]} arr1 - The first array to zip.
* @param {U[]} [arr2] - The second array to zip (optional).
* @param {V[]} [arr3] - The third array to zip (optional).
* @param {W[]} [arr4] - The fourth array to zip (optional).
* @param {function} combine - The combiner function that takes corresponding elements from each array and returns a single value.
* @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.
*
* @example
* // Example usage with two arrays:
* const arr1 = [1, 2, 3];
* const arr2 = [4, 5, 6];
* const result = zipWith(arr1, arr2, (a, b) => a + b);
* // result will be [5, 7, 9]
*
* @example
* // Example usage with three arrays:
* const arr1 = [1, 2];
* const arr2 = [3, 4];
* const arr3 = [5, 6];
* const result = zipWith(arr1, arr2, arr3, (a, b, c) => `${a}${b}${c}`);
* // result will be [`135`, `246`]
*/
function zipWith(arr1) {
for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
rest[_key - 1] = arguments[_key];
// src/array/zipWith.ts
function zipWith(arr1, ...rest) {
const arrs = [arr1, ...rest.slice(0, -1)];
const combine = rest[rest.length - 1];
const result = [];
const maxIndex = Math.max(...arrs.map((arr) => arr.length));
for (let i = 0; i < maxIndex; i++) {
const elements = arrs.map((arr) => arr[i]);
result.push(combine(...elements));
}
var arrs = [arr1].concat(_toConsumableArray(rest.slice(0, -1)));
var combine = rest[rest.length - 1];
var result = [];
var maxIndex = Math.max.apply(Math, _toConsumableArray(arrs.map(function (arr) {
return arr.length;
})));
var _loop = function _loop(i) {
var elements = arrs.map(function (arr) {
return arr[i];
});
result.push(combine.apply(void 0, _toConsumableArray(elements)));
};
for (var i = 0; i < maxIndex; i++) {
_loop(i);
}
return result;
}
/**
* Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds
* have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`
* method to cancel any pending execution.
*
* @param {() => void} func - The function to debounce.
* @param {number} debounceMs - The number of milliseconds to delay.
* @returns {{ (): void; cancel: () => void }} A new debounced function with a `cancel` method.
*
* @example
* const debouncedFunction = debounce(() => {
* console.log('Function executed');
* }, 1000);
*
* // Will log 'Function executed' after 1 second if not called again in that time
* debouncedFunction();
*
* // Will not log anything as the previous call is canceled
* debouncedFunction.cancel();
*/
// src/function/debounce.ts
function debounce(func, debounceMs) {
var timeoutId = null;
var debounced = function debounced() {
let timeoutId = null;
const debounced = function() {
if (timeoutId != null) {
clearTimeout(timeoutId);
}
timeoutId = setTimeout(function () {
timeoutId = setTimeout(() => {
func();
}, debounceMs);
};
debounced.cancel = function () {
debounced.cancel = function() {
if (timeoutId != null) {

@@ -1108,26 +387,11 @@ clearTimeout(timeoutId);

/**
* Creates a function that is restricted to invoking the provided function `func` once.
* Repeated calls to the function will return the value from the first invocation.
*
* @param {F} func - The function to restrict.
* @returns {F} A new function that invokes `func` once and caches the result.
*
* @example
* const initialize = once(() => {
* console.log('Initialized!');
* return true;
* });
*
* initialize(); // Logs: 'Initialized!' and returns true
* initialize(); // Returns true without logging
*/
// src/function/once.ts
function once(func) {
var called = false;
var cache;
return function () {
let called = false;
let cache;
return function() {
if (called) {
return cache;
}
var result = func();
const result = func();
called = true;

@@ -1139,31 +403,7 @@ cache = result;

/**
* Creates a throttled function that only invokes the provided function at most once
* per every `throttleMs` milliseconds. Subsequent calls to the throttled function
* within the wait time will not trigger the execution of the original function.
*
* @param {() => void} func - The function to throttle.
* @param {number} throttleMs - The number of milliseconds to throttle executions to.
* @returns {() => void} A new throttled function.
*
* @example
* const throttledFunction = throttle(() => {
* console.log('Function executed');
* }, 1000);
*
* // Will log 'Function executed' immediately
* throttledFunction();
*
* // Will not log anything as it is within the throttle time
* throttledFunction();
*
* // After 1 second
* setTimeout(() => {
* throttledFunction(); // Will log 'Function executed'
* }, 1000);
*/
// src/function/throttle.ts
function throttle(func, throttleMs) {
var lastCallTime;
var throttledFunction = function throttledFunction() {
var now = Date.now();
let lastCallTime;
const throttledFunction = function() {
const now = Date.now();
if (lastCallTime == null || now - lastCallTime >= throttleMs) {

@@ -1177,20 +417,3 @@ lastCallTime = now;

/**
* Clamps a number within the inclusive lower and upper bounds.
*
* This function takes a number and two bounds, and returns the number clamped within the specified bounds.
* If only one bound is provided, it returns the minimum of the value and the bound.
*
* @param {number} value - The number to clamp.
* @param {number} minimum - The minimum bound to clamp the number.
* @param {number} maximum - The maximum bound to clamp the number.
* @returns {number} The clamped number within the specified bounds.
*
* @example
* * const result1 = clamp(10, 5); // result1 will be 5, as 10 is clamped to the bound 5
* const result2 = clamp(10, 5, 15); // result2 will be 10, as it is within the bounds 5 and 15
* const result3 = clamp(2, 5, 15); // result3 will be 5, as 2 is clamped to the lower bound 5
* const result4 = clamp(20, 5, 15); // result4 will be 15, as 20 is clamped to the upper bound 15
*/
// src/math/clamp.ts
function clamp(value, bound1, bound2) {

@@ -1203,49 +426,13 @@ if (bound2 == null) {

/**
* Rounds a number to a specified precision.
*
* This function takes a number and an optional precision value, and returns the number rounded
* to the specified number of decimal places.
*
* @param {number} value - The number to round.
* @param {number} [precision=0] - The number of decimal places to round to. Defaults to 0.
* @returns {number} The rounded number.
*
* @example
* * const result1 = round(1.2345); // result1 will be 1
* const result2 = round(1.2345, 2); // result2 will be 1.23
* const result3 = round(1.2345, 3); // result3 will be 1.235
*/
function round(value) {
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var multiplier = Math.pow(10, precision);
// src/math/round.ts
function round(value, precision = 0) {
const multiplier = Math.pow(10, precision);
return Math.round(value * multiplier) / multiplier;
}
/**
* Calculates the sum of an array of numbers.
*
* This function takes an array of numbers and returns the sum of all the elements in the array.
*
* @param {number[]} nums - An array of numbers to be summed.
* @returns {number} The sum of all the numbers in the array.
*
* @example
* * const numbers = [1, 2, 3, 4, 5];
* const result = sum(numbers);
* // result will be 15
*/
// src/math/sum.ts
function sum(nums) {
var result = 0;
var _iterator = _createForOfIteratorHelper(nums),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var num = _step.value;
result += num;
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
let result = 0;
for (const num of nums) {
result += num;
}

@@ -1255,30 +442,7 @@ return result;

/**
* Creates a new object with specified keys omitted.
*
* This function takes an object and an array of keys, and returns a new object that
* excludes the properties corresponding to the specified keys.
*
* @param {T} obj - The object to omit keys from.
* @param {K[]} keys - An array of keys to be omitted from the object.
* @returns {Omit<T, K>} A new object with the specified keys omitted.
*
* @example
* * const obj = { a: 1, b: 2, c: 3 };
* const result = omit(obj, ['b', 'c']);
* // result will be { a: 1 }
*/
// src/object/omit.ts
function omit(obj, keys) {
var result = _objectSpread2({}, obj);
var _iterator = _createForOfIteratorHelper(keys),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var key = _step.value;
delete result[key];
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
const result = __spreadValues({}, obj);
for (const key of keys) {
delete result[key];
}

@@ -1288,26 +452,6 @@ return result;

/**
* Creates a new object composed of the properties that do not satisfy the predicate function.
*
* This function takes an object and a predicate function, and returns a new object that
* includes only the properties for which the predicate function returns false.
*
* @param {T} obj - The object to omit properties from.
* @param {(value: T[string], key: string) => boolean} shouldOmit - A predicate function that determines
* whether a property should be omitted. It takes the property's key and value as arguments and returns `true`
* if the property should be omitted, and `false` otherwise.
* @returns {Partial<T>} A new object with the properties that do not satisfy the predicate function.
*
* @example
* const obj = { a: 1, b: 'omit', c: 3 };
* const shouldOmit = (key, value) => typeof value === 'string';
* const result = omitBy(obj, shouldOmit);
* // result will be { a: 1, c: 3 }
*/
// src/object/omitBy.ts
function omitBy(obj, shouldOmit) {
var result = {};
for (var _i = 0, _Object$entries = Object.entries(obj); _i < _Object$entries.length; _i++) {
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
key = _Object$entries$_i[0],
value = _Object$entries$_i[1];
const result = {};
for (const [key, value] of Object.entries(obj)) {
if (shouldOmit(value, key)) {

@@ -1321,30 +465,7 @@ continue;

/**
* Creates a new object composed of the picked object properties.
*
* This function takes an object and an array of keys, and returns a new object that
* includes only the properties corresponding to the specified keys.
*
* @param {T} obj - The object to pick keys from.
* @param {K[]} keys - An array of keys to be picked from the object.
* @returns {Pick<T, K>} A new object with the specified keys picked.
*
* @example
* * const obj = { a: 1, b: 2, c: 3 };
* const result = pick(obj, ['a', 'c']);
* // result will be { a: 1, c: 3 }
*/
// src/object/pick.ts
function pick(obj, keys) {
var result = {};
var _iterator = _createForOfIteratorHelper(keys),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var key = _step.value;
result[key] = obj[key];
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
const result = {};
for (const key of keys) {
result[key] = obj[key];
}

@@ -1354,26 +475,6 @@ return result;

/**
* Creates a new object composed of the properties that satisfy the predicate function.
*
* This function takes an object and a predicate function, and returns a new object that
* includes only the properties for which the predicate function returns true.
*
* @param {T} obj - The object to pick properties from.
* @param {(value: T[keyof T], key: string) => boolean} shouldPick - A predicate function that determines
* whether a property should be picked. It takes the property's key and value as arguments and returns `true`
* if the property should be picked, and `false` otherwise.
* @returns {Partial<T>} A new object with the properties that satisfy the predicate function.
*
* @example
* const obj = { a: 1, b: 'pick', c: 3 };
* const shouldPick = (value) => typeof value === 'string';
* const result = pickBy(obj, shouldPick);
* // result will be { b: 'pick' }
*/
// src/object/pickBy.ts
function pickBy(obj, shouldPick) {
var result = {};
for (var _i = 0, _Object$entries = Object.entries(obj); _i < _Object$entries.length; _i++) {
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
key = _Object$entries$_i[0],
value = _Object$entries$_i[1];
const result = {};
for (const [key, value] of Object.entries(obj)) {
if (!shouldPick(value, key)) {

@@ -1387,64 +488,13 @@ continue;

/**
* Checks if a given value is null or undefined.
*
* This function tests whether the provided value is either `null` or `undefined`.
* It returns `true` if the value is `null` or `undefined`, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`.
*
* @param {unknown} x - The value to test for null or undefined.
* @returns {boolean} `true` if the value is null or undefined, `false` otherwise.
*
* @example
* * const value1 = null;
* const value2 = undefined;
* const value3 = 42;
* const result1 = isNil(value1); // true
* const result2 = isNil(value2); // true
* const result3 = isNil(value3); // false
*/
// src/predicate/isNil.ts
function isNil(x) {
return x == null || x == undefined;
return x == null || x == void 0;
}
/**
* Checks if the given value is not null nor undefined.
*
* The main use of this function is to be used with TypeScript as a type predicate.
*
* @param {T | null | undefined} x - The value to test if it is not null nor undefined.
* @returns {x is T} True if the value is not null nor undefined, false otherwise.
*
* @example
* // Here the type of `arr` is (number | undefined)[]
* const arr = [1, undefined, 3];
* // Here the type of `result` is number[]
* const result = arr.filter(isNotNil);
* // result will be [1, 3]
*/
// src/predicate/isNotNil.ts
function isNotNil(x) {
return x != null && x != undefined;
return x != null && x != void 0;
}
/**
* Checks if the given value is null.
*
* This function tests whether the provided value is strictly equal to `null`.
* It returns `true` if the value is `null`, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null`.
*
* @param {unknown} x - The value to test if it is null.
* @returns {x is null} True if the value is null, false otherwise.
*
* @example
* * const value1 = null;
* const value2 = undefined;
* const value3 = 42;
*
* console.log(isNull(value1)); // true
* console.log(isNull(value2)); // false
* console.log(isNull(value3)); // false
*/
// src/predicate/isNull.ts
function isNull(x) {

@@ -1454,94 +504,61 @@ return x === null;

/**
* Checks if the given value is undefined.
*
* This function tests whether the provided value is strictly equal to `undefined`.
* It returns `true` if the value is `undefined`, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `undefined`.
*
* @param {unknown} x - The value to test if it is undefined.
* @returns {x is undefined} true if the value is undefined, false otherwise.
*
* @example
* * const value1 = undefined;
* const value2 = null;
* const value3 = 42;
*
* console.log(isUndefined(value1)); // true
* console.log(isUndefined(value2)); // false
* console.log(isUndefined(value3)); // false
*/
// src/predicate/isUndefined.ts
function isUndefined(x) {
return x === undefined;
return x === void 0;
}
/**
* Delays the execution of code for a specified number of milliseconds.
*
* This function returns a Promise that resolves after the specified delay, allowing you to use it
* with async/await to pause execution.
*
* @param {number} ms - The number of milliseconds to delay.
* @returns {Promise<void>} A Promise that resolves after the specified delay.
*
* @example
* async function foo() {
* console.log('Start');
* await delay(1000); // Delays execution for 1 second
* console.log('End');
* }
*
* foo();
*/
// src/promise/delay.ts
function delay(ms) {
return new Promise(function (resolve) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
exports.chunk = chunk;
exports.clamp = clamp;
exports.debounce = debounce;
exports.delay = delay;
exports.difference = difference;
exports.differenceBy = differenceBy;
exports.differenceWith = differenceWith;
exports.drop = drop;
exports.dropRight = dropRight;
exports.dropRightWhile = dropRightWhile;
exports.dropWhile = dropWhile;
exports.groupBy = groupBy;
exports.intersection = intersection;
exports.intersectionBy = intersectionBy;
exports.intersectionWith = intersectionWith;
exports.isNil = isNil;
exports.isNotNil = isNotNil;
exports.isNull = isNull;
exports.isUndefined = isUndefined;
exports.omit = omit;
exports.omitBy = omitBy;
exports.once = once;
exports.partition = partition;
exports.pick = pick;
exports.pickBy = pickBy;
exports.round = round;
exports.sample = sample;
exports.shuffle = shuffle;
exports.sum = sum;
exports.take = take;
exports.takeRight = takeRight;
exports.takeRightWhile = takeRightWhile;
exports.takeWhile = takeWhile;
exports.throttle = throttle;
exports.union = union;
exports.unionBy = unionBy;
exports.unionWith = unionWith;
exports.uniq = uniq;
exports.uniqBy = uniqBy;
exports.uniqWith = uniqWith;
exports.xor = xor;
exports.xorBy = xorBy;
exports.xorWith = xorWith;
exports.zip = zip;
exports.zipWith = zipWith;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
chunk,
clamp,
debounce,
delay,
difference,
differenceBy,
differenceWith,
drop,
dropRight,
dropRightWhile,
dropWhile,
groupBy,
intersection,
intersectionBy,
intersectionWith,
isNil,
isNotNil,
isNull,
isUndefined,
omit,
omitBy,
once,
partition,
pick,
pickBy,
round,
sample,
shuffle,
sum,
take,
takeRight,
takeRightWhile,
takeWhile,
throttle,
union,
unionBy,
unionWith,
uniq,
uniqBy,
uniqWith,
xor,
xorBy,
xorWith,
zip,
zipWith
});
//# sourceMappingURL=index.js.map

@@ -18,3 +18,5 @@ /**

*/
export declare function clamp(value: number, maximum: number): number;
export declare function clamp(value: number, minimum: number, maximum: number): number;
declare function clamp(value: number, maximum: number): number;
declare function clamp(value: number, minimum: number, maximum: number): number;
export { clamp };

@@ -1,3 +0,3 @@

export { clamp } from './clamp';
export { round } from './round';
export { sum } from './sum';
export { clamp } from './clamp.js';
export { round } from './round.js';
export { sum } from './sum.js';

@@ -1,23 +0,30 @@

'use strict';
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
Object.defineProperty(exports, '__esModule', { value: true });
// src/math/index.ts
var math_exports = {};
__export(math_exports, {
clamp: () => clamp,
round: () => round,
sum: () => sum
});
module.exports = __toCommonJS(math_exports);
/**
* Clamps a number within the inclusive lower and upper bounds.
*
* This function takes a number and two bounds, and returns the number clamped within the specified bounds.
* If only one bound is provided, it returns the minimum of the value and the bound.
*
* @param {number} value - The number to clamp.
* @param {number} minimum - The minimum bound to clamp the number.
* @param {number} maximum - The maximum bound to clamp the number.
* @returns {number} The clamped number within the specified bounds.
*
* @example
* * const result1 = clamp(10, 5); // result1 will be 5, as 10 is clamped to the bound 5
* const result2 = clamp(10, 5, 15); // result2 will be 10, as it is within the bounds 5 and 15
* const result3 = clamp(2, 5, 15); // result3 will be 5, as 2 is clamped to the lower bound 5
* const result4 = clamp(20, 5, 15); // result4 will be 15, as 20 is clamped to the upper bound 15
*/
// src/math/clamp.ts
function clamp(value, bound1, bound2) {

@@ -30,120 +37,22 @@ if (bound2 == null) {

/**
* Rounds a number to a specified precision.
*
* This function takes a number and an optional precision value, and returns the number rounded
* to the specified number of decimal places.
*
* @param {number} value - The number to round.
* @param {number} [precision=0] - The number of decimal places to round to. Defaults to 0.
* @returns {number} The rounded number.
*
* @example
* * const result1 = round(1.2345); // result1 will be 1
* const result2 = round(1.2345, 2); // result2 will be 1.23
* const result3 = round(1.2345, 3); // result3 will be 1.235
*/
function round(value) {
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var multiplier = Math.pow(10, precision);
// src/math/round.ts
function round(value, precision = 0) {
const multiplier = Math.pow(10, precision);
return Math.round(value * multiplier) / multiplier;
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _createForOfIteratorHelper(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (!it) {
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;
var F = function () {};
return {
s: F,
n: function () {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
},
e: function (e) {
throw e;
},
f: F
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var normalCompletion = true,
didErr = false,
err;
return {
s: function () {
it = it.call(o);
},
n: function () {
var step = it.next();
normalCompletion = step.done;
return step;
},
e: function (e) {
didErr = true;
err = e;
},
f: function () {
try {
if (!normalCompletion && it.return != null) it.return();
} finally {
if (didErr) throw err;
}
}
};
}
/**
* Calculates the sum of an array of numbers.
*
* This function takes an array of numbers and returns the sum of all the elements in the array.
*
* @param {number[]} nums - An array of numbers to be summed.
* @returns {number} The sum of all the numbers in the array.
*
* @example
* * const numbers = [1, 2, 3, 4, 5];
* const result = sum(numbers);
* // result will be 15
*/
// src/math/sum.ts
function sum(nums) {
var result = 0;
var _iterator = _createForOfIteratorHelper(nums),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var num = _step.value;
result += num;
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
let result = 0;
for (const num of nums) {
result += num;
}
return result;
}
exports.clamp = clamp;
exports.round = round;
exports.sum = sum;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
clamp,
round,
sum
});
//# sourceMappingURL=index.js.map

@@ -16,2 +16,4 @@ /**

*/
export declare function round(value: number, precision?: number): number;
declare function round(value: number, precision?: number): number;
export { round };

@@ -14,2 +14,4 @@ /**

*/
export declare function sum(nums: number[]): number;
declare function sum(nums: number[]): number;
export { sum };

@@ -1,4 +0,4 @@

export { omit } from './omit';
export { omitBy } from './omitBy';
export { pick } from './pick';
export { pickBy } from './pickBy';
export { omit } from './omit.js';
export { omitBy } from './omitBy.js';
export { pick } from './pick.js';
export { pickBy } from './pickBy.js';

@@ -1,183 +0,49 @@

'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function _iterableToArrayLimit(r, l) {
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (null != t) {
var e,
n,
i,
u,
a = [],
f = !0,
o = !1;
try {
if (i = (t = t.call(r)).next, 0 === l) {
if (Object(t) !== t) return;
f = !1;
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
} catch (r) {
o = !0, n = r;
} finally {
try {
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
} finally {
if (o) throw n;
}
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
return a;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
}
function ownKeys(e, r) {
var t = Object.keys(e);
if (Object.getOwnPropertySymbols) {
var o = Object.getOwnPropertySymbols(e);
r && (o = o.filter(function (r) {
return Object.getOwnPropertyDescriptor(e, r).enumerable;
})), t.push.apply(t, o);
}
return t;
}
function _objectSpread2(e) {
for (var r = 1; r < arguments.length; r++) {
var t = null != arguments[r] ? arguments[r] : {};
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
_defineProperty(e, r, t[r]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
});
}
return e;
}
function _toPrimitive(t, r) {
if ("object" != typeof t || !t) return t;
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r || "default");
if ("object" != typeof i) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === r ? String : Number)(t);
}
function _toPropertyKey(t) {
var i = _toPrimitive(t, "string");
return "symbol" == typeof i ? i : i + "";
}
function _defineProperty(obj, key, value) {
key = _toPropertyKey(key);
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _createForOfIteratorHelper(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (!it) {
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;
var F = function () {};
return {
s: F,
n: function () {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
},
e: function (e) {
throw e;
},
f: F
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var normalCompletion = true,
didErr = false,
err;
return {
s: function () {
it = it.call(o);
},
n: function () {
var step = it.next();
normalCompletion = step.done;
return step;
},
e: function (e) {
didErr = true;
err = e;
},
f: function () {
try {
if (!normalCompletion && it.return != null) it.return();
} finally {
if (didErr) throw err;
}
}
};
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
/**
* Creates a new object with specified keys omitted.
*
* This function takes an object and an array of keys, and returns a new object that
* excludes the properties corresponding to the specified keys.
*
* @param {T} obj - The object to omit keys from.
* @param {K[]} keys - An array of keys to be omitted from the object.
* @returns {Omit<T, K>} A new object with the specified keys omitted.
*
* @example
* * const obj = { a: 1, b: 2, c: 3 };
* const result = omit(obj, ['b', 'c']);
* // result will be { a: 1 }
*/
// src/object/index.ts
var object_exports = {};
__export(object_exports, {
omit: () => omit,
omitBy: () => omitBy,
pick: () => pick,
pickBy: () => pickBy
});
module.exports = __toCommonJS(object_exports);
// src/object/omit.ts
function omit(obj, keys) {
var result = _objectSpread2({}, obj);
var _iterator = _createForOfIteratorHelper(keys),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var key = _step.value;
delete result[key];
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
const result = __spreadValues({}, obj);
for (const key of keys) {
delete result[key];
}

@@ -187,26 +53,6 @@ return result;

/**
* Creates a new object composed of the properties that do not satisfy the predicate function.
*
* This function takes an object and a predicate function, and returns a new object that
* includes only the properties for which the predicate function returns false.
*
* @param {T} obj - The object to omit properties from.
* @param {(value: T[string], key: string) => boolean} shouldOmit - A predicate function that determines
* whether a property should be omitted. It takes the property's key and value as arguments and returns `true`
* if the property should be omitted, and `false` otherwise.
* @returns {Partial<T>} A new object with the properties that do not satisfy the predicate function.
*
* @example
* const obj = { a: 1, b: 'omit', c: 3 };
* const shouldOmit = (key, value) => typeof value === 'string';
* const result = omitBy(obj, shouldOmit);
* // result will be { a: 1, c: 3 }
*/
// src/object/omitBy.ts
function omitBy(obj, shouldOmit) {
var result = {};
for (var _i = 0, _Object$entries = Object.entries(obj); _i < _Object$entries.length; _i++) {
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
key = _Object$entries$_i[0],
value = _Object$entries$_i[1];
const result = {};
for (const [key, value] of Object.entries(obj)) {
if (shouldOmit(value, key)) {

@@ -220,30 +66,7 @@ continue;

/**
* Creates a new object composed of the picked object properties.
*
* This function takes an object and an array of keys, and returns a new object that
* includes only the properties corresponding to the specified keys.
*
* @param {T} obj - The object to pick keys from.
* @param {K[]} keys - An array of keys to be picked from the object.
* @returns {Pick<T, K>} A new object with the specified keys picked.
*
* @example
* * const obj = { a: 1, b: 2, c: 3 };
* const result = pick(obj, ['a', 'c']);
* // result will be { a: 1, c: 3 }
*/
// src/object/pick.ts
function pick(obj, keys) {
var result = {};
var _iterator = _createForOfIteratorHelper(keys),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var key = _step.value;
result[key] = obj[key];
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
const result = {};
for (const key of keys) {
result[key] = obj[key];
}

@@ -253,26 +76,6 @@ return result;

/**
* Creates a new object composed of the properties that satisfy the predicate function.
*
* This function takes an object and a predicate function, and returns a new object that
* includes only the properties for which the predicate function returns true.
*
* @param {T} obj - The object to pick properties from.
* @param {(value: T[keyof T], key: string) => boolean} shouldPick - A predicate function that determines
* whether a property should be picked. It takes the property's key and value as arguments and returns `true`
* if the property should be picked, and `false` otherwise.
* @returns {Partial<T>} A new object with the properties that satisfy the predicate function.
*
* @example
* const obj = { a: 1, b: 'pick', c: 3 };
* const shouldPick = (value) => typeof value === 'string';
* const result = pickBy(obj, shouldPick);
* // result will be { b: 'pick' }
*/
// src/object/pickBy.ts
function pickBy(obj, shouldPick) {
var result = {};
for (var _i = 0, _Object$entries = Object.entries(obj); _i < _Object$entries.length; _i++) {
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
key = _Object$entries$_i[0],
value = _Object$entries$_i[1];
const result = {};
for (const [key, value] of Object.entries(obj)) {
if (!shouldPick(value, key)) {

@@ -285,6 +88,9 @@ continue;

}
exports.omit = omit;
exports.omitBy = omitBy;
exports.pick = pick;
exports.pickBy = pickBy;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
omit,
omitBy,
pick,
pickBy
});
//# sourceMappingURL=index.js.map

@@ -16,2 +16,4 @@ /**

*/
export declare function omit<T, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
declare function omit<T, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
export { omit };

@@ -19,2 +19,4 @@ /**

*/
export declare function omitBy<T extends Record<string, any>>(obj: T, shouldOmit: (value: T[keyof T], key: string) => boolean): Partial<T>;
declare function omitBy<T extends Record<string, any>>(obj: T, shouldOmit: (value: T[keyof T], key: string) => boolean): Partial<T>;
export { omitBy };

@@ -16,2 +16,4 @@ /**

*/
export declare function pick<T, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
declare function pick<T, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
export { pick };

@@ -19,2 +19,4 @@ /**

*/
export declare function pickBy<T extends Record<string, any>>(obj: T, shouldPick: (value: T[keyof T], key: string) => boolean): Partial<T>;
declare function pickBy<T extends Record<string, any>>(obj: T, shouldPick: (value: T[keyof T], key: string) => boolean): Partial<T>;
export { pickBy };

@@ -1,4 +0,4 @@

export { isNil } from './isNil';
export { isNotNil } from './isNotNil';
export { isNull } from './isNull';
export { isUndefined } from './isUndefined';
export { isNil } from './isNil.js';
export { isNotNil } from './isNotNil.js';
export { isNull } from './isNull.js';
export { isUndefined } from './isUndefined.js';

@@ -1,67 +0,41 @@

'use strict';
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
Object.defineProperty(exports, '__esModule', { value: true });
// src/predicate/index.ts
var predicate_exports = {};
__export(predicate_exports, {
isNil: () => isNil,
isNotNil: () => isNotNil,
isNull: () => isNull,
isUndefined: () => isUndefined
});
module.exports = __toCommonJS(predicate_exports);
/**
* Checks if a given value is null or undefined.
*
* This function tests whether the provided value is either `null` or `undefined`.
* It returns `true` if the value is `null` or `undefined`, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`.
*
* @param {unknown} x - The value to test for null or undefined.
* @returns {boolean} `true` if the value is null or undefined, `false` otherwise.
*
* @example
* * const value1 = null;
* const value2 = undefined;
* const value3 = 42;
* const result1 = isNil(value1); // true
* const result2 = isNil(value2); // true
* const result3 = isNil(value3); // false
*/
// src/predicate/isNil.ts
function isNil(x) {
return x == null || x == undefined;
return x == null || x == void 0;
}
/**
* Checks if the given value is not null nor undefined.
*
* The main use of this function is to be used with TypeScript as a type predicate.
*
* @param {T | null | undefined} x - The value to test if it is not null nor undefined.
* @returns {x is T} True if the value is not null nor undefined, false otherwise.
*
* @example
* // Here the type of `arr` is (number | undefined)[]
* const arr = [1, undefined, 3];
* // Here the type of `result` is number[]
* const result = arr.filter(isNotNil);
* // result will be [1, 3]
*/
// src/predicate/isNotNil.ts
function isNotNil(x) {
return x != null && x != undefined;
return x != null && x != void 0;
}
/**
* Checks if the given value is null.
*
* This function tests whether the provided value is strictly equal to `null`.
* It returns `true` if the value is `null`, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null`.
*
* @param {unknown} x - The value to test if it is null.
* @returns {x is null} True if the value is null, false otherwise.
*
* @example
* * const value1 = null;
* const value2 = undefined;
* const value3 = 42;
*
* console.log(isNull(value1)); // true
* console.log(isNull(value2)); // false
* console.log(isNull(value3)); // false
*/
// src/predicate/isNull.ts
function isNull(x) {

@@ -71,29 +45,13 @@ return x === null;

/**
* Checks if the given value is undefined.
*
* This function tests whether the provided value is strictly equal to `undefined`.
* It returns `true` if the value is `undefined`, and `false` otherwise.
*
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `undefined`.
*
* @param {unknown} x - The value to test if it is undefined.
* @returns {x is undefined} true if the value is undefined, false otherwise.
*
* @example
* * const value1 = undefined;
* const value2 = null;
* const value3 = 42;
*
* console.log(isUndefined(value1)); // true
* console.log(isUndefined(value2)); // false
* console.log(isUndefined(value3)); // false
*/
// src/predicate/isUndefined.ts
function isUndefined(x) {
return x === undefined;
return x === void 0;
}
exports.isNil = isNil;
exports.isNotNil = isNotNil;
exports.isNull = isNull;
exports.isUndefined = isUndefined;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
isNil,
isNotNil,
isNull,
isUndefined
});
//# sourceMappingURL=index.js.map

@@ -20,2 +20,4 @@ /**

*/
export declare function isNil(x: unknown): x is null | undefined;
declare function isNil(x: unknown): x is null | undefined;
export { isNil };

@@ -16,2 +16,4 @@ /**

*/
export declare function isNotNil<T>(x: T | null | undefined): x is T;
declare function isNotNil<T>(x: T | null | undefined): x is T;
export { isNotNil };

@@ -21,2 +21,4 @@ /**

*/
export declare function isNull(x: unknown): x is null;
declare function isNull(x: unknown): x is null;
export { isNull };

@@ -21,2 +21,4 @@ /**

*/
export declare function isUndefined(x: unknown): x is undefined;
declare function isUndefined(x: unknown): x is undefined;
export { isUndefined };

@@ -19,2 +19,4 @@ /**

*/
export declare function delay(ms: number): Promise<void>;
declare function delay(ms: number): Promise<void>;
export { delay };

@@ -1,1 +0,1 @@

export { delay } from './delay';
export { delay } from './delay.js';

@@ -1,29 +0,37 @@

'use strict';
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
Object.defineProperty(exports, '__esModule', { value: true });
// src/promise/index.ts
var promise_exports = {};
__export(promise_exports, {
delay: () => delay
});
module.exports = __toCommonJS(promise_exports);
/**
* Delays the execution of code for a specified number of milliseconds.
*
* This function returns a Promise that resolves after the specified delay, allowing you to use it
* with async/await to pause execution.
*
* @param {number} ms - The number of milliseconds to delay.
* @returns {Promise<void>} A Promise that resolves after the specified delay.
*
* @example
* async function foo() {
* console.log('Start');
* await delay(1000); // Delays execution for 1 second
* console.log('End');
* }
*
* foo();
*/
// src/promise/delay.ts
function delay(ms) {
return new Promise(function (resolve) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
exports.delay = delay;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
delay
});
//# sourceMappingURL=index.js.map
{
"name": "es-toolkit",
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
"version": "1.0.3-dev.35+34d4356a",
"version": "1.0.3-dev.37+9bde10a5",
"workspaces": [

@@ -11,35 +11,70 @@ "docs"

".": {
"types": "./dist/index.d.ts",
"import": "./esm/index.mjs",
"require": "./dist/index.js"
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"./array": {
"types": "./dist/array/index.d.ts",
"import": "./esm/array/index.mjs",
"require": "./dist/array/index.js"
"import": {
"types": "./dist/array/index.d.mts",
"default": "./dist/array/index.mjs"
},
"require": {
"types": "./dist/array/index.d.ts",
"default": "./dist/array/index.js"
}
},
"./function": {
"types": "./dist/function/index.d.ts",
"import": "./esm/function/index.mjs",
"require": "./dist/function/index.js"
"import": {
"types": "./dist/function/index.d.mts",
"default": "./dist/function/index.mjs"
},
"require": {
"types": "./dist/function/index.d.ts",
"default": "./dist/function/index.js"
}
},
"./math": {
"types": "./dist/math/index.d.ts",
"import": "./esm/math/index.mjs",
"require": "./dist/math/index.js"
"import": {
"types": "./dist/math/index.d.mts",
"default": "./dist/math/index.mjs"
},
"require": {
"types": "./dist/math/index.d.ts",
"default": "./dist/math/index.js"
}
},
"./object": {
"types": "./dist/object/index.d.ts",
"import": "./esm/object/index.mjs",
"require": "./dist/object/index.js"
"import": {
"types": "./dist/object/index.d.mts",
"default": "./dist/object/index.mjs"
},
"require": {
"types": "./dist/object/index.d.ts",
"default": "./dist/object/index.js"
}
},
"./predicate": {
"types": "./dist/predicate/index.d.ts",
"import": "./esm/predicate/index.mjs",
"require": "./dist/predicate/index.js"
"import": {
"types": "./dist/predicate/index.d.mts",
"default": "./dist/predicate/index.mjs"
},
"require": {
"types": "./dist/predicate/index.d.ts",
"default": "./dist/predicate/index.js"
}
},
"./promise": {
"types": "./dist/promise/index.d.ts",
"import": "./esm/promise/index.mjs",
"require": "./dist/promise/index.js"
"import": {
"types": "./dist/promise/index.d.mts",
"default": "./dist/promise/index.mjs"
},
"require": {
"types": "./dist/promise/index.d.ts",
"default": "./dist/promise/index.js"
}
},

@@ -49,4 +84,3 @@ "./package.json": "./package.json"

"files": [
"dist/**/*",
"esm/**/*",
"dist",
"*.d.ts"

@@ -57,38 +91,74 @@ ],

"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./esm/index.mjs",
"require": "./dist/index.js"
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"./array": {
"types": "./dist/array/index.d.ts",
"import": "./esm/array/index.mjs",
"require": "./dist/array/index.js"
"import": {
"types": "./dist/array/index.d.mts",
"default": "./dist/array/index.mjs"
},
"require": {
"types": "./dist/array/index.d.ts",
"default": "./dist/array/index.js"
}
},
"./function": {
"types": "./dist/function/index.d.ts",
"import": "./esm/function/index.mjs",
"require": "./dist/function/index.js"
"import": {
"types": "./dist/function/index.d.mts",
"default": "./dist/function/index.mjs"
},
"require": {
"types": "./dist/function/index.d.ts",
"default": "./dist/function/index.js"
}
},
"./math": {
"types": "./dist/math/index.d.ts",
"import": "./esm/math/index.mjs",
"require": "./dist/math/index.js"
"import": {
"types": "./dist/math/index.d.mts",
"default": "./dist/math/index.mjs"
},
"require": {
"types": "./dist/math/index.d.ts",
"default": "./dist/math/index.js"
}
},
"./object": {
"types": "./dist/object/index.d.ts",
"import": "./esm/object/index.mjs",
"require": "./dist/object/index.js"
"import": {
"types": "./dist/object/index.d.mts",
"default": "./dist/object/index.mjs"
},
"require": {
"types": "./dist/object/index.d.ts",
"default": "./dist/object/index.js"
}
},
"./predicate": {
"types": "./dist/predicate/index.d.ts",
"import": "./esm/predicate/index.mjs",
"require": "./dist/predicate/index.js"
"import": {
"types": "./dist/predicate/index.d.mts",
"default": "./dist/predicate/index.mjs"
},
"require": {
"types": "./dist/predicate/index.d.ts",
"default": "./dist/predicate/index.js"
}
},
"./promise": {
"types": "./dist/promise/index.d.ts",
"import": "./esm/promise/index.mjs",
"require": "./dist/promise/index.js"
"import": {
"types": "./dist/promise/index.d.mts",
"default": "./dist/promise/index.mjs"
},
"require": {
"types": "./dist/promise/index.d.ts",
"default": "./dist/promise/index.js"
}
},

@@ -104,3 +174,2 @@ "./package.json": "./package.json"

"@changesets/cli": "^2.27.1",
"@toss/rollup-config": "0.2.0-canary.0",
"@types/babel__core": "^7",

@@ -119,3 +188,3 @@ "@types/babel__preset-env": "^7",

"prettier": "^3.2.5",
"rollup": "^2.78.0",
"tsup": "^8.1.0",
"typescript": "^5.4.5",

@@ -127,7 +196,8 @@ "vitest": "^1.5.2"

"prepack": "yarn build",
"build": "rm -rf dist esm && tsc -p tsconfig.json --declaration --emitDeclarationOnly --declarationDir dist && rollup -c rollup.config.js && ./.scripts/postbuild.sh",
"build": "tsup && ./.scripts/postbuild.sh",
"test": "vitest run --coverage --typecheck"
},
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc