@oscarpalmer/atoms 0.205.0 → 0.207.0
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/array/reverse.mjs +2 -1
- package/dist/array/single.d.mts +3 -3
- package/dist/array/sort.mjs +3 -2
- package/dist/color/misc/alpha.mjs +1 -1
- package/dist/color/misc/get.mjs +1 -1
- package/dist/color/space/hsl.mjs +7 -2
- package/dist/color/space/hwb.mjs +2 -1
- package/dist/color/space/rgb.mjs +22 -13
- package/dist/function/retry.mjs +12 -14
- package/dist/index.d.mts +105 -55
- package/dist/index.mjs +323 -262
- package/dist/internal/array/insert.mjs +2 -1
- package/dist/internal/function/limit.mjs +9 -9
- package/dist/internal/function/work.d.mts +1 -1
- package/dist/internal/math/aggregate.d.mts +41 -0
- package/dist/internal/math/aggregate.mjs +4 -1
- package/dist/internal/math/misc.d.mts +8 -0
- package/dist/internal/math/misc.mjs +11 -1
- package/dist/internal/models/plan.model.d.mts +23 -0
- package/dist/internal/models/plan.model.mjs +7 -0
- package/dist/internal/{result/models.d.mts → models/result.model.d.mts} +1 -1
- package/dist/internal/random.mjs +2 -1
- package/dist/internal/result/attempt.d.mts +59 -0
- package/dist/internal/result/attempt.mjs +24 -0
- package/dist/internal/result/misc.d.mts +1 -1
- package/dist/internal/string/misc.mjs +4 -5
- package/dist/internal/value/equal.mjs +2 -1
- package/dist/internal/value/has.d.mts +1 -1
- package/dist/internal/value/misc.d.mts +1 -1
- package/dist/internal/value/misc.mjs +1 -1
- package/dist/math.d.mts +3 -52
- package/dist/math.mjs +3 -16
- package/dist/plan/index.d.mts +38 -0
- package/dist/plan/index.mjs +61 -0
- package/dist/plan/models.d.mts +2 -0
- package/dist/plan/models.mjs +1 -0
- package/dist/promise/constants.d.mts +0 -1
- package/dist/promise/constants.mjs +1 -2
- package/dist/promise/helpers.mjs +1 -1
- package/dist/promise/index.mjs +9 -9
- package/dist/promise/misc.d.mts +1 -1
- package/dist/promise/misc.mjs +1 -1
- package/dist/promise/models.d.mts +1 -1
- package/dist/queue.mjs +11 -6
- package/dist/result/index.d.mts +2 -59
- package/dist/result/index.mjs +1 -23
- package/dist/result/match.d.mts +1 -1
- package/dist/result/misc.d.mts +1 -1
- package/dist/result/work/flow.d.mts +1 -1
- package/dist/result/work/flow.mjs +2 -1
- package/dist/result/work/pipe.d.mts +1 -1
- package/dist/result/work/pipe.mjs +2 -1
- package/dist/string/fuzzy.mjs +7 -5
- package/dist/string/index.mjs +2 -1
- package/dist/value/clone.mjs +5 -8
- package/dist/value/diff.mjs +3 -2
- package/package.json +9 -4
- /package/dist/internal/{result/models.mjs → models/result.model.mjs} +0 -0
package/dist/array/reverse.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { floor } from "../internal/math/misc.mjs";
|
|
1
2
|
//#region src/array/reverse.ts
|
|
2
3
|
/**
|
|
3
4
|
* Reverse the order of items in an array
|
|
@@ -9,7 +10,7 @@ function reverse(array) {
|
|
|
9
10
|
if (!Array.isArray(array)) return [];
|
|
10
11
|
const { length } = array;
|
|
11
12
|
if (length < 2) return array;
|
|
12
|
-
const half =
|
|
13
|
+
const half = floor(length / 2);
|
|
13
14
|
for (let firstIndex = 0; firstIndex < half; firstIndex += 1) {
|
|
14
15
|
const temporaryItem = array[firstIndex];
|
|
15
16
|
const secondIndex = length - 1 - firstIndex;
|
package/dist/array/single.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import { PlainObject } from "../models.mjs";
|
|
|
3
3
|
/**
|
|
4
4
|
* Get the _only_ item matching the given value
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* _Throws an error if multiple items match the value_
|
|
7
7
|
*
|
|
8
8
|
* @param array Array to search in
|
|
9
9
|
* @param callback Callback to get an item's value for matching
|
|
@@ -23,7 +23,7 @@ export declare function single<Item, Callback extends (item: Item, index: number
|
|
|
23
23
|
/**
|
|
24
24
|
* Get the _only_ item matching the given value by key
|
|
25
25
|
*
|
|
26
|
-
*
|
|
26
|
+
* _Throws an error if multiple items match the value_
|
|
27
27
|
*
|
|
28
28
|
* @param array Array to search in
|
|
29
29
|
* @param key Key to get an item's value for matching
|
|
@@ -43,7 +43,7 @@ export declare function single<Item extends PlainObject, ItemKey extends keyof I
|
|
|
43
43
|
/**
|
|
44
44
|
* Get the _only_ item matching the filter
|
|
45
45
|
*
|
|
46
|
-
*
|
|
46
|
+
* _Throws an error if multiple items match the filter_
|
|
47
47
|
*
|
|
48
48
|
* @param array Array to search in
|
|
49
49
|
* @param filter Filter callback to match items
|
package/dist/array/sort.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isPlainObject } from "../internal/is.mjs";
|
|
2
|
+
import { floor, round } from "../internal/math/misc.mjs";
|
|
2
3
|
import { compare } from "../internal/value/compare.mjs";
|
|
3
4
|
//#region src/array/sort.ts
|
|
4
5
|
function Sorter(sorters) {
|
|
@@ -48,7 +49,7 @@ function getSortedArrayIndex(array, item) {
|
|
|
48
49
|
let low = 0;
|
|
49
50
|
let high = length - 1;
|
|
50
51
|
while (low <= high) {
|
|
51
|
-
const mid =
|
|
52
|
+
const mid = floor((low + high) / 2);
|
|
52
53
|
if (getComparisonValue(item, array[mid], sorters, sortersLength) < 0) high = mid - 1;
|
|
53
54
|
else low = mid + 1;
|
|
54
55
|
}
|
|
@@ -103,7 +104,7 @@ function isSortedArray(array) {
|
|
|
103
104
|
const sortersLength = sorters.length;
|
|
104
105
|
let offset = 0;
|
|
105
106
|
if (length >= SORT_THRESHOLD) {
|
|
106
|
-
offset =
|
|
107
|
+
offset = round(length / SORT_PEEK_PERCENTAGE);
|
|
107
108
|
offset = offset > SORT_THRESHOLD ? SORT_THRESHOLD : offset;
|
|
108
109
|
for (let index = 0; index < offset; index += 1) {
|
|
109
110
|
const [firstItem, firstOffset] = [array[index], array[index + 1]];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { round } from "../../internal/math/misc.mjs";
|
|
1
2
|
import { clamp } from "../../internal/number.mjs";
|
|
2
3
|
import { COLOR_ALPHA, COLOR_DEFAULTS, COLOR_EXPRESSION, COLOR_MAX, COLOR_SYMBOL } from "../constants.mjs";
|
|
3
|
-
import { round } from "../../internal/math/misc.mjs";
|
|
4
4
|
//#region src/color/misc/alpha.ts
|
|
5
5
|
function getAlpha(value, hex) {
|
|
6
6
|
if (typeof value === "number") return getAlphaFromValue(value);
|
package/dist/color/misc/get.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { round } from "../../internal/math/misc.mjs";
|
|
1
2
|
import { clamp } from "../../internal/number.mjs";
|
|
2
3
|
import { COLOR_DEFAULTS, COLOR_MAX, COLOR_SRGB, COLOR_TYPE } from "../constants.mjs";
|
|
3
|
-
import { round } from "../../internal/math/misc.mjs";
|
|
4
4
|
import { getColorFromState, getColorState } from "./state.mjs";
|
|
5
5
|
import { color } from "../instance.mjs";
|
|
6
6
|
//#region src/color/misc/get.ts
|
package/dist/color/space/hsl.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { max, min } from "../../internal/math/aggregate.mjs";
|
|
1
2
|
import { COLOR_DEFAULTS, COLOR_MAX, COLOR_TYPE } from "../constants.mjs";
|
|
2
3
|
import { getAlphaValue } from "../misc/alpha.mjs";
|
|
3
4
|
import { getDegrees, getHexValue, getPercentage } from "../misc/get.mjs";
|
|
@@ -9,7 +10,7 @@ function convertHslToHwba(input) {
|
|
|
9
10
|
let { hue, lightness, saturation } = isHslLike(input) ? getHslValues(input) : { ...COLOR_DEFAULTS.hsl };
|
|
10
11
|
lightness /= COLOR_MAX.percent;
|
|
11
12
|
saturation /= COLOR_MAX.percent;
|
|
12
|
-
const value = lightness + saturation *
|
|
13
|
+
const value = lightness + saturation * min([lightness, 1 - lightness]);
|
|
13
14
|
if (value === 0) saturation = 0;
|
|
14
15
|
else saturation = 2 * (1 - lightness / value);
|
|
15
16
|
const blackness = 1 - value;
|
|
@@ -46,7 +47,11 @@ function getColorFromHsl(state, type) {
|
|
|
46
47
|
}
|
|
47
48
|
function getHexyValue(hue, lightness, saturation, value) {
|
|
48
49
|
const part = (value + hue / 30) % 12;
|
|
49
|
-
return (lightness - saturation *
|
|
50
|
+
return (lightness - saturation * min([lightness, 1 - lightness]) * max([-1, min([
|
|
51
|
+
part - 3,
|
|
52
|
+
9 - part,
|
|
53
|
+
1
|
|
54
|
+
])])) * COLOR_MAX.hex;
|
|
50
55
|
}
|
|
51
56
|
function getHslValue() {
|
|
52
57
|
return getStateValue(this, COLOR_TYPE.hsl, false);
|
package/dist/color/space/hwb.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { min } from "../../internal/math/aggregate.mjs";
|
|
1
2
|
import { COLOR_DEFAULTS, COLOR_MAX, COLOR_TYPE } from "../constants.mjs";
|
|
2
3
|
import { getAlphaValue } from "../misc/alpha.mjs";
|
|
3
4
|
import { getDegrees, getPercentage } from "../misc/get.mjs";
|
|
@@ -38,7 +39,7 @@ function getColorFromHwb(state, type) {
|
|
|
38
39
|
function getHwbSaturation(blackness, whiteness, lightness) {
|
|
39
40
|
const hue = 1 - blackness - whiteness;
|
|
40
41
|
if (hue <= 0) return 0;
|
|
41
|
-
return hue /
|
|
42
|
+
return hue / min([2 * lightness, 2 - 2 * lightness]);
|
|
42
43
|
}
|
|
43
44
|
function getHwbValue() {
|
|
44
45
|
return getStateValue(this, COLOR_TYPE.hwb, false);
|
package/dist/color/space/rgb.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { max, min } from "../../internal/math/aggregate.mjs";
|
|
1
2
|
import { join } from "../../internal/string/misc.mjs";
|
|
2
3
|
import { COLOR_DEFAULTS, COLOR_MAX, COLOR_TYPE } from "../constants.mjs";
|
|
3
4
|
import { getAlpha, getAlphaValue } from "../misc/alpha.mjs";
|
|
@@ -20,12 +21,12 @@ function convertRgbToHex(rgb, alpha) {
|
|
|
20
21
|
}
|
|
21
22
|
function convertRgbToHsla(value) {
|
|
22
23
|
const values = getRgbCalculationValues(isRgbLike(value) ? getRgbValues(value) : { ...COLOR_DEFAULTS.rgb });
|
|
23
|
-
const { delta,
|
|
24
|
-
const lightness = (
|
|
24
|
+
const { delta, maximum, minimum } = values;
|
|
25
|
+
const lightness = (minimum + maximum) / 2;
|
|
25
26
|
let hue = 0;
|
|
26
27
|
let saturation = 0;
|
|
27
28
|
if (delta !== 0) {
|
|
28
|
-
saturation = (
|
|
29
|
+
saturation = (maximum - lightness) / min([lightness, 1 - lightness]);
|
|
29
30
|
hue = getRgbHue(values);
|
|
30
31
|
hue *= 60;
|
|
31
32
|
}
|
|
@@ -38,7 +39,7 @@ function convertRgbToHsla(value) {
|
|
|
38
39
|
}
|
|
39
40
|
function convertRgbToHwba(value) {
|
|
40
41
|
const values = getRgbCalculationValues(isRgbLike(value) ? getRgbValues(value) : { ...COLOR_DEFAULTS.rgb });
|
|
41
|
-
const { delta,
|
|
42
|
+
const { delta, maximum, minimum } = values;
|
|
42
43
|
let hue = 0;
|
|
43
44
|
if (delta !== 0) {
|
|
44
45
|
hue = getRgbHue(values);
|
|
@@ -46,8 +47,8 @@ function convertRgbToHwba(value) {
|
|
|
46
47
|
}
|
|
47
48
|
return {
|
|
48
49
|
hue,
|
|
49
|
-
whiteness:
|
|
50
|
-
blackness: (1 -
|
|
50
|
+
whiteness: minimum * COLOR_MAX.percent,
|
|
51
|
+
blackness: (1 - maximum) * COLOR_MAX.percent,
|
|
51
52
|
alpha: getAlphaValue(value?.alpha ?? COLOR_MAX.percent)
|
|
52
53
|
};
|
|
53
54
|
}
|
|
@@ -67,14 +68,22 @@ function getRgbCalculationValues(rgb) {
|
|
|
67
68
|
const blue = rgb.blue / COLOR_MAX.hex;
|
|
68
69
|
const green = rgb.green / COLOR_MAX.hex;
|
|
69
70
|
const red = rgb.red / COLOR_MAX.hex;
|
|
70
|
-
const
|
|
71
|
-
|
|
71
|
+
const maximum = max([
|
|
72
|
+
blue,
|
|
73
|
+
green,
|
|
74
|
+
red
|
|
75
|
+
]);
|
|
76
|
+
const minimum = min([
|
|
77
|
+
blue,
|
|
78
|
+
green,
|
|
79
|
+
red
|
|
80
|
+
]);
|
|
72
81
|
return {
|
|
73
82
|
blue,
|
|
74
|
-
delta:
|
|
83
|
+
delta: maximum - minimum,
|
|
75
84
|
green,
|
|
76
|
-
|
|
77
|
-
|
|
85
|
+
maximum,
|
|
86
|
+
minimum,
|
|
78
87
|
red
|
|
79
88
|
};
|
|
80
89
|
}
|
|
@@ -85,8 +94,8 @@ function getRgbaColor() {
|
|
|
85
94
|
return getStateValue(this, COLOR_TYPE.rgb, true);
|
|
86
95
|
}
|
|
87
96
|
function getRgbHue(values) {
|
|
88
|
-
const { blue, delta, green,
|
|
89
|
-
switch (
|
|
97
|
+
const { blue, delta, green, maximum, red } = values;
|
|
98
|
+
switch (maximum) {
|
|
90
99
|
case blue: return (red - green) / delta + 4;
|
|
91
100
|
case green: return (blue - red) / delta + 2;
|
|
92
101
|
default: return (green - blue) / delta + (green < blue ? 6 : 0);
|
package/dist/function/retry.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isPlainObject } from "../internal/is.mjs";
|
|
2
|
+
import { asyncAttempt, attempt } from "../internal/result/attempt.mjs";
|
|
2
3
|
import { getNumberOrDefault } from "../internal/defaults.mjs";
|
|
3
4
|
import { LIMITER_WAIT, getLimiter } from "../internal/function/limit.mjs";
|
|
4
5
|
//#region src/function/retry.ts
|
|
@@ -25,15 +26,12 @@ var RetryError = class extends Error {
|
|
|
25
26
|
async function asyncRetry(callback, options) {
|
|
26
27
|
if (typeof callback !== "function") throw new TypeError(RETRY_MESSAGE_EXPECTATION);
|
|
27
28
|
async function handle() {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
attempts += 1;
|
|
35
|
-
limiter.run();
|
|
36
|
-
}
|
|
29
|
+
const result = await asyncAttempt(async () => callback());
|
|
30
|
+
if (result.ok) resolver(result.value);
|
|
31
|
+
else if (attempts >= times || !when(result.error)) rejector(new RetryError(RETRY_MESSAGE_FAILED, result.error));
|
|
32
|
+
else {
|
|
33
|
+
attempts += 1;
|
|
34
|
+
limiter.run();
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
37
|
const { delay, times, when } = createRetryOptions(options);
|
|
@@ -66,11 +64,11 @@ function retry(callback, options) {
|
|
|
66
64
|
if (typeof callback !== "function") throw new TypeError(RETRY_MESSAGE_EXPECTATION);
|
|
67
65
|
const { times, when } = createRetryOptions(options);
|
|
68
66
|
let last;
|
|
69
|
-
for (let index = 0; index <= times; index += 1)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (index >= times || !when(error)) {
|
|
73
|
-
last = error;
|
|
67
|
+
for (let index = 0; index <= times; index += 1) {
|
|
68
|
+
const result = attempt(callback);
|
|
69
|
+
if (result.ok) return result.value;
|
|
70
|
+
if (index >= times || !when(result.error)) {
|
|
71
|
+
last = result.error;
|
|
74
72
|
break;
|
|
75
73
|
}
|
|
76
74
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -1482,7 +1482,7 @@ export declare function reverse<Item>(array: Item[]): Item[];
|
|
|
1482
1482
|
/**
|
|
1483
1483
|
* Get the _only_ item matching the given value
|
|
1484
1484
|
*
|
|
1485
|
-
*
|
|
1485
|
+
* _Throws an error if multiple items match the value_
|
|
1486
1486
|
*
|
|
1487
1487
|
* @param array Array to search in
|
|
1488
1488
|
* @param callback Callback to get an item's value for matching
|
|
@@ -1502,7 +1502,7 @@ export declare function single<Item, Callback extends (item: Item, index: number
|
|
|
1502
1502
|
/**
|
|
1503
1503
|
* Get the _only_ item matching the given value by key
|
|
1504
1504
|
*
|
|
1505
|
-
*
|
|
1505
|
+
* _Throws an error if multiple items match the value_
|
|
1506
1506
|
*
|
|
1507
1507
|
* @param array Array to search in
|
|
1508
1508
|
* @param key Key to get an item's value for matching
|
|
@@ -1522,7 +1522,7 @@ export declare function single<Item extends PlainObject, ItemKey extends keyof I
|
|
|
1522
1522
|
/**
|
|
1523
1523
|
* Get the _only_ item matching the filter
|
|
1524
1524
|
*
|
|
1525
|
-
*
|
|
1525
|
+
* _Throws an error if multiple items match the filter_
|
|
1526
1526
|
*
|
|
1527
1527
|
* @param array Array to search in
|
|
1528
1528
|
* @param filter Filter callback to match items
|
|
@@ -3667,7 +3667,7 @@ export type MemoizedOptions<Callback extends GenericCallback> = {
|
|
|
3667
3667
|
*/
|
|
3668
3668
|
export declare function memoize<Callback extends GenericCallback>(callback: Callback, options?: MemoizedOptions<Callback>): Memoized<Callback>;
|
|
3669
3669
|
//#endregion
|
|
3670
|
-
//#region src/internal/result
|
|
3670
|
+
//#region src/internal/models/result.model.d.ts
|
|
3671
3671
|
/**
|
|
3672
3672
|
* An unknown result
|
|
3673
3673
|
*/
|
|
@@ -4587,6 +4587,56 @@ export declare function setValue<Data extends PlainObject, Path extends NestedKe
|
|
|
4587
4587
|
*/
|
|
4588
4588
|
export declare function setValue<Data extends PlainObject>(data: Data, path: string, value: unknown, ignoreCase?: boolean): Data;
|
|
4589
4589
|
//#endregion
|
|
4590
|
+
//#region src/internal/models/plan.model.d.ts
|
|
4591
|
+
/**
|
|
4592
|
+
* A plan of execution that can yield intermediate results and eventually return a value or an error.
|
|
4593
|
+
*/
|
|
4594
|
+
type Plan<out Value, out Error = unknown> = {
|
|
4595
|
+
/**
|
|
4596
|
+
* Run the plan to completion
|
|
4597
|
+
*
|
|
4598
|
+
* @returns Final result, or an error
|
|
4599
|
+
*/
|
|
4600
|
+
run: () => Error | Value;
|
|
4601
|
+
};
|
|
4602
|
+
//#endregion
|
|
4603
|
+
//#region src/plan/index.d.ts
|
|
4604
|
+
/**
|
|
4605
|
+
* Is the value a generator function?
|
|
4606
|
+
*
|
|
4607
|
+
* @param value Value to check
|
|
4608
|
+
* @returns `true` if the value is a generator function, otherwise `false`
|
|
4609
|
+
*/
|
|
4610
|
+
export declare function isGenerator(value: unknown): value is () => Generator;
|
|
4611
|
+
/**
|
|
4612
|
+
* Is the value a plan?
|
|
4613
|
+
*
|
|
4614
|
+
* @param value Value to check
|
|
4615
|
+
* @returns `true` if the value is a plan, otherwise `false`
|
|
4616
|
+
*/
|
|
4617
|
+
export declare function isPlan<Value = unknown, Error = unknown>(value: unknown): value is Plan<Value, Error>;
|
|
4618
|
+
/**
|
|
4619
|
+
* Create a plan for a generator function
|
|
4620
|
+
*
|
|
4621
|
+
* @param generator Generator to plan for
|
|
4622
|
+
* @returns Generator plan
|
|
4623
|
+
*/
|
|
4624
|
+
export declare function plan<Value = unknown, Error = unknown>(generator: () => Generator<unknown, Value, Error>): Plan<Value, Error>;
|
|
4625
|
+
/**
|
|
4626
|
+
* Run a generator to completion
|
|
4627
|
+
*
|
|
4628
|
+
* @param generator Generator to run
|
|
4629
|
+
* @returns Final result, or an error
|
|
4630
|
+
*/
|
|
4631
|
+
export declare function run<Value = unknown, Error = unknown>(generator: () => Generator<unknown, Value, unknown>): Error | Value;
|
|
4632
|
+
/**
|
|
4633
|
+
* Run a plan to completion
|
|
4634
|
+
*
|
|
4635
|
+
* @param plan Plan to run
|
|
4636
|
+
* @returns Final result, or an error
|
|
4637
|
+
*/
|
|
4638
|
+
export declare function run<Value = unknown, Error = unknown>(plan: Plan<Value, Error>): Error | Value;
|
|
4639
|
+
//#endregion
|
|
4590
4640
|
//#region src/internal/aborter.d.ts
|
|
4591
4641
|
type Aborter = {
|
|
4592
4642
|
callback: GenericCallback;
|
|
@@ -5001,7 +5051,7 @@ export declare function timed<Value>(promise: Promise<Value>, options: RequiredK
|
|
|
5001
5051
|
*/
|
|
5002
5052
|
export declare function timed<Value>(promise: Promise<Value>, time: number): Promise<Value>;
|
|
5003
5053
|
//#endregion
|
|
5004
|
-
//#region src/result/
|
|
5054
|
+
//#region src/internal/result/attempt.d.ts
|
|
5005
5055
|
/**
|
|
5006
5056
|
* Executes a _Promise_, catching any errors, and returns a result
|
|
5007
5057
|
*
|
|
@@ -7731,8 +7781,57 @@ export declare function max<Item extends PlainObject>(items: Item[], key: keyof
|
|
|
7731
7781
|
* @returns Maximum value, or `Number.NaN` if no maximum can be found
|
|
7732
7782
|
*/
|
|
7733
7783
|
export declare function max(values: number[]): number;
|
|
7784
|
+
/**
|
|
7785
|
+
* Get the minimum value from a list of items
|
|
7786
|
+
*
|
|
7787
|
+
* @param items List of items
|
|
7788
|
+
* @param callback Callback to get an item's value
|
|
7789
|
+
* @param first Return only the first item with the minimum value
|
|
7790
|
+
* @returns First item with the minimum value, or `undefined` if no minimum can be found
|
|
7791
|
+
*/
|
|
7792
|
+
export declare function min<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number, first: true): Item | undefined;
|
|
7793
|
+
/**
|
|
7794
|
+
* Get the minimum value from a list of items
|
|
7795
|
+
*
|
|
7796
|
+
* @param items List of items
|
|
7797
|
+
* @param key Key to use for value
|
|
7798
|
+
* @param first Return only the first item with the minimum value
|
|
7799
|
+
* @returns First item with the minimum value, or `undefined` if no minimum can be found
|
|
7800
|
+
*/
|
|
7801
|
+
export declare function min<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>, first: true): Item | undefined;
|
|
7802
|
+
/**
|
|
7803
|
+
* Get the minimum value from a list of items
|
|
7804
|
+
*
|
|
7805
|
+
* @param items List of items
|
|
7806
|
+
* @param callback Callback to get an item's value
|
|
7807
|
+
* @returns Items with the minimum value
|
|
7808
|
+
*/
|
|
7809
|
+
export declare function min<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number): Item[];
|
|
7810
|
+
/**
|
|
7811
|
+
* Get the minimum value from a list of items
|
|
7812
|
+
*
|
|
7813
|
+
* @param items List of items
|
|
7814
|
+
* @param key Key to use for value
|
|
7815
|
+
* @returns Items with the minimum value
|
|
7816
|
+
*/
|
|
7817
|
+
export declare function min<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>): Item[];
|
|
7818
|
+
/**
|
|
7819
|
+
* Get the minimum value from a list of numbers
|
|
7820
|
+
*
|
|
7821
|
+
* @param values List of numbers
|
|
7822
|
+
* @returns Minimum value, or `Number.NaN` if no minimum can be found
|
|
7823
|
+
*/
|
|
7824
|
+
export declare function min(values: number[]): number;
|
|
7734
7825
|
//#endregion
|
|
7735
7826
|
//#region src/internal/math/misc.d.ts
|
|
7827
|
+
/**
|
|
7828
|
+
* Round a number down
|
|
7829
|
+
*
|
|
7830
|
+
* @param value Number to round down
|
|
7831
|
+
* @param decimals Number of decimal places to round to _(defaults to `0`)_
|
|
7832
|
+
* @returns Rounded number, or `Number.NaN` if the value if unable to be rounded
|
|
7833
|
+
*/
|
|
7834
|
+
export declare function floor(value: number, decimals?: number): number;
|
|
7736
7835
|
/**
|
|
7737
7836
|
* Round a number
|
|
7738
7837
|
*
|
|
@@ -7799,14 +7898,6 @@ export declare function count<Item extends PlainObject, ItemKey extends keyof It
|
|
|
7799
7898
|
* @returns Number of items, or `Number.NaN` if no count can be calculated
|
|
7800
7899
|
*/
|
|
7801
7900
|
export declare function count(values: unknown[]): number;
|
|
7802
|
-
/**
|
|
7803
|
-
* Round a number down
|
|
7804
|
-
*
|
|
7805
|
-
* @param value Number to round down
|
|
7806
|
-
* @param decimals Number of decimal places to round to _(defaults to `0`)_
|
|
7807
|
-
* @returns Rounded number, or `Number.NaN` if the value if unable to be rounded
|
|
7808
|
-
*/
|
|
7809
|
-
export declare function floor(value: number, decimals?: number): number;
|
|
7810
7901
|
/**
|
|
7811
7902
|
* Get the median value from a list of items
|
|
7812
7903
|
*
|
|
@@ -7830,47 +7921,6 @@ export declare function median<Item extends PlainObject>(array: Item[], key: key
|
|
|
7830
7921
|
* @returns Median value, or `Number.NaN` if no median can be calculated
|
|
7831
7922
|
*/
|
|
7832
7923
|
export declare function median(array: number[]): number;
|
|
7833
|
-
/**
|
|
7834
|
-
* Get the minimum value from a list of items
|
|
7835
|
-
*
|
|
7836
|
-
* @param items List of items
|
|
7837
|
-
* @param callback Callback to get an item's value
|
|
7838
|
-
* @param first Return only the first item with the minimum value
|
|
7839
|
-
* @returns First item with the minimum value, or `undefined` if no minimum can be found
|
|
7840
|
-
*/
|
|
7841
|
-
export declare function min<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number, first: true): Item | undefined;
|
|
7842
|
-
/**
|
|
7843
|
-
* Get the minimum value from a list of items
|
|
7844
|
-
*
|
|
7845
|
-
* @param items List of items
|
|
7846
|
-
* @param key Key to use for value
|
|
7847
|
-
* @param first Return only the first item with the minimum value
|
|
7848
|
-
* @returns First item with the minimum value, or `undefined` if no minimum can be found
|
|
7849
|
-
*/
|
|
7850
|
-
export declare function min<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>, first: true): Item | undefined;
|
|
7851
|
-
/**
|
|
7852
|
-
* Get the minimum value from a list of items
|
|
7853
|
-
*
|
|
7854
|
-
* @param items List of items
|
|
7855
|
-
* @param callback Callback to get an item's value
|
|
7856
|
-
* @returns Items with the minimum value
|
|
7857
|
-
*/
|
|
7858
|
-
export declare function min<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number): Item[];
|
|
7859
|
-
/**
|
|
7860
|
-
* Get the minimum value from a list of items
|
|
7861
|
-
*
|
|
7862
|
-
* @param items List of items
|
|
7863
|
-
* @param key Key to use for value
|
|
7864
|
-
* @returns Items with the minimum value
|
|
7865
|
-
*/
|
|
7866
|
-
export declare function min<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>): Item[];
|
|
7867
|
-
/**
|
|
7868
|
-
* Get the minimum value from a list of numbers
|
|
7869
|
-
*
|
|
7870
|
-
* @param values List of numbers
|
|
7871
|
-
* @returns Minimum value, or `Number.NaN` if no minimum can be found
|
|
7872
|
-
*/
|
|
7873
|
-
export declare function min(values: number[]): number;
|
|
7874
7924
|
/**
|
|
7875
7925
|
* Get the sum of a list of items
|
|
7876
7926
|
*
|
|
@@ -8317,4 +8367,4 @@ export declare class SizedSet<Value = unknown> extends Set<Value> {
|
|
|
8317
8367
|
get(value: Value, update?: boolean): Value | undefined;
|
|
8318
8368
|
}
|
|
8319
8369
|
//#endregion
|
|
8320
|
-
export { type AsyncLimiter, type Color, type ColorType, type ColorTypeExtended, type ColorValue, type ColorValueExtended, type HSLAColor, type HSLColor, type HWBAColor, type HWBColor, Key$1 as Key, type Limiter, Logger, type RGBAColor, type RGBColor, type Shaken, type Smushed, type Subscription, type SubscriptionParameters, type SubscriptionProperty, type Subscriptions, type SubscriptionsParameters, type TimeLogger, type Unsmushed, push as append, filterAndMap as select, toPromise as fromResult, getRandomFloatingNumber as getRandomFloat, isLogger, isTimeLogger, mapAndFilter as reverseSelect };
|
|
8370
|
+
export { type AsyncLimiter, type Color, type ColorType, type ColorTypeExtended, type ColorValue, type ColorValueExtended, type HSLAColor, type HSLColor, type HWBAColor, type HWBColor, Key$1 as Key, type Limiter, Logger, type Plan, type RGBAColor, type RGBColor, type Shaken, type Smushed, type Subscription, type SubscriptionParameters, type SubscriptionProperty, type Subscriptions, type SubscriptionsParameters, type TimeLogger, type Unsmushed, push as append, filterAndMap as select, toPromise as fromResult, getRandomFloatingNumber as getRandomFloat, isLogger, isTimeLogger, mapAndFilter as reverseSelect };
|