es-toolkit 1.2.0-dev.51 → 1.2.0-dev.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/array/differenceWith.d.mts +1 -1
- package/dist/array/differenceWith.d.ts +1 -1
- package/dist/array/differenceWith.js.map +1 -1
- package/dist/array/differenceWith.mjs +1 -1
- package/dist/array/drop.d.mts +1 -1
- package/dist/array/drop.d.ts +1 -1
- package/dist/array/drop.js.map +1 -1
- package/dist/array/drop.mjs +1 -1
- package/dist/array/dropRight.d.mts +1 -1
- package/dist/array/dropRight.d.ts +1 -1
- package/dist/array/dropRight.js.map +1 -1
- package/dist/array/dropRight.mjs +1 -1
- package/dist/array/dropRightWhile.d.mts +1 -1
- package/dist/array/dropRightWhile.d.ts +1 -1
- package/dist/array/dropRightWhile.js.map +1 -1
- package/dist/array/dropRightWhile.mjs +1 -1
- package/dist/array/index.js.map +1 -1
- package/dist/array/index.mjs +16 -16
- package/dist/array/intersectionWith.d.mts +1 -1
- package/dist/array/intersectionWith.d.ts +1 -1
- package/dist/array/intersectionWith.js.map +1 -1
- package/dist/array/intersectionWith.mjs +1 -1
- package/dist/array/take.js.map +1 -1
- package/dist/array/take.mjs +1 -1
- package/dist/array/union.js.map +1 -1
- package/dist/array/union.mjs +2 -2
- package/dist/array/unionBy.d.mts +1 -1
- package/dist/array/unionBy.d.ts +1 -1
- package/dist/array/unionBy.js.map +1 -1
- package/dist/array/unionBy.mjs +1 -1
- package/dist/array/unionWith.js.map +1 -1
- package/dist/array/unionWith.mjs +2 -2
- package/dist/array/uniq.d.mts +1 -1
- package/dist/array/uniq.d.ts +1 -1
- package/dist/array/uniq.js.map +1 -1
- package/dist/array/uniq.mjs +1 -1
- package/dist/array/uniqBy.d.mts +4 -0
- package/dist/array/uniqBy.d.ts +4 -0
- package/dist/array/uniqBy.js.map +1 -1
- package/dist/array/uniqBy.mjs +2 -2
- package/dist/array/uniqWith.d.mts +4 -0
- package/dist/array/uniqWith.d.ts +4 -0
- package/dist/array/uniqWith.js.map +1 -1
- package/dist/array/uniqWith.mjs +1 -1
- package/dist/array/xor.js.map +1 -1
- package/dist/array/xor.mjs +3 -3
- package/dist/array/xorBy.d.mts +1 -1
- package/dist/array/xorBy.d.ts +1 -1
- package/dist/array/xorBy.js.map +1 -1
- package/dist/array/xorBy.mjs +2 -2
- package/dist/array/xorWith.js.map +1 -1
- package/dist/array/xorWith.mjs +5 -5
- package/dist/array/zipWith.d.mts +1 -1
- package/dist/array/zipWith.d.ts +1 -1
- package/dist/array/zipWith.js.map +1 -1
- package/dist/array/zipWith.mjs +1 -1
- package/dist/{chunk-6BCRFIEW.mjs → chunk-25R2U4KM.mjs} +1 -1
- package/dist/{chunk-6BCRFIEW.mjs.map → chunk-25R2U4KM.mjs.map} +1 -1
- package/dist/{chunk-VKVA56XG.mjs → chunk-3GMXDQQQ.mjs} +2 -2
- package/dist/{chunk-OLBUAFBX.mjs → chunk-4RRRH7OY.mjs} +1 -1
- package/dist/{chunk-OLBUAFBX.mjs.map → chunk-4RRRH7OY.mjs.map} +1 -1
- package/dist/{chunk-M3SHJ3LL.mjs → chunk-5NSVMWDQ.mjs} +1 -1
- package/dist/{chunk-M3SHJ3LL.mjs.map → chunk-5NSVMWDQ.mjs.map} +1 -1
- package/dist/{chunk-7LAOIS6P.mjs → chunk-6Z2YFKXQ.mjs} +1 -1
- package/dist/{chunk-7LAOIS6P.mjs.map → chunk-6Z2YFKXQ.mjs.map} +1 -1
- package/dist/{chunk-B5P232BA.mjs → chunk-7OU22ENP.mjs} +1 -1
- package/dist/chunk-7OU22ENP.mjs.map +1 -0
- package/dist/{chunk-SQOYF647.mjs → chunk-7ROFZNHY.mjs} +1 -1
- package/dist/chunk-7ROFZNHY.mjs.map +1 -0
- package/dist/{chunk-Y6ZRNII6.mjs → chunk-AIRSKN47.mjs} +1 -1
- package/dist/{chunk-Y6ZRNII6.mjs.map → chunk-AIRSKN47.mjs.map} +1 -1
- package/dist/{chunk-PRTIPC5X.mjs → chunk-C4IZ7TGA.mjs} +1 -1
- package/dist/chunk-C4IZ7TGA.mjs.map +1 -0
- package/dist/{chunk-TCHT4HCP.mjs → chunk-ERPXZYH2.mjs} +4 -4
- package/dist/{chunk-6GRNTXI3.mjs → chunk-EXU45QAF.mjs} +1 -1
- package/dist/{chunk-6GRNTXI3.mjs.map → chunk-EXU45QAF.mjs.map} +1 -1
- package/dist/{chunk-GLAZTR32.mjs → chunk-I2NAKQIE.mjs} +2 -2
- package/dist/{chunk-TK2EDHSP.mjs → chunk-K3UNRNNO.mjs} +2 -2
- package/dist/chunk-K3UNRNNO.mjs.map +1 -0
- package/dist/{chunk-SPLO5OZW.mjs → chunk-LIXL7PEP.mjs} +1 -1
- package/dist/chunk-LIXL7PEP.mjs.map +1 -0
- package/dist/{chunk-RK6PRCEJ.mjs → chunk-MLCL773E.mjs} +1 -1
- package/dist/chunk-MLCL773E.mjs.map +1 -0
- package/dist/{chunk-4PNP6CKQ.mjs → chunk-MTT7OPUK.mjs} +2 -2
- package/dist/chunk-MTT7OPUK.mjs.map +1 -0
- package/dist/{chunk-AFYV2UVZ.mjs → chunk-NQXYPWUH.mjs} +1 -1
- package/dist/{chunk-AFYV2UVZ.mjs.map → chunk-NQXYPWUH.mjs.map} +1 -1
- package/dist/{chunk-KBJTBR5T.mjs → chunk-OHQAR5AU.mjs} +1 -1
- package/dist/{chunk-KBJTBR5T.mjs.map → chunk-OHQAR5AU.mjs.map} +1 -1
- package/dist/{chunk-JDMFIUGM.mjs → chunk-SWPLMJR7.mjs} +1 -1
- package/dist/chunk-SWPLMJR7.mjs.map +1 -0
- package/dist/{chunk-YHY2XTJW.mjs → chunk-V7E5DGZP.mjs} +1 -1
- package/dist/chunk-V7E5DGZP.mjs.map +1 -0
- package/dist/{chunk-HOQRMBSB.mjs → chunk-VH2PV426.mjs} +1 -1
- package/dist/{chunk-HOQRMBSB.mjs.map → chunk-VH2PV426.mjs.map} +1 -1
- package/dist/{chunk-6LDIBBWQ.mjs → chunk-VOAKEOIM.mjs} +1 -1
- package/dist/chunk-VOAKEOIM.mjs.map +1 -0
- package/dist/{chunk-YEZIGQJG.mjs → chunk-XDERWWNA.mjs} +2 -2
- package/dist/{chunk-J6SWM4X6.mjs → chunk-ZE42UHNG.mjs} +1 -1
- package/dist/chunk-ZE42UHNG.mjs.map +1 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -24
- package/dist/math/clamp.d.mts +1 -1
- package/dist/math/clamp.d.ts +1 -1
- package/dist/math/clamp.js.map +1 -1
- package/dist/math/clamp.mjs +1 -1
- package/dist/math/index.js.map +1 -1
- package/dist/math/index.mjs +3 -3
- package/dist/math/round.d.mts +1 -1
- package/dist/math/round.d.ts +1 -1
- package/dist/math/round.js.map +1 -1
- package/dist/math/round.mjs +1 -1
- package/dist/math/sum.d.mts +1 -1
- package/dist/math/sum.d.ts +1 -1
- package/dist/math/sum.js.map +1 -1
- package/dist/math/sum.mjs +1 -1
- package/dist/object/index.js.map +1 -1
- package/dist/object/index.mjs +2 -2
- package/dist/object/omit.d.mts +1 -1
- package/dist/object/omit.d.ts +1 -1
- package/dist/object/omit.js.map +1 -1
- package/dist/object/omit.mjs +1 -1
- package/dist/object/pick.d.mts +1 -1
- package/dist/object/pick.d.ts +1 -1
- package/dist/object/pick.js.map +1 -1
- package/dist/object/pick.mjs +1 -1
- package/dist/predicate/index.js.map +1 -1
- package/dist/predicate/index.mjs +3 -3
- package/dist/predicate/isNil.d.mts +1 -1
- package/dist/predicate/isNil.d.ts +1 -1
- package/dist/predicate/isNil.js.map +1 -1
- package/dist/predicate/isNil.mjs +1 -1
- package/dist/predicate/isNull.d.mts +1 -1
- package/dist/predicate/isNull.d.ts +1 -1
- package/dist/predicate/isNull.js.map +1 -1
- package/dist/predicate/isNull.mjs +1 -1
- package/dist/predicate/isUndefined.d.mts +1 -1
- package/dist/predicate/isUndefined.d.ts +1 -1
- package/dist/predicate/isUndefined.js.map +1 -1
- package/dist/predicate/isUndefined.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-4PNP6CKQ.mjs.map +0 -1
- package/dist/chunk-6LDIBBWQ.mjs.map +0 -1
- package/dist/chunk-B5P232BA.mjs.map +0 -1
- package/dist/chunk-J6SWM4X6.mjs.map +0 -1
- package/dist/chunk-JDMFIUGM.mjs.map +0 -1
- package/dist/chunk-PRTIPC5X.mjs.map +0 -1
- package/dist/chunk-RK6PRCEJ.mjs.map +0 -1
- package/dist/chunk-SPLO5OZW.mjs.map +0 -1
- package/dist/chunk-SQOYF647.mjs.map +0 -1
- package/dist/chunk-TK2EDHSP.mjs.map +0 -1
- package/dist/chunk-YHY2XTJW.mjs.map +0 -1
- /package/dist/{chunk-VKVA56XG.mjs.map → chunk-3GMXDQQQ.mjs.map} +0 -0
- /package/dist/{chunk-TCHT4HCP.mjs.map → chunk-ERPXZYH2.mjs.map} +0 -0
- /package/dist/{chunk-GLAZTR32.mjs.map → chunk-I2NAKQIE.mjs.map} +0 -0
- /package/dist/{chunk-YEZIGQJG.mjs.map → chunk-XDERWWNA.mjs.map} +0 -0
package/dist/math/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/math/index.ts","../../src/math/clamp.ts","../../src/math/round.ts","../../src/math/sum.ts"],"sourcesContent":["export { clamp } from './clamp';\nexport { round } from './round';\nexport { sum } from './sum';\n","/**\n * Clamps a number within the inclusive lower and upper bounds.\n *\n * This function takes a number and two bounds, and returns the number clamped within the specified bounds.\n * If only one bound is provided, it returns the minimum of the value and the bound.\n *\n * @param {number} value - The number to clamp.\n * @param {number} minimum - The minimum bound to clamp the number.\n * @param {number} maximum - The maximum bound to clamp the number.\n * @returns {number} The clamped number within the specified bounds.\n *\n * @example\n *
|
|
1
|
+
{"version":3,"sources":["../../src/math/index.ts","../../src/math/clamp.ts","../../src/math/round.ts","../../src/math/sum.ts"],"sourcesContent":["export { clamp } from './clamp';\nexport { round } from './round';\nexport { sum } from './sum';\n","/**\n * Clamps a number within the inclusive lower and upper bounds.\n *\n * This function takes a number and two bounds, and returns the number clamped within the specified bounds.\n * If only one bound is provided, it returns the minimum of the value and the bound.\n *\n * @param {number} value - The number to clamp.\n * @param {number} minimum - The minimum bound to clamp the number.\n * @param {number} maximum - The maximum bound to clamp the number.\n * @returns {number} The clamped number within the specified bounds.\n *\n * @example\n * const result1 = clamp(10, 5); // result1 will be 5, as 10 is clamped to the bound 5\n * const result2 = clamp(10, 5, 15); // result2 will be 10, as it is within the bounds 5 and 15\n * const result3 = clamp(2, 5, 15); // result3 will be 5, as 2 is clamped to the lower bound 5\n * const result4 = clamp(20, 5, 15); // result4 will be 15, as 20 is clamped to the upper bound 15\n */\nexport function clamp(value: number, maximum: number): number;\nexport function clamp(value: number, minimum: number, maximum: number): number;\nexport function clamp(value: number, bound1: number, bound2?: number): number {\n if (bound2 == null) {\n return Math.min(value, bound1);\n }\n\n return Math.min(Math.max(value, bound1), bound2);\n}\n","/**\n * Rounds a number to a specified precision.\n *\n * This function takes a number and an optional precision value, and returns the number rounded\n * to the specified number of decimal places.\n *\n * @param {number} value - The number to round.\n * @param {number} [precision=0] - The number of decimal places to round to. Defaults to 0.\n * @returns {number} The rounded number.\n *\n * @example\n * const result1 = round(1.2345); // result1 will be 1\n * const result2 = round(1.2345, 2); // result2 will be 1.23\n * const result3 = round(1.2345, 3); // result3 will be 1.235\n */\nexport function round(value: number, precision: number = 0): number {\n const multiplier = Math.pow(10, precision);\n return Math.round(value * multiplier) / multiplier;\n}\n","/**\n * Calculates the sum of an array of numbers.\n *\n * This function takes an array of numbers and returns the sum of all the elements in the array.\n *\n * @param {number[]} nums - An array of numbers to be summed.\n * @returns {number} The sum of all the numbers in the array.\n *\n * @example\n * const numbers = [1, 2, 3, 4, 5];\n * const result = sum(numbers);\n * // result will be 15\n */\nexport function sum(nums: number[]): number {\n let result = 0;\n\n for (const num of nums) {\n result += num;\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACmBO,SAAS,MAAM,OAAe,QAAgB,QAAyB;AAC5E,MAAI,UAAU,MAAM;AAClB,WAAO,KAAK,IAAI,OAAO,MAAM;AAAA,EAC/B;AAEA,SAAO,KAAK,IAAI,KAAK,IAAI,OAAO,MAAM,GAAG,MAAM;AACjD;;;ACVO,SAAS,MAAM,OAAe,YAAoB,GAAW;AAClE,QAAM,aAAa,KAAK,IAAI,IAAI,SAAS;AACzC,SAAO,KAAK,MAAM,QAAQ,UAAU,IAAI;AAC1C;;;ACLO,SAAS,IAAI,MAAwB;AAC1C,MAAI,SAAS;AAEb,aAAW,OAAO,MAAM;AACtB,cAAU;AAAA,EACZ;AAEA,SAAO;AACT;","names":[]}
|
package/dist/math/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import "../chunk-IJLQVGW4.mjs";
|
|
2
2
|
import {
|
|
3
3
|
clamp
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-MLCL773E.mjs";
|
|
5
5
|
import {
|
|
6
6
|
round
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-V7E5DGZP.mjs";
|
|
8
8
|
import {
|
|
9
9
|
sum
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-7OU22ENP.mjs";
|
|
11
11
|
import "../chunk-2MM5EJJX.mjs";
|
|
12
12
|
export {
|
|
13
13
|
clamp,
|
package/dist/math/round.d.mts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @returns {number} The rounded number.
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
|
-
*
|
|
12
|
+
* const result1 = round(1.2345); // result1 will be 1
|
|
13
13
|
* const result2 = round(1.2345, 2); // result2 will be 1.23
|
|
14
14
|
* const result3 = round(1.2345, 3); // result3 will be 1.235
|
|
15
15
|
*/
|
package/dist/math/round.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @returns {number} The rounded number.
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
|
-
*
|
|
12
|
+
* const result1 = round(1.2345); // result1 will be 1
|
|
13
13
|
* const result2 = round(1.2345, 2); // result2 will be 1.23
|
|
14
14
|
* const result3 = round(1.2345, 3); // result3 will be 1.235
|
|
15
15
|
*/
|
package/dist/math/round.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/math/round.ts"],"sourcesContent":["/**\n * Rounds a number to a specified precision.\n *\n * This function takes a number and an optional precision value, and returns the number rounded\n * to the specified number of decimal places.\n *\n * @param {number} value - The number to round.\n * @param {number} [precision=0] - The number of decimal places to round to. Defaults to 0.\n * @returns {number} The rounded number.\n *\n * @example\n *
|
|
1
|
+
{"version":3,"sources":["../../src/math/round.ts"],"sourcesContent":["/**\n * Rounds a number to a specified precision.\n *\n * This function takes a number and an optional precision value, and returns the number rounded\n * to the specified number of decimal places.\n *\n * @param {number} value - The number to round.\n * @param {number} [precision=0] - The number of decimal places to round to. Defaults to 0.\n * @returns {number} The rounded number.\n *\n * @example\n * const result1 = round(1.2345); // result1 will be 1\n * const result2 = round(1.2345, 2); // result2 will be 1.23\n * const result3 = round(1.2345, 3); // result3 will be 1.235\n */\nexport function round(value: number, precision: number = 0): number {\n const multiplier = Math.pow(10, precision);\n return Math.round(value * multiplier) / multiplier;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAeO,SAAS,MAAM,OAAe,YAAoB,GAAW;AAClE,QAAM,aAAa,KAAK,IAAI,IAAI,SAAS;AACzC,SAAO,KAAK,MAAM,QAAQ,UAAU,IAAI;AAC1C;","names":[]}
|
package/dist/math/round.mjs
CHANGED
package/dist/math/sum.d.mts
CHANGED
package/dist/math/sum.d.ts
CHANGED
package/dist/math/sum.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/math/sum.ts"],"sourcesContent":["/**\n * Calculates the sum of an array of numbers.\n *\n * This function takes an array of numbers and returns the sum of all the elements in the array.\n *\n * @param {number[]} nums - An array of numbers to be summed.\n * @returns {number} The sum of all the numbers in the array.\n *\n * @example\n *
|
|
1
|
+
{"version":3,"sources":["../../src/math/sum.ts"],"sourcesContent":["/**\n * Calculates the sum of an array of numbers.\n *\n * This function takes an array of numbers and returns the sum of all the elements in the array.\n *\n * @param {number[]} nums - An array of numbers to be summed.\n * @returns {number} The sum of all the numbers in the array.\n *\n * @example\n * const numbers = [1, 2, 3, 4, 5];\n * const result = sum(numbers);\n * // result will be 15\n */\nexport function sum(nums: number[]): number {\n let result = 0;\n\n for (const num of nums) {\n result += num;\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,SAAS,IAAI,MAAwB;AAC1C,MAAI,SAAS;AAEb,aAAW,OAAO,MAAM;AACtB,cAAU;AAAA,EACZ;AAEA,SAAO;AACT;","names":[]}
|
package/dist/math/sum.mjs
CHANGED
package/dist/object/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/object/index.ts","../../src/object/omit.ts","../../src/object/omitBy.ts","../../src/object/pick.ts","../../src/object/pickBy.ts"],"sourcesContent":["export { omit } from './omit';\nexport { omitBy } from './omitBy';\nexport { pick } from './pick';\nexport { pickBy } from './pickBy';\n","/**\n * Creates a new object with specified keys omitted.\n *\n * This function takes an object and an array of keys, and returns a new object that\n * excludes the properties corresponding to the specified keys.\n *\n * @param {T} obj - The object to omit keys from.\n * @param {K[]} keys - An array of keys to be omitted from the object.\n * @returns {Omit<T, K>} A new object with the specified keys omitted.\n *\n * @example\n *
|
|
1
|
+
{"version":3,"sources":["../../src/object/index.ts","../../src/object/omit.ts","../../src/object/omitBy.ts","../../src/object/pick.ts","../../src/object/pickBy.ts"],"sourcesContent":["export { omit } from './omit';\nexport { omitBy } from './omitBy';\nexport { pick } from './pick';\nexport { pickBy } from './pickBy';\n","/**\n * Creates a new object with specified keys omitted.\n *\n * This function takes an object and an array of keys, and returns a new object that\n * excludes the properties corresponding to the specified keys.\n *\n * @param {T} obj - The object to omit keys from.\n * @param {K[]} keys - An array of keys to be omitted from the object.\n * @returns {Omit<T, K>} A new object with the specified keys omitted.\n *\n * @example\n * const obj = { a: 1, b: 2, c: 3 };\n * const result = omit(obj, ['b', 'c']);\n * // result will be { a: 1 }\n */\nexport function omit<T, K extends keyof T>(obj: T, keys: K[]): Omit<T, K> {\n const result = { ...obj };\n\n for (const key of keys) {\n delete result[key];\n }\n\n return result as Omit<T, K>;\n}\n","/**\n * Creates a new object composed of the properties that do not satisfy the predicate function.\n *\n * This function takes an object and a predicate function, and returns a new object that\n * includes only the properties for which the predicate function returns false.\n *\n * @param {T} obj - The object to omit properties from.\n * @param {(value: T[string], key: string) => boolean} shouldOmit - A predicate function that determines\n * whether a property should be omitted. It takes the property's key and value as arguments and returns `true`\n * if the property should be omitted, and `false` otherwise.\n * @returns {Partial<T>} A new object with the properties that do not satisfy the predicate function.\n *\n * @example\n * const obj = { a: 1, b: 'omit', c: 3 };\n * const shouldOmit = (key, value) => typeof value === 'string';\n * const result = omitBy(obj, shouldOmit);\n * // result will be { a: 1, c: 3 }\n */\nexport function omitBy<T extends Record<string, any>>(\n obj: T,\n shouldOmit: (value: T[keyof T], key: string) => boolean\n): Partial<T> {\n const result: Partial<T> = {};\n\n for (const [key, value] of Object.entries(obj)) {\n if (shouldOmit(value, key)) {\n continue;\n }\n\n (result as any)[key] = value;\n }\n\n return result;\n}\n","/**\n * Creates a new object composed of the picked object properties.\n *\n * This function takes an object and an array of keys, and returns a new object that\n * includes only the properties corresponding to the specified keys.\n *\n * @param {T} obj - The object to pick keys from.\n * @param {K[]} keys - An array of keys to be picked from the object.\n * @returns {Pick<T, K>} A new object with the specified keys picked.\n *\n * @example\n * const obj = { a: 1, b: 2, c: 3 };\n * const result = pick(obj, ['a', 'c']);\n * // result will be { a: 1, c: 3 }\n */\nexport function pick<T, K extends keyof T>(obj: T, keys: K[]): Pick<T, K> {\n const result = {} as Pick<T, K>;\n\n for (const key of keys) {\n result[key] = obj[key];\n }\n\n return result;\n}\n","/**\n * Creates a new object composed of the properties that satisfy the predicate function.\n *\n * This function takes an object and a predicate function, and returns a new object that\n * includes only the properties for which the predicate function returns true.\n *\n * @param {T} obj - The object to pick properties from.\n * @param {(value: T[keyof T], key: string) => boolean} shouldPick - A predicate function that determines\n * whether a property should be picked. It takes the property's key and value as arguments and returns `true`\n * if the property should be picked, and `false` otherwise.\n * @returns {Partial<T>} A new object with the properties that satisfy the predicate function.\n *\n * @example\n * const obj = { a: 1, b: 'pick', c: 3 };\n * const shouldPick = (value) => typeof value === 'string';\n * const result = pickBy(obj, shouldPick);\n * // result will be { b: 'pick' }\n */\nexport function pickBy<T extends Record<string, any>>(\n obj: T,\n shouldPick: (value: T[keyof T], key: string) => boolean\n): Partial<T> {\n const result: Partial<T> = {};\n\n for (const [key, value] of Object.entries(obj)) {\n if (!shouldPick(value, key)) {\n continue;\n }\n\n (result as any)[key] = value;\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACeO,SAAS,KAA2B,KAAQ,MAAuB;AACxE,QAAM,SAAS,mBAAK;AAEpB,aAAW,OAAO,MAAM;AACtB,WAAO,OAAO,GAAG;AAAA,EACnB;AAEA,SAAO;AACT;;;ACLO,SAAS,OACd,KACA,YACY;AACZ,QAAM,SAAqB,CAAC;AAE5B,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,GAAG,GAAG;AAC9C,QAAI,WAAW,OAAO,GAAG,GAAG;AAC1B;AAAA,IACF;AAEA,IAAC,OAAe,GAAG,IAAI;AAAA,EACzB;AAEA,SAAO;AACT;;;AClBO,SAAS,KAA2B,KAAQ,MAAuB;AACxE,QAAM,SAAS,CAAC;AAEhB,aAAW,OAAO,MAAM;AACtB,WAAO,GAAG,IAAI,IAAI,GAAG;AAAA,EACvB;AAEA,SAAO;AACT;;;ACLO,SAAS,OACd,KACA,YACY;AACZ,QAAM,SAAqB,CAAC;AAE5B,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,GAAG,GAAG;AAC9C,QAAI,CAAC,WAAW,OAAO,GAAG,GAAG;AAC3B;AAAA,IACF;AAEA,IAAC,OAAe,GAAG,IAAI;AAAA,EACzB;AAEA,SAAO;AACT;","names":[]}
|
package/dist/object/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import "../chunk-T5JCRGXA.mjs";
|
|
2
2
|
import {
|
|
3
3
|
omit
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-ZE42UHNG.mjs";
|
|
5
5
|
import {
|
|
6
6
|
omitBy
|
|
7
7
|
} from "../chunk-SF3V7XXM.mjs";
|
|
8
8
|
import {
|
|
9
9
|
pick
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-NQXYPWUH.mjs";
|
|
11
11
|
import {
|
|
12
12
|
pickBy
|
|
13
13
|
} from "../chunk-T2C2WVFL.mjs";
|
package/dist/object/omit.d.mts
CHANGED
package/dist/object/omit.d.ts
CHANGED
package/dist/object/omit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/object/omit.ts"],"sourcesContent":["/**\n * Creates a new object with specified keys omitted.\n *\n * This function takes an object and an array of keys, and returns a new object that\n * excludes the properties corresponding to the specified keys.\n *\n * @param {T} obj - The object to omit keys from.\n * @param {K[]} keys - An array of keys to be omitted from the object.\n * @returns {Omit<T, K>} A new object with the specified keys omitted.\n *\n * @example\n *
|
|
1
|
+
{"version":3,"sources":["../../src/object/omit.ts"],"sourcesContent":["/**\n * Creates a new object with specified keys omitted.\n *\n * This function takes an object and an array of keys, and returns a new object that\n * excludes the properties corresponding to the specified keys.\n *\n * @param {T} obj - The object to omit keys from.\n * @param {K[]} keys - An array of keys to be omitted from the object.\n * @returns {Omit<T, K>} A new object with the specified keys omitted.\n *\n * @example\n * const obj = { a: 1, b: 2, c: 3 };\n * const result = omit(obj, ['b', 'c']);\n * // result will be { a: 1 }\n */\nexport function omit<T, K extends keyof T>(obj: T, keys: K[]): Omit<T, K> {\n const result = { ...obj };\n\n for (const key of keys) {\n delete result[key];\n }\n\n return result as Omit<T, K>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAeO,SAAS,KAA2B,KAAQ,MAAuB;AACxE,QAAM,SAAS,mBAAK;AAEpB,aAAW,OAAO,MAAM;AACtB,WAAO,OAAO,GAAG;AAAA,EACnB;AAEA,SAAO;AACT;","names":[]}
|
package/dist/object/omit.mjs
CHANGED
package/dist/object/pick.d.mts
CHANGED
package/dist/object/pick.d.ts
CHANGED
package/dist/object/pick.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/object/pick.ts"],"sourcesContent":["/**\n * Creates a new object composed of the picked object properties.\n *\n * This function takes an object and an array of keys, and returns a new object that\n * includes only the properties corresponding to the specified keys.\n *\n * @param {T} obj - The object to pick keys from.\n * @param {K[]} keys - An array of keys to be picked from the object.\n * @returns {Pick<T, K>} A new object with the specified keys picked.\n *\n * @example\n *
|
|
1
|
+
{"version":3,"sources":["../../src/object/pick.ts"],"sourcesContent":["/**\n * Creates a new object composed of the picked object properties.\n *\n * This function takes an object and an array of keys, and returns a new object that\n * includes only the properties corresponding to the specified keys.\n *\n * @param {T} obj - The object to pick keys from.\n * @param {K[]} keys - An array of keys to be picked from the object.\n * @returns {Pick<T, K>} A new object with the specified keys picked.\n *\n * @example\n * const obj = { a: 1, b: 2, c: 3 };\n * const result = pick(obj, ['a', 'c']);\n * // result will be { a: 1, c: 3 }\n */\nexport function pick<T, K extends keyof T>(obj: T, keys: K[]): Pick<T, K> {\n const result = {} as Pick<T, K>;\n\n for (const key of keys) {\n result[key] = obj[key];\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAeO,SAAS,KAA2B,KAAQ,MAAuB;AACxE,QAAM,SAAS,CAAC;AAEhB,aAAW,OAAO,MAAM;AACtB,WAAO,GAAG,IAAI,IAAI,GAAG;AAAA,EACvB;AAEA,SAAO;AACT;","names":[]}
|
package/dist/object/pick.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/predicate/index.ts","../../src/predicate/isNil.ts","../../src/predicate/isNotNil.ts","../../src/predicate/isNull.ts","../../src/predicate/isUndefined.ts"],"sourcesContent":["export { isNil } from './isNil';\nexport { isNotNil } from './isNotNil';\nexport { isNull } from './isNull';\nexport { isUndefined } from './isUndefined';\n","/**\n * Checks if a given value is null or undefined.\n *\n * This function tests whether the provided value is either `null` or `undefined`.\n * It returns `true` if the value is `null` or `undefined`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`.\n *\n * @param {unknown} x - The value to test for null or undefined.\n * @returns {boolean} `true` if the value is null or undefined, `false` otherwise.\n *\n * @example\n *
|
|
1
|
+
{"version":3,"sources":["../../src/predicate/index.ts","../../src/predicate/isNil.ts","../../src/predicate/isNotNil.ts","../../src/predicate/isNull.ts","../../src/predicate/isUndefined.ts"],"sourcesContent":["export { isNil } from './isNil';\nexport { isNotNil } from './isNotNil';\nexport { isNull } from './isNull';\nexport { isUndefined } from './isUndefined';\n","/**\n * Checks if a given value is null or undefined.\n *\n * This function tests whether the provided value is either `null` or `undefined`.\n * It returns `true` if the value is `null` or `undefined`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`.\n *\n * @param {unknown} x - The value to test for null or undefined.\n * @returns {boolean} `true` if the value is null or undefined, `false` otherwise.\n *\n * @example\n * const value1 = null;\n * const value2 = undefined;\n * const value3 = 42;\n * const result1 = isNil(value1); // true\n * const result2 = isNil(value2); // true\n * const result3 = isNil(value3); // false\n */\nexport function isNil(x: unknown): x is null | undefined {\n return x === null || x === undefined;\n}\n","/**\n * Checks if the given value is not null nor undefined.\n *\n * The main use of this function is to be used with TypeScript as a type predicate.\n *\n * @param {T | null | undefined} x - The value to test if it is not null nor undefined.\n * @returns {x is T} True if the value is not null nor undefined, false otherwise.\n *\n * @example\n * // Here the type of `arr` is (number | undefined)[]\n * const arr = [1, undefined, 3];\n * // Here the type of `result` is number[]\n * const result = arr.filter(isNotNil);\n * // result will be [1, 3]\n */\nexport function isNotNil<T>(x: T | null | undefined): x is T {\n return x !== null && x !== undefined;\n}\n","/**\n * Checks if the given value is null.\n *\n * This function tests whether the provided value is strictly equal to `null`.\n * It returns `true` if the value is `null`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null`.\n *\n * @param {unknown} x - The value to test if it is null.\n * @returns {x is null} True if the value is null, false otherwise.\n *\n * @example\n * const value1 = null;\n * const value2 = undefined;\n * const value3 = 42;\n *\n * console.log(isNull(value1)); // true\n * console.log(isNull(value2)); // false\n * console.log(isNull(value3)); // false\n */\nexport function isNull(x: unknown): x is null {\n return x === null;\n}\n","/**\n * Checks if the given value is undefined.\n *\n * This function tests whether the provided value is strictly equal to `undefined`.\n * It returns `true` if the value is `undefined`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `undefined`.\n *\n * @param {unknown} x - The value to test if it is undefined.\n * @returns {x is undefined} true if the value is undefined, false otherwise.\n *\n * @example\n * const value1 = undefined;\n * const value2 = null;\n * const value3 = 42;\n *\n * console.log(isUndefined(value1)); // true\n * console.log(isUndefined(value2)); // false\n * console.log(isUndefined(value3)); // false\n */\nexport function isUndefined(x: unknown): x is undefined {\n return x === undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACmBO,SAAS,MAAM,GAAmC;AACvD,SAAO,MAAM,QAAQ,MAAM;AAC7B;;;ACNO,SAAS,SAAY,GAAiC;AAC3D,SAAO,MAAM,QAAQ,MAAM;AAC7B;;;ACGO,SAAS,OAAO,GAAuB;AAC5C,SAAO,MAAM;AACf;;;ACFO,SAAS,YAAY,GAA4B;AACtD,SAAO,MAAM;AACf;","names":[]}
|
package/dist/predicate/index.mjs
CHANGED
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
} from "../chunk-ZQNAZPSK.mjs";
|
|
5
5
|
import {
|
|
6
6
|
isNull
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-AIRSKN47.mjs";
|
|
8
8
|
import {
|
|
9
9
|
isUndefined
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-VH2PV426.mjs";
|
|
11
11
|
import {
|
|
12
12
|
isNil
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-OHQAR5AU.mjs";
|
|
14
14
|
import "../chunk-2MM5EJJX.mjs";
|
|
15
15
|
export {
|
|
16
16
|
isNil,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/predicate/isNil.ts"],"sourcesContent":["/**\n * Checks if a given value is null or undefined.\n *\n * This function tests whether the provided value is either `null` or `undefined`.\n * It returns `true` if the value is `null` or `undefined`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`.\n *\n * @param {unknown} x - The value to test for null or undefined.\n * @returns {boolean} `true` if the value is null or undefined, `false` otherwise.\n *\n * @example\n *
|
|
1
|
+
{"version":3,"sources":["../../src/predicate/isNil.ts"],"sourcesContent":["/**\n * Checks if a given value is null or undefined.\n *\n * This function tests whether the provided value is either `null` or `undefined`.\n * It returns `true` if the value is `null` or `undefined`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`.\n *\n * @param {unknown} x - The value to test for null or undefined.\n * @returns {boolean} `true` if the value is null or undefined, `false` otherwise.\n *\n * @example\n * const value1 = null;\n * const value2 = undefined;\n * const value3 = 42;\n * const result1 = isNil(value1); // true\n * const result2 = isNil(value2); // true\n * const result3 = isNil(value3); // false\n */\nexport function isNil(x: unknown): x is null | undefined {\n return x === null || x === undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBO,SAAS,MAAM,GAAmC;AACvD,SAAO,MAAM,QAAQ,MAAM;AAC7B;","names":[]}
|
package/dist/predicate/isNil.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/predicate/isNull.ts"],"sourcesContent":["/**\n * Checks if the given value is null.\n *\n * This function tests whether the provided value is strictly equal to `null`.\n * It returns `true` if the value is `null`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null`.\n *\n * @param {unknown} x - The value to test if it is null.\n * @returns {x is null} True if the value is null, false otherwise.\n *\n * @example\n *
|
|
1
|
+
{"version":3,"sources":["../../src/predicate/isNull.ts"],"sourcesContent":["/**\n * Checks if the given value is null.\n *\n * This function tests whether the provided value is strictly equal to `null`.\n * It returns `true` if the value is `null`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null`.\n *\n * @param {unknown} x - The value to test if it is null.\n * @returns {x is null} True if the value is null, false otherwise.\n *\n * @example\n * const value1 = null;\n * const value2 = undefined;\n * const value3 = 42;\n *\n * console.log(isNull(value1)); // true\n * console.log(isNull(value2)); // false\n * console.log(isNull(value3)); // false\n */\nexport function isNull(x: unknown): x is null {\n return x === null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBO,SAAS,OAAO,GAAuB;AAC5C,SAAO,MAAM;AACf;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/predicate/isUndefined.ts"],"sourcesContent":["/**\n * Checks if the given value is undefined.\n *\n * This function tests whether the provided value is strictly equal to `undefined`.\n * It returns `true` if the value is `undefined`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `undefined`.\n *\n * @param {unknown} x - The value to test if it is undefined.\n * @returns {x is undefined} true if the value is undefined, false otherwise.\n *\n * @example\n *
|
|
1
|
+
{"version":3,"sources":["../../src/predicate/isUndefined.ts"],"sourcesContent":["/**\n * Checks if the given value is undefined.\n *\n * This function tests whether the provided value is strictly equal to `undefined`.\n * It returns `true` if the value is `undefined`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `undefined`.\n *\n * @param {unknown} x - The value to test if it is undefined.\n * @returns {x is undefined} true if the value is undefined, false otherwise.\n *\n * @example\n * const value1 = undefined;\n * const value2 = null;\n * const value3 = 42;\n *\n * console.log(isUndefined(value1)); // true\n * console.log(isUndefined(value2)); // false\n * console.log(isUndefined(value3)); // false\n */\nexport function isUndefined(x: unknown): x is undefined {\n return x === undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBO,SAAS,YAAY,GAA4B;AACtD,SAAO,MAAM;AACf;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-toolkit",
|
|
3
3
|
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
|
|
4
|
-
"version": "1.2.0-dev.
|
|
4
|
+
"version": "1.2.0-dev.53+6ec30938",
|
|
5
5
|
"workspaces": [
|
|
6
6
|
"docs"
|
|
7
7
|
],
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/array/xorBy.ts"],"sourcesContent":["import { differenceBy } from './differenceBy';\nimport { intersectionBy } from './intersectionBy';\nimport { unionBy } from './unionBy';\n\n/**\n * Computes the symmetric difference between two arrays using a custom mapping function.\n * The symmetric difference is the set of elements which are in either of the arrays,\n * but not in their intersection, determined by the result of the mapping function.\n *\n * @template T - Type of elements in the input arrays.\n * @template U - Type of the values returned by the mapping function.\n *\n * @param {T[]} arr1 - The first array.\n * @param {T[]} arr2 - The second array.\n * @param {function(item: T): U} mapper - The function to map array elements to comparison values.\n * @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.\n *\n * @example\n * // Custom mapping function for objects with an 'id' property\n * const idMapper = obj => obj.id;\n * xorBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);\n * // Returns [{ id: 1 }, { id: 3 }]\n */\nexport function xorBy<T, U>(arr1: T[], arr2: T[], mapper: (item: T) => U): T[] {\n const union = unionBy(arr1, arr2, mapper);\n const intersection = intersectionBy(arr1, arr2, mapper);\n\n return differenceBy(union, intersection, mapper);\n}\n"],"mappings":";;;;;;;;;;;AAuBO,SAAS,MAAY,MAAW,MAAW,QAA6B;AAC7E,QAAM,QAAQ,QAAQ,MAAM,MAAM,MAAM;AACxC,QAAM,eAAe,eAAe,MAAM,MAAM,MAAM;AAEtD,SAAO,aAAa,OAAO,cAAc,MAAM;AACjD;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/array/dropRightWhile.ts"],"sourcesContent":["import { dropWhile } from './dropWhile';\n\n/**\n * Removes elements from the end of an array until the predicate returns false.\n *\n * This function iterates over an array from the end and drops elements until the provided\n * predicate function returns false. It then returns a new array with the remaining elements.\n *\n * @param {T[]} arr - The array from which to drop elements.\n * @param {function(item: T): boolean} canContinueDropping - A predicate function that determines\n * whether to continue dropping elements. The function is called with each element from the end,\n * and dropping continues as long as it returns true.\n * @returns {T[]} A new array with the elements remaining after the predicate returns false.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = dropRightWhile(array, x => x > 3);\n * // result will be [1, 2, 3] since elements greater than 3 are dropped from the end.\n */\nexport function dropRightWhile<T>(arr: T[], canContinueDropping: (item: T) => boolean) {\n const reversed = arr.slice().reverse();\n const dropped = dropWhile(reversed, canContinueDropping);\n return dropped.slice().reverse();\n}\n"],"mappings":";;;;;AAmBO,SAAS,eAAkB,KAAU,qBAA2C;AACrF,QAAM,WAAW,IAAI,MAAM,EAAE,QAAQ;AACrC,QAAM,UAAU,UAAU,UAAU,mBAAmB;AACvD,SAAO,QAAQ,MAAM,EAAE,QAAQ;AACjC;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/math/sum.ts"],"sourcesContent":["/**\n * Calculates the sum of an array of numbers.\n *\n * This function takes an array of numbers and returns the sum of all the elements in the array.\n *\n * @param {number[]} nums - An array of numbers to be summed.\n * @returns {number} The sum of all the numbers in the array.\n *\n * @example\n * * const numbers = [1, 2, 3, 4, 5];\n * const result = sum(numbers);\n * // result will be 15\n */\nexport function sum(nums: number[]): number {\n let result = 0;\n\n for (const num of nums) {\n result += num;\n }\n\n return result;\n}\n"],"mappings":";AAaO,SAAS,IAAI,MAAwB;AAC1C,MAAI,SAAS;AAEb,aAAW,OAAO,MAAM;AACtB,cAAU;AAAA,EACZ;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/object/omit.ts"],"sourcesContent":["/**\n * Creates a new object with specified keys omitted.\n *\n * This function takes an object and an array of keys, and returns a new object that\n * excludes the properties corresponding to the specified keys.\n *\n * @param {T} obj - The object to omit keys from.\n * @param {K[]} keys - An array of keys to be omitted from the object.\n * @returns {Omit<T, K>} A new object with the specified keys omitted.\n *\n * @example\n * * const obj = { a: 1, b: 2, c: 3 };\n * const result = omit(obj, ['b', 'c']);\n * // result will be { a: 1 }\n */\nexport function omit<T, K extends keyof T>(obj: T, keys: K[]): Omit<T, K> {\n const result = { ...obj };\n\n for (const key of keys) {\n delete result[key];\n }\n\n return result as Omit<T, K>;\n}\n"],"mappings":";;;;;AAeO,SAAS,KAA2B,KAAQ,MAAuB;AACxE,QAAM,SAAS,mBAAK;AAEpB,aAAW,OAAO,MAAM;AACtB,WAAO,OAAO,GAAG;AAAA,EACnB;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/array/uniq.ts"],"sourcesContent":["/**\n * Creates a duplicate-free version of an array.\n *\n * This function takes an array and returns a new array containing only the unique values\n * from the original array, preserving the order of first occurrence.\n *\n * @param {T[]} arr - The array to process.\n * @returns {T[]} A new array with only unique values from the original array.\n *\n * @example\n * * const array = [1, 2, 2, 3, 4, 4, 5];\n * const result = uniq(array);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function uniq<T>(arr: T[]): T[] {\n const result: T[] = [];\n\n for (const item of arr) {\n if (result.includes(item)) {\n continue;\n }\n\n result.push(item);\n }\n\n return result;\n}\n"],"mappings":";AAcO,SAAS,KAAQ,KAAe;AACrC,QAAM,SAAc,CAAC;AAErB,aAAW,QAAQ,KAAK;AACtB,QAAI,OAAO,SAAS,IAAI,GAAG;AACzB;AAAA,IACF;AAEA,WAAO,KAAK,IAAI;AAAA,EAClB;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/array/zipWith.ts"],"sourcesContent":["/**\n * Combines multiple arrays into a single array using a custom combiner function.\n *\n * This function takes multiple arrays and a combiner function, and returns a new array where each element\n * is the result of applying the combiner function to the corresponding elements of the input arrays.\n *\n * @param {T[]} arr1 - The first array to zip.\n * @param {U[]} [arr2] - The second array to zip (optional).\n * @param {V[]} [arr3] - The third array to zip (optional).\n * @param {W[]} [arr4] - The fourth array to zip (optional).\n * @param {function} combine - The combiner function that takes corresponding elements from each array and returns a single value.\n * @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.\n *\n * @example\n * // Example usage with two arrays:\n * const arr1 = [1, 2, 3];\n * const arr2 = [4, 5, 6];\n * const result = zipWith(arr1, arr2, (a, b) => a + b);\n * // result will be [5, 7, 9]\n *\n * @example\n * // Example usage with three arrays:\n * const arr1 = [1, 2];\n * const arr2 = [3, 4];\n * const arr3 = [5, 6];\n * const result = zipWith(arr1, arr2, arr3, (a, b, c) => `${a}${b}${c}`);\n * // result will be [`135`, `246`]\n */\nexport function zipWith<T, R>(arr1: T[], combine: (item: T) => R): R[];\nexport function zipWith<T, U, R>(arr1: T[], arr2: U[], combine: (item1: T, item2: U) => R): R[];\nexport function zipWith<T, U, V, R>(arr1: T[], arr2: U[], arr3: V[], combine: (item1: T, item2: U, item3: V) => R): R[];\nexport function zipWith<T, U, V, W, R>(\n arr1: T[],\n arr2: U[],\n arr3: V[],\n arr4: W[],\n combine: (item1: T, item2: U, item3: V, item4: W) => R\n): R[];\nexport function zipWith<T, R>(arr1: T[], ...rest: any[]): R[] {\n const arrs = [arr1, ...rest.slice(0, -1)];\n const combine = rest[rest.length - 1] as (...items: T[]) => R;\n\n const result: R[] = [];\n const maxIndex = Math.max(...arrs.map(arr => arr.length));\n\n for (let i = 0; i < maxIndex; i++) {\n const elements: T[] = arrs.map(arr => arr[i]);\n result.push(combine(...elements));\n }\n\n return result;\n}\n"],"mappings":";AAsCO,SAAS,QAAc,SAAc,MAAkB;AAC5D,QAAM,OAAO,CAAC,MAAM,GAAG,KAAK,MAAM,GAAG,EAAE,CAAC;AACxC,QAAM,UAAU,KAAK,KAAK,SAAS,CAAC;AAEpC,QAAM,SAAc,CAAC;AACrB,QAAM,WAAW,KAAK,IAAI,GAAG,KAAK,IAAI,SAAO,IAAI,MAAM,CAAC;AAExD,WAAS,IAAI,GAAG,IAAI,UAAU,KAAK;AACjC,UAAM,WAAgB,KAAK,IAAI,SAAO,IAAI,CAAC,CAAC;AAC5C,WAAO,KAAK,QAAQ,GAAG,QAAQ,CAAC;AAAA,EAClC;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/math/clamp.ts"],"sourcesContent":["/**\n * Clamps a number within the inclusive lower and upper bounds.\n *\n * This function takes a number and two bounds, and returns the number clamped within the specified bounds.\n * If only one bound is provided, it returns the minimum of the value and the bound.\n *\n * @param {number} value - The number to clamp.\n * @param {number} minimum - The minimum bound to clamp the number.\n * @param {number} maximum - The maximum bound to clamp the number.\n * @returns {number} The clamped number within the specified bounds.\n *\n * @example\n * * const result1 = clamp(10, 5); // result1 will be 5, as 10 is clamped to the bound 5\n * const result2 = clamp(10, 5, 15); // result2 will be 10, as it is within the bounds 5 and 15\n * const result3 = clamp(2, 5, 15); // result3 will be 5, as 2 is clamped to the lower bound 5\n * const result4 = clamp(20, 5, 15); // result4 will be 15, as 20 is clamped to the upper bound 15\n */\nexport function clamp(value: number, maximum: number): number;\nexport function clamp(value: number, minimum: number, maximum: number): number;\nexport function clamp(value: number, bound1: number, bound2?: number): number {\n if (bound2 == null) {\n return Math.min(value, bound1);\n }\n\n return Math.min(Math.max(value, bound1), bound2);\n}\n"],"mappings":";AAmBO,SAAS,MAAM,OAAe,QAAgB,QAAyB;AAC5E,MAAI,UAAU,MAAM;AAClB,WAAO,KAAK,IAAI,OAAO,MAAM;AAAA,EAC/B;AAEA,SAAO,KAAK,IAAI,KAAK,IAAI,OAAO,MAAM,GAAG,MAAM;AACjD;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/array/unionBy.ts"],"sourcesContent":["/**\n * Creates an array of unique values, in order, from all given arrays using a provided mapping function to determine equality.\n *\n * @param {T[]} arr1 - The first array.\n * @param {T[]} arr2 - The second array.\n * @param {function(item: T): U} mapper - The function to map array elements to comparison values.\n * @returns {T[]} A new array containing the union of unique elements from `arr1` and `arr2`, based on the values returned by the mapping function.\n *\n * @example\n * // Custom mapping function for numbers (modulo comparison)\n * const moduloMapper = (x) => x % 3;\n * unionBy([1, 2, 3], [4, 5, 6], moduloMapper);\n * // Returns [1, 2, 3]\n *\n * @example\n * // Custom mapping function for objects with an 'id' property\n * const idMapper = (obj) => obj.id;\n * unionBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);\n * // Returns [{ id: 1 }, { id: 2 }, { id: 3 }]\n */\nexport function unionBy<T, U>(arr1: T[], arr2: T[], mapper: (item: T) => U): T[] {\n const map = new Map<U, T>();\n\n for (const item of [...arr1, ...arr2]) {\n const key = mapper(item);\n if (!map.has(key)) {\n map.set(key, item);\n }\n }\n\n return [...map.values()];\n}\n"],"mappings":";AAoBO,SAAS,QAAc,MAAW,MAAW,QAA6B;AAC/E,QAAM,MAAM,oBAAI,IAAU;AAE1B,aAAW,QAAQ,CAAC,GAAG,MAAM,GAAG,IAAI,GAAG;AACrC,UAAM,MAAM,OAAO,IAAI;AACvB,QAAI,CAAC,IAAI,IAAI,GAAG,GAAG;AACjB,UAAI,IAAI,KAAK,IAAI;AAAA,IACnB;AAAA,EACF;AAEA,SAAO,CAAC,GAAG,IAAI,OAAO,CAAC;AACzB;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/array/uniqWith.ts"],"sourcesContent":["/**\n * The `uniqWith` function takes an array as its first argument and a 'comparator' function as the second.\n *\n * 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.\n *\n * @example\n * ```ts\n * uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => Math.abs(a - b) < 1);\n * // [1, 2, 3, 5, 7]\n * ```\n */\nexport function uniqWith<T>(arr: T[], areItemsEqual: (item1: T, item2: T) => boolean): T[] {\n const result: T[] = [];\n\n for (const item of arr) {\n const isUniq = result.every(v => !areItemsEqual(v, item));\n\n if (isUniq) {\n result.push(item);\n }\n }\n\n return result;\n}\n"],"mappings":";AAWO,SAAS,SAAY,KAAU,eAAqD;AACzF,QAAM,SAAc,CAAC;AAErB,aAAW,QAAQ,KAAK;AACtB,UAAM,SAAS,OAAO,MAAM,OAAK,CAAC,cAAc,GAAG,IAAI,CAAC;AAExD,QAAI,QAAQ;AACV,aAAO,KAAK,IAAI;AAAA,IAClB;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/array/uniqBy.ts"],"sourcesContent":["import { uniqWith } from './uniqWith';\n\n/**\n * 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.\n *\n * It filters out elements with the same value, meaning it does not check for duplicates in data types like Objects.\n *\n * @example\n * ```ts\n * uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);\n * // [1.2, 2.1, 3.3, 5.7, 7.19]\n * ```\n */\nexport function uniqBy<T, U>(arr: T[], converter: (item: T) => U): T[] {\n return uniqWith(arr, (item1, item2) => converter(item1) === converter(item2));\n}\n"],"mappings":";;;;;AAaO,SAAS,OAAa,KAAU,WAAgC;AACrE,SAAO,SAAS,KAAK,CAAC,OAAO,UAAU,UAAU,KAAK,MAAM,UAAU,KAAK,CAAC;AAC9E;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/math/round.ts"],"sourcesContent":["/**\n * Rounds a number to a specified precision.\n *\n * This function takes a number and an optional precision value, and returns the number rounded\n * to the specified number of decimal places.\n *\n * @param {number} value - The number to round.\n * @param {number} [precision=0] - The number of decimal places to round to. Defaults to 0.\n * @returns {number} The rounded number.\n *\n * @example\n * * const result1 = round(1.2345); // result1 will be 1\n * const result2 = round(1.2345, 2); // result2 will be 1.23\n * const result3 = round(1.2345, 3); // result3 will be 1.235\n */\nexport function round(value: number, precision: number = 0): number {\n const multiplier = Math.pow(10, precision);\n return Math.round(value * multiplier) / multiplier;\n}\n"],"mappings":";AAeO,SAAS,MAAM,OAAe,YAAoB,GAAW;AAClE,QAAM,aAAa,KAAK,IAAI,IAAI,SAAS;AACzC,SAAO,KAAK,MAAM,QAAQ,UAAU,IAAI;AAC1C;","names":[]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|