es-toolkit 1.13.1-dev.305 → 1.13.1-dev.307

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/index.mjs CHANGED
@@ -42,7 +42,7 @@ import {
42
42
  } from "./chunk-VH2PV426.mjs";
43
43
  import {
44
44
  isArrayLike
45
- } from "./chunk-J4SHAMXJ.mjs";
45
+ } from "./chunk-LPZZIY5Z.mjs";
46
46
  import {
47
47
  isEqual
48
48
  } from "./chunk-JYSV56US.mjs";
@@ -102,7 +102,32 @@ import {
102
102
  import {
103
103
  range
104
104
  } from "./chunk-DPH2KE6O.mjs";
105
+ import "./chunk-236H5JZJ.mjs";
106
+ import {
107
+ debounce
108
+ } from "./chunk-3IP4JVLL.mjs";
109
+ import {
110
+ negate
111
+ } from "./chunk-BOOQBJN2.mjs";
112
+ import {
113
+ noop
114
+ } from "./chunk-LKXCOLNY.mjs";
115
+ import {
116
+ once
117
+ } from "./chunk-CMBC4MXG.mjs";
118
+ import {
119
+ throttle
120
+ } from "./chunk-QOJGMVVR.mjs";
105
121
  import "./chunk-DDH7K4QM.mjs";
122
+ import {
123
+ zipObject
124
+ } from "./chunk-6GWEY5EL.mjs";
125
+ import {
126
+ zipWith
127
+ } from "./chunk-4KYXHZ4R.mjs";
128
+ import {
129
+ unzip
130
+ } from "./chunk-UYZKMBDO.mjs";
106
131
  import {
107
132
  unzipWith
108
133
  } from "./chunk-IFNXROZR.mjs";
@@ -122,11 +147,11 @@ import {
122
147
  zip
123
148
  } from "./chunk-IDCUZVJL.mjs";
124
149
  import {
125
- zipObject
126
- } from "./chunk-6GWEY5EL.mjs";
150
+ takeRightWhile
151
+ } from "./chunk-NTLX2MPV.mjs";
127
152
  import {
128
- zipWith
129
- } from "./chunk-4KYXHZ4R.mjs";
153
+ takeWhile
154
+ } from "./chunk-2IXFGSUA.mjs";
130
155
  import {
131
156
  toFilled
132
157
  } from "./chunk-OP4OAKQJ.mjs";
@@ -139,6 +164,9 @@ import {
139
164
  import {
140
165
  unionWith
141
166
  } from "./chunk-2ZCITDMK.mjs";
167
+ import {
168
+ uniqWith
169
+ } from "./chunk-237HGSZS.mjs";
142
170
  import {
143
171
  uniq
144
172
  } from "./chunk-DVK2N4KC.mjs";
@@ -146,11 +174,11 @@ import {
146
174
  uniqBy
147
175
  } from "./chunk-B4COTK4K.mjs";
148
176
  import {
149
- uniqWith
150
- } from "./chunk-237HGSZS.mjs";
177
+ orderBy
178
+ } from "./chunk-7B7W36UP.mjs";
151
179
  import {
152
- unzip
153
- } from "./chunk-UYZKMBDO.mjs";
180
+ partition
181
+ } from "./chunk-DN3NOZ3H.mjs";
154
182
  import {
155
183
  sample
156
184
  } from "./chunk-2KNLZB7V.mjs";
@@ -176,11 +204,11 @@ import {
176
204
  takeRight
177
205
  } from "./chunk-N3QYJX4T.mjs";
178
206
  import {
179
- takeRightWhile
180
- } from "./chunk-NTLX2MPV.mjs";
207
+ initial
208
+ } from "./chunk-XPSOKBRZ.mjs";
181
209
  import {
182
- takeWhile
183
- } from "./chunk-2IXFGSUA.mjs";
210
+ intersection
211
+ } from "./chunk-FVVSE2F2.mjs";
184
212
  import {
185
213
  intersectionBy
186
214
  } from "./chunk-O6UXZR3U.mjs";
@@ -200,14 +228,17 @@ import {
200
228
  minBy
201
229
  } from "./chunk-IJD7FE2Z.mjs";
