es-toolkit 1.20.0-dev.627 → 1.20.0-dev.628

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Creates a deep clone of the given object.
3
+ *
4
+ * @template T - The type of the object.
5
+ * @param {T} obj - The object to clone.
6
+ * @returns {T} - A deep clone of the given object.
7
+ *
8
+ * @example
9
+ * // Clone a primitive values
10
+ * const num = 29;
11
+ * const clonedNum = clone(num);
12
+ * console.log(clonedNum); // 29
13
+ * console.log(clonedNum === num) ; // true
14
+ *
15
+ * @example
16
+ * // Clone an array
17
+ * const arr = [1, 2, 3];
18
+ * const clonedArr = clone(arr);
19
+ * console.log(clonedArr); // [1, 2, 3]
20
+ * console.log(clonedArr === arr); // false
21
+ *
22
+ * @example
23
+ * // Clone an array with nested objects
24
+ * const arr = [1, { a: 1 }, [1, 2, 3]];
25
+ * const clonedArr = clone(arr);
26
+ * arr[1].a = 2;
27
+ * console.log(arr); // [2, { a: 2 }, [1, 2, 3]]
28
+ * console.log(clonedArr); // [1, { a: 1 }, [1, 2, 3]]
29
+ * console.log(clonedArr === arr); // false
30
+ *
31
+ * @example
32
+ * // Clone an object
33
+ * const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };
34
+ * const clonedObj = clone(obj);
35
+ * console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }
36
+ * console.log(clonedObj === obj); // false
37
+ *
38
+ * @example
39
+ * // Clone an object with nested objects
40
+ * const obj = { a: 1, b: { c: 1 } };
41
+ * const clonedObj = clone(obj);
42
+ * obj.b.c = 2;
43
+ * console.log(obj); // { a: 1, b: { c: 2 } }
44
+ * console.log(clonedObj); // { a: 1, b: { c: 1 } }
45
+ * console.log(clonedObj === obj); // false
46
+ */
47
+ declare function cloneDeep<T>(obj: T): T;
48
+
49
+ export { cloneDeep };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Checks if the given value is a non-primitive, array-like object.
3
+ *
4
+ * @param {unknown} value The value to check.
5
+ * @returns {value is ArrayLike<unknown> & object} `true` if the value is a non-primitive, array-like object, `false` otherwise.
6
+ *
7
+ * @example
8
+ * isArrayLikeObject([1, 2, 3]); // true
9
+ * isArrayLikeObject({ 0: 'a', length: 1 }); // true
10
+ * isArrayLikeObject('abc'); // false
11
+ * isArrayLikeObject(()=>{}); // false
12
+ */
13
+ declare function isArrayLikeObject(value: unknown): value is ArrayLike<unknown> & object;
14
+
15
+ export { isArrayLikeObject };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Checks if the given value is a non-primitive, array-like object.
3
+ *
4
+ * @param {unknown} value The value to check.
5
+ * @returns {value is ArrayLike<unknown> & object} `true` if the value is a non-primitive, array-like object, `false` otherwise.
6
+ *
7
+ * @example
8
+ * isArrayLikeObject([1, 2, 3]); // true
9
+ * isArrayLikeObject({ 0: 'a', length: 1 }); // true
10
+ * isArrayLikeObject('abc'); // false
11
+ * isArrayLikeObject(()=>{}); // false
12
+ */
13
+ declare function isArrayLikeObject(value: unknown): value is ArrayLike<unknown> & object;
14
+
15
+ export { isArrayLikeObject };
@@ -0,0 +1,8 @@
1
+ import { isArrayLike } from './isArrayLike.mjs';
2
+ import { isObjectLike } from './isObjectLike.mjs';
3
+
4
+ function isArrayLikeObject(value) {
5
+ return isObjectLike(value) && isArrayLike(value);
6
+ }
7
+
8
+ export { isArrayLikeObject };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Checks if a given value is null or undefined.
3
+ *
4
+ * This function tests whether the provided value is either `null` or `undefined`.
5
+ * It returns `true` if the value is `null` or `undefined`, and `false` otherwise.
6
+ *
7
+ * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`.
8
+ *
9
+ * @param {unknown} x - The value to test for null or undefined.
10
+ * @returns {boolean} `true` if the value is null or undefined, `false` otherwise.
11
+ *
12
+ * @example
13
+ * const value1 = null;
14
+ * const value2 = undefined;
15
+ * const value3 = 42;
16
+ * const result1 = isNil(value1); // true
17
+ * const result2 = isNil(value2); // true
18
+ * const result3 = isNil(value3); // false
19
+ */
20
+ declare function isNil(x?: unknown): x is null | undefined;
21
+
22
+ export { isNil };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Checks if a given value is null or undefined.
3
+ *
4
+ * This function tests whether the provided value is either `null` or `undefined`.
5
+ * It returns `true` if the value is `null` or `undefined`, and `false` otherwise.
6
+ *
7
+ * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`.
8
+ *
9
+ * @param {unknown} x - The value to test for null or undefined.
10
+ * @returns {boolean} `true` if the value is null or undefined, `false` otherwise.
11
+ *
12
+ * @example
13
+ * const value1 = null;
14
+ * const value2 = undefined;
15
+ * const value3 = 42;
16
+ * const result1 = isNil(value1); // true
17
+ * const result2 = isNil(value2); // true
18
+ * const result3 = isNil(value3); // false
19
+ */
20
+ declare function isNil(x?: unknown): x is null | undefined;
21
+
22
+ export { isNil };
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.20.0-dev.627+0c4edbb2",
4
+ "version": "1.20.0-dev.628+0b0ff547",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {