es-toolkit 1.23.0-dev.748 → 1.23.0-dev.750
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/_chunk/{toMerged-CkfNn9.js → toMerged-DDLv0D.js} +4 -3
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/_internal/MAX_ARRAY_LENGTH.mjs +3 -0
- package/dist/compat/index.d.mts +1 -0
- package/dist/compat/index.d.ts +1 -0
- package/dist/compat/index.js +12 -1
- package/dist/compat/index.mjs +1 -0
- package/dist/compat/util/toLength.d.mts +16 -0
- package/dist/compat/util/toLength.d.ts +16 -0
- package/dist/compat/util/toLength.mjs +12 -0
- package/dist/index.js +1 -1
- package/dist/object/index.js +1 -1
- package/dist/object/pickBy.mjs +4 -3
- package/package.json +1 -1
package/dist/compat/index.d.mts
CHANGED
|
@@ -206,6 +206,7 @@ export { eq } from './util/eq.mjs';
|
|
|
206
206
|
export { times } from './util/times.mjs';
|
|
207
207
|
export { toFinite } from './util/toFinite.mjs';
|
|
208
208
|
export { toInteger } from './util/toInteger.mjs';
|
|
209
|
+
export { toLength } from './util/toLength.mjs';
|
|
209
210
|
export { toNumber } from './util/toNumber.mjs';
|
|
210
211
|
export { toPath } from './util/toPath.mjs';
|
|
211
212
|
export { toString } from './util/toString.mjs';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -206,6 +206,7 @@ export { eq } from './util/eq.js';
|
|
|
206
206
|
export { times } from './util/times.js';
|
|
207
207
|
export { toFinite } from './util/toFinite.js';
|
|
208
208
|
export { toInteger } from './util/toInteger.js';
|
|
209
|
+
export { toLength } from './util/toLength.js';
|
|
209
210
|
export { toNumber } from './util/toNumber.js';
|
|
210
211
|
export { toPath } from './util/toPath.js';
|
|
211
212
|
export { toString } from './util/toString.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -8,7 +8,7 @@ const flowRight$1 = require('../_chunk/flowRight-Cf9ldK.js');
|
|
|
8
8
|
const noop = require('../_chunk/noop-2IwLUk.js');
|
|
9
9
|
const sumBy = require('../_chunk/sumBy-BkErWJ.js');
|
|
10
10
|
const randomInt = require('../_chunk/randomInt-CF7bZK.js');
|
|
11
|
-
const toMerged = require('../_chunk/toMerged-
|
|
11
|
+
const toMerged = require('../_chunk/toMerged-DDLv0D.js');
|
|
12
12
|
const isPlainObject$1 = require('../_chunk/isPlainObject-DgrsU7.js');
|
|
13
13
|
const isWeakSet$1 = require('../_chunk/isWeakSet-Bd6nry.js');
|
|
14
14
|
const upperFirst = require('../_chunk/upperFirst-BUECmK.js');
|
|
@@ -2006,6 +2006,16 @@ function times(n, iteratee) {
|
|
|
2006
2006
|
return result;
|
|
2007
2007
|
}
|
|
2008
2008
|
|
|
2009
|
+
const MAX_ARRAY_LENGTH = 4_294_967_295;
|
|
2010
|
+
|
|
2011
|
+
function toLength(value) {
|
|
2012
|
+
if (value == null) {
|
|
2013
|
+
return 0;
|
|
2014
|
+
}
|
|
2015
|
+
const length = Math.floor(Number(value));
|
|
2016
|
+
return clamp(length, 0, MAX_ARRAY_LENGTH);
|
|
2017
|
+
}
|
|
2018
|
+
|
|
2009
2019
|
function defaultTo(value, defaultValue) {
|
|
2010
2020
|
if (value == null || Number.isNaN(value)) {
|
|
2011
2021
|
return defaultValue;
|
|
@@ -2217,6 +2227,7 @@ exports.times = times;
|
|
|
2217
2227
|
exports.toDefaulted = toDefaulted;
|
|
2218
2228
|
exports.toFinite = toFinite;
|
|
2219
2229
|
exports.toInteger = toInteger;
|
|
2230
|
+
exports.toLength = toLength;
|
|
2220
2231
|
exports.toNumber = toNumber;
|
|
2221
2232
|
exports.toPath = toPath;
|
|
2222
2233
|
exports.toString = toString;
|
package/dist/compat/index.mjs
CHANGED
|
@@ -206,6 +206,7 @@ export { constant } from './util/constant.mjs';
|
|
|
206
206
|
export { times } from './util/times.mjs';
|
|
207
207
|
export { toFinite } from './util/toFinite.mjs';
|
|
208
208
|
export { toInteger } from './util/toInteger.mjs';
|
|
209
|
+
export { toLength } from './util/toLength.mjs';
|
|
209
210
|
export { toNumber } from './util/toNumber.mjs';
|
|
210
211
|
export { toPath } from './util/toPath.mjs';
|
|
211
212
|
export { toString } from './util/toString.mjs';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts value to an integer suitable for use as the length of an array-like object.
|
|
3
|
+
*
|
|
4
|
+
* @param {unknown} value - The value to convert to an array length.
|
|
5
|
+
* @returns {number} Returns the converted integer.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* toLength(3.2) // => 3
|
|
9
|
+
* toLength(-1) // => 0
|
|
10
|
+
* toLength(1.9) // => 1
|
|
11
|
+
* toLength('42') // => 42
|
|
12
|
+
* toLength(null) // => 0
|
|
13
|
+
*/
|
|
14
|
+
declare function toLength(value?: unknown): number;
|
|
15
|
+
|
|
16
|
+
export { toLength };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts value to an integer suitable for use as the length of an array-like object.
|
|
3
|
+
*
|
|
4
|
+
* @param {unknown} value - The value to convert to an array length.
|
|
5
|
+
* @returns {number} Returns the converted integer.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* toLength(3.2) // => 3
|
|
9
|
+
* toLength(-1) // => 0
|
|
10
|
+
* toLength(1.9) // => 1
|
|
11
|
+
* toLength('42') // => 42
|
|
12
|
+
* toLength(null) // => 0
|
|
13
|
+
*/
|
|
14
|
+
declare function toLength(value?: unknown): number;
|
|
15
|
+
|
|
16
|
+
export { toLength };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MAX_ARRAY_LENGTH } from '../_internal/MAX_ARRAY_LENGTH.mjs';
|
|
2
|
+
import { clamp } from '../math/clamp.mjs';
|
|
3
|
+
|
|
4
|
+
function toLength(value) {
|
|
5
|
+
if (value == null) {
|
|
6
|
+
return 0;
|
|
7
|
+
}
|
|
8
|
+
const length = Math.floor(Number(value));
|
|
9
|
+
return clamp(length, 0, MAX_ARRAY_LENGTH);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { toLength };
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ const noop = require('./_chunk/noop-2IwLUk.js');
|
|
|
11
11
|
const sumBy = require('./_chunk/sumBy-BkErWJ.js');
|
|
12
12
|
const randomInt = require('./_chunk/randomInt-CF7bZK.js');
|
|
13
13
|
const math_index = require('./math/index.js');
|
|
14
|
-
const toMerged = require('./_chunk/toMerged-
|
|
14
|
+
const toMerged = require('./_chunk/toMerged-DDLv0D.js');
|
|
15
15
|
const object_index = require('./object/index.js');
|
|
16
16
|
const isWeakSet = require('./_chunk/isWeakSet-Bd6nry.js');
|
|
17
17
|
const predicate_index = require('./predicate/index.js');
|
package/dist/object/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const toMerged = require('../_chunk/toMerged-
|
|
5
|
+
const toMerged = require('../_chunk/toMerged-DDLv0D.js');
|
|
6
6
|
|
|
7
7
|
function mergeWith(target, source, merge) {
|
|
8
8
|
const sourceKeys = Object.keys(source);
|
package/dist/object/pickBy.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
function pickBy(obj, shouldPick) {
|
|
2
2
|
const result = {};
|
|
3
|
-
const
|
|
4
|
-
for (let i = 0; i <
|
|
5
|
-
const
|
|
3
|
+
const keys = Object.keys(obj);
|
|
4
|
+
for (let i = 0; i < keys.length; i++) {
|
|
5
|
+
const key = keys[i];
|
|
6
|
+
const value = obj[key];
|
|
6
7
|
if (shouldPick(value, key)) {
|
|
7
8
|
result[key] = value;
|
|
8
9
|
}
|
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.23.0-dev.
|
|
4
|
+
"version": "1.23.0-dev.750+a6e14159",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|