es-toolkit 1.19.0-dev.621 → 1.19.0-dev.622
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 +1 -1
- package/dist/compat/index.d.ts +1 -1
- package/dist/compat/index.js +11 -1
- package/dist/compat/index.mjs +1 -1
- package/dist/compat/math/clamp.d.mts +32 -0
- package/dist/compat/math/clamp.d.ts +32 -0
- package/dist/compat/math/clamp.mjs +13 -0
- package/dist/math/inRange.d.mts +23 -0
- package/dist/math/inRange.d.ts +23 -0
- package/package.json +1 -1
package/dist/compat/index.d.mts
CHANGED
|
@@ -57,7 +57,6 @@ export { MemoizeCache, memoize } from '../function/memoize.mjs';
|
|
|
57
57
|
export { unary } from '../function/unary.mjs';
|
|
58
58
|
export { partial } from '../function/partial.mjs';
|
|
59
59
|
export { partialRight } from '../function/partialRight.mjs';
|
|
60
|
-
export { clamp } from '../math/clamp.mjs';
|
|
61
60
|
export { inRange } from '../math/inRange.mjs';
|
|
62
61
|
export { mean } from '../math/mean.mjs';
|
|
63
62
|
export { meanBy } from '../math/meanBy.mjs';
|
|
@@ -171,6 +170,7 @@ export { repeat } from './string/repeat.mjs';
|
|
|
171
170
|
export { trim } from './string/trim.mjs';
|
|
172
171
|
export { trimStart } from './string/trimStart.mjs';
|
|
173
172
|
export { trimEnd } from './string/trimEnd.mjs';
|
|
173
|
+
export { clamp } from './math/clamp.mjs';
|
|
174
174
|
export { max } from './math/max.mjs';
|
|
175
175
|
export { min } from './math/min.mjs';
|
|
176
176
|
export { ceil } from './math/ceil.mjs';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -57,7 +57,6 @@ export { MemoizeCache, memoize } from '../function/memoize.js';
|
|
|
57
57
|
export { unary } from '../function/unary.js';
|
|
58
58
|
export { partial } from '../function/partial.js';
|
|
59
59
|
export { partialRight } from '../function/partialRight.js';
|
|
60
|
-
export { clamp } from '../math/clamp.js';
|
|
61
60
|
export { inRange } from '../math/inRange.js';
|
|
62
61
|
export { mean } from '../math/mean.js';
|
|
63
62
|
export { meanBy } from '../math/meanBy.js';
|
|
@@ -171,6 +170,7 @@ export { repeat } from './string/repeat.js';
|
|
|
171
170
|
export { trim } from './string/trim.js';
|
|
172
171
|
export { trimStart } from './string/trimStart.js';
|
|
173
172
|
export { trimEnd } from './string/trimEnd.js';
|
|
173
|
+
export { clamp } from './math/clamp.js';
|
|
174
174
|
export { max } from './math/max.js';
|
|
175
175
|
export { min } from './math/min.js';
|
|
176
176
|
export { ceil } from './math/ceil.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -1442,6 +1442,16 @@ function trimEnd(str, chars, guard) {
|
|
|
1442
1442
|
}
|
|
1443
1443
|
}
|
|
1444
1444
|
|
|
1445
|
+
function clamp(value, bound1, bound2) {
|
|
1446
|
+
if (Number.isNaN(bound1)) {
|
|
1447
|
+
bound1 = 0;
|
|
1448
|
+
}
|
|
1449
|
+
if (Number.isNaN(bound2)) {
|
|
1450
|
+
bound2 = 0;
|
|
1451
|
+
}
|
|
1452
|
+
return range.clamp(value, bound1, bound2);
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1445
1455
|
function max(items = []) {
|
|
1446
1456
|
let maxElement = items[0];
|
|
1447
1457
|
let max = undefined;
|
|
@@ -1566,7 +1576,6 @@ exports.once = rest$1.once;
|
|
|
1566
1576
|
exports.partial = rest$1.partial;
|
|
1567
1577
|
exports.partialRight = rest$1.partialRight;
|
|
1568
1578
|
exports.unary = rest$1.unary;
|
|
1569
|
-
exports.clamp = range.clamp;
|
|
1570
1579
|
exports.inRange = range.inRange;
|
|
1571
1580
|
exports.mean = range.mean;
|
|
1572
1581
|
exports.meanBy = range.meanBy;
|
|
@@ -1609,6 +1618,7 @@ exports.camelCase = camelCase;
|
|
|
1609
1618
|
exports.castArray = castArray;
|
|
1610
1619
|
exports.ceil = ceil;
|
|
1611
1620
|
exports.chunk = chunk;
|
|
1621
|
+
exports.clamp = clamp;
|
|
1612
1622
|
exports.concat = concat;
|
|
1613
1623
|
exports.conforms = conforms;
|
|
1614
1624
|
exports.conformsTo = conformsTo;
|
package/dist/compat/index.mjs
CHANGED
|
@@ -57,7 +57,6 @@ export { memoize } from '../function/memoize.mjs';
|
|
|
57
57
|
export { unary } from '../function/unary.mjs';
|
|
58
58
|
export { partial } from '../function/partial.mjs';
|
|
59
59
|
export { partialRight } from '../function/partialRight.mjs';
|
|
60
|
-
export { clamp } from '../math/clamp.mjs';
|
|
61
60
|
export { inRange } from '../math/inRange.mjs';
|
|
62
61
|
export { mean } from '../math/mean.mjs';
|
|
63
62
|
export { meanBy } from '../math/meanBy.mjs';
|
|
@@ -171,6 +170,7 @@ export { repeat } from './string/repeat.mjs';
|
|
|
171
170
|
export { trim } from './string/trim.mjs';
|
|
172
171
|
export { trimStart } from './string/trimStart.mjs';
|
|
173
172
|
export { trimEnd } from './string/trimEnd.mjs';
|
|
173
|
+
export { clamp } from './math/clamp.mjs';
|
|
174
174
|
export { max } from './math/max.mjs';
|
|
175
175
|
export { min } from './math/min.mjs';
|
|
176
176
|
export { ceil } from './math/ceil.mjs';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clamps a number within the inclusive upper bound.
|
|
3
|
+
*
|
|
4
|
+
* This function takes a number and a maximum bound, and returns the number clamped within the specified upper bound.
|
|
5
|
+
* If only one bound is provided, it returns the minimum of the value and the bound.
|
|
6
|
+
*
|
|
7
|
+
* @param {number} value - The number to clamp.
|
|
8
|
+
* @param {number} maximum - The maximum bound to clamp the number.
|
|
9
|
+
* @returns {number} The clamped number within the specified upper bound.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const result1 = clamp(10, 5); // result1 will be 5, as 10 is clamped to the bound 5
|
|
13
|
+
*/
|
|
14
|
+
declare function clamp(value: number, maximum: number): number;
|
|
15
|
+
/**
|
|
16
|
+
* Clamps a number within the inclusive lower and upper bounds.
|
|
17
|
+
*
|
|
18
|
+
* This function takes a number and two bounds, and returns the number clamped within the specified bounds.
|
|
19
|
+
*
|
|
20
|
+
* @param {number} value - The number to clamp.
|
|
21
|
+
* @param {number} minimum - The minimum bound to clamp the number.
|
|
22
|
+
* @param {number} maximum - The maximum bound to clamp the number.
|
|
23
|
+
* @returns {number} The clamped number within the specified bounds.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const result2 = clamp(10, 5, 15); // result2 will be 10, as it is within the bounds 5 and 15
|
|
27
|
+
* const result3 = clamp(2, 5, 15); // result3 will be 5, as 2 is clamped to the lower bound 5
|
|
28
|
+
* const result4 = clamp(20, 5, 15); // result4 will be 15, as 20 is clamped to the upper bound 15
|
|
29
|
+
*/
|
|
30
|
+
declare function clamp(value: number, minimum: number, maximum: number): number;
|
|
31
|
+
|
|
32
|
+
export { clamp };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clamps a number within the inclusive upper bound.
|
|
3
|
+
*
|
|
4
|
+
* This function takes a number and a maximum bound, and returns the number clamped within the specified upper bound.
|
|
5
|
+
* If only one bound is provided, it returns the minimum of the value and the bound.
|
|
6
|
+
*
|
|
7
|
+
* @param {number} value - The number to clamp.
|
|
8
|
+
* @param {number} maximum - The maximum bound to clamp the number.
|
|
9
|
+
* @returns {number} The clamped number within the specified upper bound.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const result1 = clamp(10, 5); // result1 will be 5, as 10 is clamped to the bound 5
|
|
13
|
+
*/
|
|
14
|
+
declare function clamp(value: number, maximum: number): number;
|
|
15
|
+
/**
|
|
16
|
+
* Clamps a number within the inclusive lower and upper bounds.
|
|
17
|
+
*
|
|
18
|
+
* This function takes a number and two bounds, and returns the number clamped within the specified bounds.
|
|
19
|
+
*
|
|
20
|
+
* @param {number} value - The number to clamp.
|
|
21
|
+
* @param {number} minimum - The minimum bound to clamp the number.
|
|
22
|
+
* @param {number} maximum - The maximum bound to clamp the number.
|
|
23
|
+
* @returns {number} The clamped number within the specified bounds.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const result2 = clamp(10, 5, 15); // result2 will be 10, as it is within the bounds 5 and 15
|
|
27
|
+
* const result3 = clamp(2, 5, 15); // result3 will be 5, as 2 is clamped to the lower bound 5
|
|
28
|
+
* const result4 = clamp(20, 5, 15); // result4 will be 15, as 20 is clamped to the upper bound 15
|
|
29
|
+
*/
|
|
30
|
+
declare function clamp(value: number, minimum: number, maximum: number): number;
|
|
31
|
+
|
|
32
|
+
export { clamp };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { clamp as clamp$1 } from '../../math/clamp.mjs';
|
|
2
|
+
|
|
3
|
+
function clamp(value, bound1, bound2) {
|
|
4
|
+
if (Number.isNaN(bound1)) {
|
|
5
|
+
bound1 = 0;
|
|
6
|
+
}
|
|
7
|
+
if (Number.isNaN(bound2)) {
|
|
8
|
+
bound2 = 0;
|
|
9
|
+
}
|
|
10
|
+
return clamp$1(value, bound1, bound2);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { clamp };
|
package/dist/math/inRange.d.mts
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the value is less than the maximum.
|
|
3
|
+
*
|
|
4
|
+
* @param {number} value The value to check.
|
|
5
|
+
* @param {number} maximum The upper bound of the range (exclusive).
|
|
6
|
+
* @returns {boolean} `true` if the value is less than the maximum, otherwise `false`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const result = inRange(3, 5); // result will be true.
|
|
10
|
+
* const result2 = inRange(5, 5); // result2 will be false.
|
|
11
|
+
*/
|
|
1
12
|
declare function inRange(value: number, maximum: number): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Checks if the value is within the range defined by minimum (inclusive) and maximum (exclusive).
|
|
15
|
+
*
|
|
16
|
+
* @param {number} value The value to check.
|
|
17
|
+
* @param {number} minimum The lower bound of the range (inclusive).
|
|
18
|
+
* @param {number} maximum The upper bound of the range (exclusive).
|
|
19
|
+
* @returns {boolean} `true` if the value is within the specified range, otherwise `false`.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* const result = inRange(3, 2, 5); // result will be true.
|
|
23
|
+
* const result2 = inRange(1, 2, 5); // result2 will be false.
|
|
24
|
+
*/
|
|
2
25
|
declare function inRange(value: number, minimum: number, maximum: number): boolean;
|
|
3
26
|
|
|
4
27
|
export { inRange };
|
package/dist/math/inRange.d.ts
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the value is less than the maximum.
|
|
3
|
+
*
|
|
4
|
+
* @param {number} value The value to check.
|
|
5
|
+
* @param {number} maximum The upper bound of the range (exclusive).
|
|
6
|
+
* @returns {boolean} `true` if the value is less than the maximum, otherwise `false`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const result = inRange(3, 5); // result will be true.
|
|
10
|
+
* const result2 = inRange(5, 5); // result2 will be false.
|
|
11
|
+
*/
|
|
1
12
|
declare function inRange(value: number, maximum: number): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Checks if the value is within the range defined by minimum (inclusive) and maximum (exclusive).
|
|
15
|
+
*
|
|
16
|
+
* @param {number} value The value to check.
|
|
17
|
+
* @param {number} minimum The lower bound of the range (inclusive).
|
|
18
|
+
* @param {number} maximum The upper bound of the range (exclusive).
|
|
19
|
+
* @returns {boolean} `true` if the value is within the specified range, otherwise `false`.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* const result = inRange(3, 2, 5); // result will be true.
|
|
23
|
+
* const result2 = inRange(1, 2, 5); // result2 will be false.
|
|
24
|
+
*/
|
|
2
25
|
declare function inRange(value: number, minimum: number, maximum: number): boolean;
|
|
3
26
|
|
|
4
27
|
export { inRange };
|
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.19.0-dev.
|
|
4
|
+
"version": "1.19.0-dev.622+192a7d59",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|