202
230
  import {
203
- orderBy
204
- } from "./chunk-7B7W36UP.mjs";
231
+ fill
232
+ } from "./chunk-YFN6KOC4.mjs";
205
233
  import {
206
- partition
207
- } from "./chunk-DN3NOZ3H.mjs";
234
+ flatMap
235
+ } from "./chunk-UY76KTPE.mjs";
208
236
  import {
209
237
  flattenDeep
210
238
  } from "./chunk-ML727RRJ.mjs";
239
+ import {
240
+ flatten
241
+ } from "./chunk-33MSBDC6.mjs";
211
242
  import {
212
243
  forEachRight
213
244
  } from "./chunk-IEA53J7P.mjs";
@@ -218,11 +249,11 @@ import {
218
249
  head
219
250
  } from "./chunk-HM2JT2RX.mjs";
220
251
  import {
221
- initial
222
- } from "./chunk-XPSOKBRZ.mjs";
252
+ countBy
253
+ } from "./chunk-CRSKT4WW.mjs";
223
254
  import {
224
- intersection
225
- } from "./chunk-FVVSE2F2.mjs";
255
+ difference
256
+ } from "./chunk-JPUKH67K.mjs";
226
257
  import {
227
258
  differenceBy
228
259
  } from "./chunk-LVWX5B43.mjs";
