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.
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/index.d.mts +5 -4
- package/dist/compat/index.d.ts +5 -4
- package/dist/compat/index.js +101 -6
- package/dist/compat/index.mjs +6 -5
- package/dist/compat/math/inRange.d.mts +27 -0
- package/dist/compat/math/inRange.d.ts +27 -0
- package/dist/compat/math/inRange.mjs +28 -0
- package/dist/compat/math/random.d.mts +50 -0
- package/dist/compat/math/random.d.ts +50 -0
- package/dist/compat/math/random.mjs +70 -0
- package/dist/compat/object/cloneDeep.d.mts +49 -0
- package/dist/compat/object/cloneDeep.d.ts +49 -0
- package/dist/compat/predicate/isArrayLikeObject.d.mts +15 -0
- package/dist/compat/predicate/isArrayLikeObject.d.ts +15 -0
- package/dist/compat/predicate/isArrayLikeObject.mjs +8 -0
- package/dist/compat/predicate/isNil.d.mts +22 -0
- package/dist/compat/predicate/isNil.d.ts +22 -0
- package/package.json +1 -1
|
@@ -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,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.
|
|
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": {
|