es-toolkit 1.47.1-dev.1856 → 1.47.1-dev.1858
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region src/compat/math/random.d.ts
|
|
2
2
|
/**
|
|
3
3
|
* Generate a random number between 0 and 1.
|
|
4
|
-
* @param [floating] - Whether to return a floating point number. Defaults to
|
|
4
|
+
* @param [floating] - Whether to return a floating point number. Defaults to false.
|
|
5
5
|
* @returns A random number between 0 and 1.
|
|
6
6
|
* @example
|
|
7
7
|
* random(); // Returns a random number between 0 and 1
|
|
@@ -12,7 +12,7 @@ declare function random(floating?: boolean): number;
|
|
|
12
12
|
/**
|
|
13
13
|
* Generate a random number between 0 and max.
|
|
14
14
|
* @param max - The upper bound (exclusive).
|
|
15
|
-
* @param [floating] - Whether to return a floating point number. Defaults to
|
|
15
|
+
* @param [floating] - Whether to return a floating point number. Defaults to false.
|
|
16
16
|
* @returns A random number between 0 and max.
|
|
17
17
|
* @example
|
|
18
18
|
* random(5); // Returns a random number between 0 and 5
|
|
@@ -24,7 +24,7 @@ declare function random(max: number, floating?: boolean): number;
|
|
|
24
24
|
* Generate a random number between min and max.
|
|
25
25
|
* @param min - The lower bound (inclusive).
|
|
26
26
|
* @param max - The upper bound (exclusive).
|
|
27
|
-
* @param [floating] - Whether to return a floating point number. Defaults to
|
|
27
|
+
* @param [floating] - Whether to return a floating point number. Defaults to false.
|
|
28
28
|
* @returns A random number between min and max.
|
|
29
29
|
* @example
|
|
30
30
|
* random(1, 5); // Returns a random number between 1 and 5
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region src/compat/math/random.d.ts
|
|
2
2
|
/**
|
|
3
3
|
* Generate a random number between 0 and 1.
|
|
4
|
-
* @param [floating] - Whether to return a floating point number. Defaults to
|
|
4
|
+
* @param [floating] - Whether to return a floating point number. Defaults to false.
|
|
5
5
|
* @returns A random number between 0 and 1.
|
|
6
6
|
* @example
|
|
7
7
|
* random(); // Returns a random number between 0 and 1
|
|
@@ -12,7 +12,7 @@ declare function random(floating?: boolean): number;
|
|
|
12
12
|
/**
|
|
13
13
|
* Generate a random number between 0 and max.
|
|
14
14
|
* @param max - The upper bound (exclusive).
|
|
15
|
-
* @param [floating] - Whether to return a floating point number. Defaults to
|
|
15
|
+
* @param [floating] - Whether to return a floating point number. Defaults to false.
|
|
16
16
|
* @returns A random number between 0 and max.
|
|
17
17
|
* @example
|
|
18
18
|
* random(5); // Returns a random number between 0 and 5
|
|
@@ -24,7 +24,7 @@ declare function random(max: number, floating?: boolean): number;
|
|
|
24
24
|
* Generate a random number between min and max.
|
|
25
25
|
* @param min - The lower bound (inclusive).
|
|
26
26
|
* @param max - The upper bound (exclusive).
|
|
27
|
-
* @param [floating] - Whether to return a floating point number. Defaults to
|
|
27
|
+
* @param [floating] - Whether to return a floating point number. Defaults to false.
|
|
28
28
|
* @returns A random number between min and max.
|
|
29
29
|
* @example
|
|
30
30
|
* random(1, 5); // Returns a random number between 1 and 5
|
|
@@ -31,8 +31,8 @@ const require_set = require("./set.js");
|
|
|
31
31
|
* const result = pick(obj, 'a.b');
|
|
32
32
|
* // result will be { 'a.b': 1 }
|
|
33
33
|
*/
|
|
34
|
-
function pick(
|
|
35
|
-
if (require_isNil.isNil(
|
|
34
|
+
function pick(object, ...keysArr) {
|
|
35
|
+
if (require_isNil.isNil(object)) return {};
|
|
36
36
|
const result = {};
|
|
37
37
|
for (let i = 0; i < keysArr.length; i++) {
|
|
38
38
|
let keys = keysArr[i];
|
|
@@ -48,9 +48,9 @@ function pick(obj, ...keysArr) {
|
|
|
48
48
|
break;
|
|
49
49
|
}
|
|
50
50
|
for (const key of keys) {
|
|
51
|
-
const value = require_get.get(
|
|
52
|
-
if (value === void 0 && !require_has.has(
|
|
53
|
-
if (typeof key === "string" && Object.hasOwn(
|
|
51
|
+
const value = require_get.get(object, key);
|
|
52
|
+
if (value === void 0 && !require_has.has(object, key)) continue;
|
|
53
|
+
if (typeof key === "string" && Object.hasOwn(object, key)) result[key] = value;
|
|
54
54
|
else require_set.set(result, key, value);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -31,8 +31,8 @@ import { set } from "./set.mjs";
|
|
|
31
31
|
* const result = pick(obj, 'a.b');
|
|
32
32
|
* // result will be { 'a.b': 1 }
|
|
33
33
|
*/
|
|
34
|
-
function pick(
|
|
35
|
-
if (isNil(
|
|
34
|
+
function pick(object, ...keysArr) {
|
|
35
|
+
if (isNil(object)) return {};
|
|
36
36
|
const result = {};
|
|
37
37
|
for (let i = 0; i < keysArr.length; i++) {
|
|
38
38
|
let keys = keysArr[i];
|
|
@@ -48,9 +48,9 @@ function pick(obj, ...keysArr) {
|
|
|
48
48
|
break;
|
|
49
49
|
}
|
|
50
50
|
for (const key of keys) {
|
|
51
|
-
const value = get(
|
|
52
|
-
if (value === void 0 && !has(
|
|
53
|
-
if (typeof key === "string" && Object.hasOwn(
|
|
51
|
+
const value = get(object, key);
|
|
52
|
+
if (value === void 0 && !has(object, key)) continue;
|
|
53
|
+
if (typeof key === "string" && Object.hasOwn(object, key)) result[key] = value;
|
|
54
54
|
else set(result, key, value);
|
|
55
55
|
}
|
|
56
56
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-toolkit",
|
|
3
|
-
"version": "1.47.1-dev.
|
|
3
|
+
"version": "1.47.1-dev.1858+7655f5e6",
|
|
4
4
|
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
|
|
5
5
|
"homepage": "https://es-toolkit.dev",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|