@@ -241,27 +272,6 @@ import {
241
272
  import {
242
273
  dropWhile
243
274
  } from "./chunk-LJ2C6MVP.mjs";
244
- import {
245
- fill
246
- } from "./chunk-YFN6KOC4.mjs";
247
- import {
248
- flatMap
249
- } from "./chunk-UY76KTPE.mjs";
250
- import {
251
- flatten
252
- } from "./chunk-33MSBDC6.mjs";
253
- import {
254
- chunk
255
- } from "./chunk-E6C5EZQA.mjs";
256
- import {
257
- compact
258
- } from "./chunk-DTJJIMKJ.mjs";
259
- import {
260
- countBy
261
- } from "./chunk-CRSKT4WW.mjs";
262
- import {
263
- difference
264
- } from "./chunk-JPUKH67K.mjs";
265
275
  import "./chunk-F47GLYUU.mjs";
266
276
  import {
267
277
  AbortError
@@ -269,22 +279,12 @@ import {
269
279
  import {
270
280
  TimeoutError
271
281
  } from "./chunk-KIOYQRMQ.mjs";
272
- import "./chunk-236H5JZJ.mjs";
273
282
  import {
274
- negate
275
- } from "./chunk-BOOQBJN2.mjs";
276
- import {
277
- noop
278
- } from "./chunk-LKXCOLNY.mjs";
279
- import {
280
- once
281
- } from "./chunk-CMBC4MXG.mjs";
282
- import {
283
- throttle
284
- } from "./chunk-QOJGMVVR.mjs";
283
+ chunk
284
+ } from "./chunk-E6C5EZQA.mjs";
285
285
  import {
286
- debounce
287
- } from "./chunk-3IP4JVLL.mjs";
286
+ compact
287
+ } from "./chunk-DTJJIMKJ.mjs";
288
288
  import "./chunk-24FKGR6U.mjs";
289
289
  export {
290
290
  AbortError,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/predicate/index.ts","../../src/array/uniq.ts","../../src/array/union.ts","../../src/predicate/isEqual.ts","../../src/predicate/isNil.ts","../../src/predicate/isNotNil.ts","../../src/predicate/isNull.ts","../../src/predicate/isUndefined.ts","../../src/predicate/isLength.ts","../../src/predicate/isPlainObject.ts","../../src/predicate/isFunction.ts","../../src/predicate/isArrayLike.ts"],"sourcesContent":["export { isEqual } from './isEqual.ts';\nexport { isNil } from './isNil.ts';\nexport { isNotNil } from './isNotNil.ts';\nexport { isNull } from './isNull.ts';\nexport { isUndefined } from './isUndefined.ts';\nexport { isLength } from './isLength.ts';\nexport { isPlainObject } from './isPlainObject.ts';\nexport { isFunction } from './isFunction.ts';\nexport { isArrayLike } from './isArrayLike.ts';\n","/**\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 * @template T - The type of elements in the array.\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: readonly T[]): T[] {\n return Array.from(new Set(arr));\n}\n","import { uniq } from './uniq.ts';\n\n/**\n * Creates an array of unique values from all given arrays.\n *\n * This function takes two arrays, merges them into a single array, and returns a new array\n * containing only the unique values from the merged array.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr1 - The first array to merge and filter for unique values.\n * @param {T[]} arr2 - The second array to merge and filter for unique values.\n * @returns {T[]} A new array of unique values.\n *\n * @example\n * const array1 = [1, 2, 3];\n * const array2 = [3, 4, 5];\n * const result = union(array1, array2);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function union<T>(arr1: readonly T[], arr2: readonly T[]): T[] {\n return uniq(arr1.concat(arr2));\n}\n","import { union } from \"../array/union.ts\";\n\n/**\n * Checks if two values are equal, including support for `Date`, `RegExp`, and deep object comparison.\n *\n * @param {unknown} a - The first value to compare.\n * @param {unknown} b - The second value to compare.\n * @returns {boolean} `true` if the values are equal, otherwise `false`.\n *\n * @example\n * isEqual(1, 1); // true\n * isEqual({ a: 1 }, { a: 1 }); // true\n * isEqual(/abc/g, /abc/g); // true\n * isEqual(new Date('2020-01-01'), new Date('2020-01-01')); // true\n * isEqual([1, 2, 3], [1, 2, 3]); // true\n */\nexport function isEqual(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) {\n return true;\n }\n\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n if (a instanceof RegExp && b instanceof RegExp) {\n return a.source === b.source && a.flags === b.flags;\n }\n\n if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) {\n return false;\n }\n\n const aKeys = Object.keys(a as object);\n const bKeys = Object.keys(b as object);\n\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n\n // check if all keys in both arrays match\n if (union(aKeys, bKeys).length !== aKeys.length) {\n return false;\n }\n\n for (let i = 0; i < aKeys.length; i++) {\n const propKey = aKeys[i];\n const aProp = (a as any)[propKey];\n const bProp = (b as any)[propKey];\n \n if (!isEqual(aProp, bProp)) {\n return false;\n }\n }\n\n return true;\n}\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;\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 * @template T - The type of value.\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","export function isLength(value: unknown): value is number {\n return typeof value === 'number' && value > -1 && value % 1 === 0 && value <= Number.MAX_SAFE_INTEGER;\n}\n","/**\n * Checks if a given value is a plain object.\n * \n * @param {object} object - The value to check.\n * @returns {boolean} - True if the value is a plain object, otherwise false.\n * \n * @example\n * console.log(isPlainObject({})); // true\n * console.log(isPlainObject([])); // false\n * console.log(isPlainObject(null)); // false\n * console.log(isPlainObject(Object.create(null))); // true\n * console.log(Buffer.from('hello, world')); // false\n */\nexport function isPlainObject(object: object): boolean {\n if (typeof object !== 'object') {\n return false;\n }\n\n if (object == null) {\n return false;\n }\n\n if (Object.getPrototypeOf(object) === null) {\n return true;\n }\n\n if (object.toString() !== '[object Object]') {\n return false;\n }\n\n let proto = object;\n\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n\n return Object.getPrototypeOf(object) === proto;\n}","/**\n * Checks if `value` is a function.\n *\n * @param {unknown} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n *\n * @example\n * isFunction(Array.prototype.slice); // true\n * isFunction(async function () {}); // true\n * isFunction(function* () {}); // true\n * isFunction(Proxy); // true\n * isFunction(Int8Array); // true\n */\nexport function isFunction(value: unknown): value is (...args: unknown[]) => unknown {\n return typeof value === 'function';\n}\n","import { isLength } from './isLength';\n\n/**\n * Checks if `value` is array-like.\n *\n * @param {unknown} value The value to check.\n * @returns {value is ArrayLike<unknown>} Returns `true` if `value` is array-like, else `false`.\n *\n * @example\n * isArrayLike([1, 2, 3]); // true\n * isArrayLike('abc'); // true\n * isArrayLike({ 0: 'a', length: 1 }); // true\n * isArrayLike({}); // false\n * isArrayLike(null); // false\n * isArrayLike(undefined); // false\n */\nexport function isArrayLike(value: unknown): value is ArrayLike<unknown> {\n return value != null && typeof value !== 'function' && isLength((value as ArrayLike<unknown>).length);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACeO,SAAS,KAAQ,KAAwB;AAC9C,SAAO,MAAM,KAAK,IAAI,IAAI,GAAG,CAAC;AAChC;;;ACEO,SAAS,MAAS,MAAoB,MAAyB;AACpE,SAAO,KAAK,KAAK,OAAO,IAAI,CAAC;AAC/B;;;ACLO,SAAS,QAAQ,GAAY,GAAqB;AACvD,MAAI,OAAO,GAAG,GAAG,CAAC,GAAG;AACnB,WAAO;AAAA,EACT;AAEA,MAAI,aAAa,QAAQ,aAAa,MAAM;AAC1C,WAAO,E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,OAAO,SAAS,MAAM,mBAAmB;AAC3C,WAAO;AAAA,EACT;AAEA,MAAI,QAAQ;AAEZ,SAAO,OAAO,eAAe,KAAK,MAAM,MAAM;AAC5C,YAAQ,OAAO,eAAe,KAAK;AAAA,EACrC;AAEA,SAAO,OAAO,eAAe,MAAM,MAAM;AAC3C;;;ACxBO,SAAS,WAAW,OAA0D;AACnF,SAAO,OAAO,UAAU;AAC1B;;;ACCO,SAAS,YAAY,OAA6C;AACvE,SAAO,SAAS,QAAQ,OAAO,UAAU,cAAc,SAAU,MAA6B,MAAM;AACtG;","names":[]}
1
+ {"version":3,"sources":["../../src/predicate/index.ts","../../src/array/uniq.ts","../../src/array/union.ts","../../src/predicate/isEqual.ts","../../src/predicate/isNil.ts","../../src/predicate/isNotNil.ts","../../src/predicate/isNull.ts","../../src/predicate/isUndefined.ts","../../src/predicate/isLength.ts","../../src/predicate/isPlainObject.ts","../../src/predicate/isFunction.ts","../../src/predicate/isArrayLike.ts"],"sourcesContent":["export { isEqual } from './isEqual.ts';\nexport { isNil } from './isNil.ts';\nexport { isNotNil } from './isNotNil.ts';\nexport { isNull } from './isNull.ts';\nexport { isUndefined } from './isUndefined.ts';\nexport { isLength } from './isLength.ts';\nexport { isPlainObject } from './isPlainObject.ts';\nexport { isFunction } from './isFunction.ts';\nexport { isArrayLike } from './isArrayLike.ts';\n","/**\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 * @template T - The type of elements in the array.\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: readonly T[]): T[] {\n return Array.from(new Set(arr));\n}\n","import { uniq } from './uniq.ts';\n\n/**\n * Creates an array of unique values from all given arrays.\n *\n * This function takes two arrays, merges them into a single array, and returns a new array\n * containing only the unique values from the merged array.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr1 - The first array to merge and filter for unique values.\n * @param {T[]} arr2 - The second array to merge and filter for unique values.\n * @returns {T[]} A new array of unique values.\n *\n * @example\n * const array1 = [1, 2, 3];\n * const array2 = [3, 4, 5];\n * const result = union(array1, array2);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function union<T>(arr1: readonly T[], arr2: readonly T[]): T[] {\n return uniq(arr1.concat(arr2));\n}\n","import { union } from \"../array/union.ts\";\n\n/**\n * Checks if two values are equal, including support for `Date`, `RegExp`, and deep object comparison.\n *\n * @param {unknown} a - The first value to compare.\n * @param {unknown} b - The second value to compare.\n * @returns {boolean} `true` if the values are equal, otherwise `false`.\n *\n * @example\n * isEqual(1, 1); // true\n * isEqual({ a: 1 }, { a: 1 }); // true\n * isEqual(/abc/g, /abc/g); // true\n * isEqual(new Date('2020-01-01'), new Date('2020-01-01')); // true\n * isEqual([1, 2, 3], [1, 2, 3]); // true\n */\nexport function isEqual(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) {\n return true;\n }\n\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n if (a instanceof RegExp && b instanceof RegExp) {\n return a.source === b.source && a.flags === b.flags;\n }\n\n if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) {\n return false;\n }\n\n const aKeys = Object.keys(a as object);\n const bKeys = Object.keys(b as object);\n\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n\n // check if all keys in both arrays match\n if (union(aKeys, bKeys).length !== aKeys.length) {\n return false;\n }\n\n for (let i = 0; i < aKeys.length; i++) {\n const propKey = aKeys[i];\n const aProp = (a as any)[propKey];\n const bProp = (b as any)[propKey];\n \n if (!isEqual(aProp, bProp)) {\n return false;\n }\n }\n\n return true;\n}\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;\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 * @template T - The type of value.\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","export function isLength(value: unknown): value is number {\n return typeof value === 'number' && value > -1 && value % 1 === 0 && value <= Number.MAX_SAFE_INTEGER;\n}\n","/**\n * Checks if a given value is a plain object.\n * \n * @param {object} object - The value to check.\n * @returns {boolean} - True if the value is a plain object, otherwise false.\n * \n * @example\n * console.log(isPlainObject({})); // true\n * console.log(isPlainObject([])); // false\n * console.log(isPlainObject(null)); // false\n * console.log(isPlainObject(Object.create(null))); // true\n * console.log(Buffer.from('hello, world')); // false\n */\nexport function isPlainObject(object: object): boolean {\n if (typeof object !== 'object') {\n return false;\n }\n\n if (object == null) {\n return false;\n }\n\n if (Object.getPrototypeOf(object) === null) {\n return true;\n }\n\n if (object.toString() !== '[object Object]') {\n return false;\n }\n\n let proto = object;\n\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n\n return Object.getPrototypeOf(object) === proto;\n}","/**\n * Checks if `value` is a function.\n *\n * @param {unknown} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n *\n * @example\n * isFunction(Array.prototype.slice); // true\n * isFunction(async function () {}); // true\n * isFunction(function* () {}); // true\n * isFunction(Proxy); // true\n * isFunction(Int8Array); // true\n */\nexport function isFunction(value: unknown): value is (...args: unknown[]) => unknown {\n return typeof value === 'function';\n}\n","import { isLength } from \"./isLength.ts\";\n\n/**\n * Checks if `value` is array-like.\n *\n * @param {unknown} value The value to check.\n * @returns {value is ArrayLike<unknown>} Returns `true` if `value` is array-like, else `false`.\n *\n * @example\n * isArrayLike([1, 2, 3]); // true\n * isArrayLike('abc'); // true\n * isArrayLike({ 0: 'a', length: 1 }); // true\n * isArrayLike({}); // false\n * isArrayLike(null); // false\n * isArrayLike(undefined); // false\n */\nexport function isArrayLike(value: unknown): value is ArrayLike<unknown> {\n return value != null && typeof value !== \"function\" &&\n isLength((value as ArrayLike<unknown>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M,QAAQ,MAAM;AAC7B;;;ACEO,SAAS,OAAO,GAAuB;AAC5C,SAAO,MAAM;AACf;;;ACFO,SAAS,YAAY,GAA4B;AACtD,SAAO,MAAM;AACf;;;ACtBO,SAAS,SAAS,OAAiC;AACxD,SAAO,OAAO,UAAU,YAAY,QAAQ,MAAM,QAAQ,MAAM,KAAK,SAAS,OAAO;AACvF;;;ACWO,SAAS,cAAc,QAAyB;AACrD,MAAI,OAAO,WAAW,UAAU;AAC9B,WAAO;AAAA,EACT;AAEA,MAAI,UAAU,MAAM;AAClB,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,eAAe,MAAM,MAAM,MAAM;AAC1C,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,SAAS,MAAM,mBAAmB;AAC3C,WAAO;AAAA,EACT;AAEA,MAAI,QAAQ;AAEZ,SAAO,OAAO,eAAe,KAAK,MAAM,MAAM;AAC5C,YAAQ,OAAO,eAAe,KAAK;AAAA,EACrC;AAEA,SAAO,OAAO,eAAe,MAAM,MAAM;AAC3C;;;ACxBO,SAAS,WAAW,OAA0D;AACnF,SAAO,OAAO,UAAU;AAC1B;;;ACCO,SAAS,YAAY,OAA6C;AACvE,SAAO,SAAS,QAAQ,OAAO,UAAU,cACvC,SAAU,MAA6B,MAAM;AACjD;","names":[]}
@@ -13,7 +13,7 @@ import {
13
13
  } from "../chunk-VH2PV426.mjs";
14
14
  import {
15
15
  isArrayLike
16
- } from "../chunk-J4SHAMXJ.mjs";
16
+ } from "../chunk-LPZZIY5Z.mjs";
17
17
  import {
18
18
  isEqual
19
19
  } from "../chunk-JYSV56US.mjs";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/predicate/isArrayLike.ts","../../src/predicate/isLength.ts"],"sourcesContent":["import { isLength } from './isLength';\n\n/**\n * Checks if `value` is array-like.\n *\n * @param {unknown} value The value to check.\n * @returns {value is ArrayLike<unknown>} Returns `true` if `value` is array-like, else `false`.\n *\n * @example\n * isArrayLike([1, 2, 3]); // true\n * isArrayLike('abc'); // true\n * isArrayLike({ 0: 'a', length: 1 }); // true\n * isArrayLike({}); // false\n * isArrayLike(null); // false\n * isArrayLike(undefined); // false\n */\nexport function isArrayLike(value: unknown): value is ArrayLike<unknown> {\n return value != null && typeof value !== 'function' && isLength((value as ArrayLike<unknown>).length);\n}\n","export function isLength(value: unknown): value is number {\n return typeof value === 'number' && value > -1 && value % 1 === 0 && value <= Number.MAX_SAFE_INTEGER;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,SAAS,SAAS,OAAiC;AACxD,SAAO,OAAO,UAAU,YAAY,QAAQ,MAAM,QAAQ,MAAM,KAAK,SAAS,OAAO;AACvF;;;ADcO,SAAS,YAAY,OAA6C;AACvE,SAAO,SAAS,QAAQ,OAAO,UAAU,cAAc,SAAU,MAA6B,MAAM;AACtG;","names":[]}
1
+ {"version":3,"sources":["../../src/predicate/isArrayLike.ts","../../src/predicate/isLength.ts"],"sourcesContent":["import { isLength } from \"./isLength.ts\";\n\n/**\n * Checks if `value` is array-like.\n *\n * @param {unknown} value The value to check.\n * @returns {value is ArrayLike<unknown>} Returns `true` if `value` is array-like, else `false`.\n *\n * @example\n * isArrayLike([1, 2, 3]); // true\n * isArrayLike('abc'); // true\n * isArrayLike({ 0: 'a', length: 1 }); // true\n * isArrayLike({}); // false\n * isArrayLike(null); // false\n * isArrayLike(undefined); // false\n */\nexport function isArrayLike(value: unknown): value is ArrayLike<unknown> {\n return value != null && typeof value !== \"function\" &&\n isLength((value as ArrayLike<unknown>).length);\n}\n","export function isLength(value: unknown): value is number {\n return typeof value === 'number' && value > -1 && value % 1 === 0 && value <= Number.MAX_SAFE_INTEGER;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,SAAS,SAAS,OAAiC;AACxD,SAAO,OAAO,UAAU,YAAY,QAAQ,MAAM,QAAQ,MAAM,KAAK,SAAS,OAAO;AACvF;;;ADcO,SAAS,YAAY,OAA6C;AACvE,SAAO,SAAS,QAAQ,OAAO,UAAU,cACvC,SAAU,MAA6B,MAAM;AACjD;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isArrayLike
3
- } from "../chunk-J4SHAMXJ.mjs";
3
+ } from "../chunk-LPZZIY5Z.mjs";
4
4
  import "../chunk-27QMXBLJ.mjs";
5
5
  import "../chunk-24FKGR6U.mjs";
6
6
  export {
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.13.1-dev.305+bd7cb34c",
4
+ "version": "1.13.1-dev.307+925ee3be",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/predicate/isArrayLike.ts"],"sourcesContent":["import { isLength } from './isLength';\n\n/**\n * Checks if `value` is array-like.\n *\n * @param {unknown} value The value to check.\n * @returns {value is ArrayLike<unknown>} Returns `true` if `value` is array-like, else `false`.\n *\n * @example\n * isArrayLike([1, 2, 3]); // true\n * isArrayLike('abc'); // true\n * isArrayLike({ 0: 'a', length: 1 }); // true\n * isArrayLike({}); // false\n * isArrayLike(null); // false\n * isArrayLike(undefined); // false\n */\nexport function isArrayLike(value: unknown): value is ArrayLike<unknown> {\n return value != null && typeof value !== 'function' && isLength((value as ArrayLike<unknown>).length);\n}\n"],"mappings":";;;;;AAgBO,SAAS,YAAY,OAA6C;AACvE,SAAO,SAAS,QAAQ,OAAO,UAAU,cAAc,SAAU,MAA6B,MAAM;AACtG;","names":[]}