@oscarpalmer/atoms 0.216.0 → 0.218.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.
Files changed (77) hide show
  1. package/dist/array/insert.mjs +1 -1
  2. package/dist/array/slice.mjs +27 -14
  3. package/dist/array/sort.mjs +2 -1
  4. package/dist/array/swap.d.mts +2 -1
  5. package/dist/color/constants.d.mts +2 -1
  6. package/dist/color/misc/get.mjs +3 -1
  7. package/dist/color/space/hex.mjs +1 -1
  8. package/dist/color/space/rgb.d.mts +1 -0
  9. package/dist/function/index.mjs +1 -2
  10. package/dist/function/retry.d.mts +1 -1
  11. package/dist/function/retry.mjs +5 -2
  12. package/dist/herald.mjs +1 -2
  13. package/dist/index.d.mts +335 -113
  14. package/dist/index.mjs +483 -241
  15. package/dist/internal/array/find.mjs +57 -34
  16. package/dist/internal/array/insert.mjs +1 -1
  17. package/dist/internal/array/match.mjs +21 -17
  18. package/dist/internal/array/sets.mjs +7 -1
  19. package/dist/internal/math/aggregate.mjs +4 -1
  20. package/dist/internal/number.d.mts +1 -1
  21. package/dist/internal/number.mjs +4 -2
  22. package/dist/internal/plan/index.d.mts +7 -0
  23. package/dist/internal/plan/index.mjs +18 -0
  24. package/dist/{plan/generate.d.mts → internal/plan/plan.generate.d.mts} +2 -2
  25. package/dist/{plan/generate.mjs → internal/plan/plan.generate.mjs} +7 -7
  26. package/dist/internal/random.d.mts +6 -0
  27. package/dist/internal/random.mjs +13 -2
  28. package/dist/internal/result/attempt.mjs +4 -4
  29. package/dist/internal/string/misc.mjs +2 -1
  30. package/dist/internal/subscription.mjs +1 -1
  31. package/dist/internal/value/equal.mjs +2 -1
  32. package/dist/internal/value/partial.mjs +3 -1
  33. package/dist/models/color.model.d.mts +2 -1
  34. package/dist/models/function/once.model.d.mts +2 -1
  35. package/dist/models/index.d.mts +2 -1
  36. package/dist/models/plan.model.d.mts +160 -29
  37. package/dist/models/plan.model.mjs +15 -5
  38. package/dist/models/queue.model.d.mts +2 -1
  39. package/dist/models/result.model.d.mts +2 -1
  40. package/dist/models/string/string.fuzzy.model.d.mts +1 -1
  41. package/dist/models/string/string.misc.model.mjs +1 -1
  42. package/dist/models/value/value.equal.model.d.mts +2 -1
  43. package/dist/models/value/value.merge.model.d.mts +3 -2
  44. package/dist/models/value/value.misc.model.d.mts +2 -1
  45. package/dist/number.mjs +1 -2
  46. package/dist/plan/index.d.mts +1 -4
  47. package/dist/plan/index.mjs +14 -15
  48. package/dist/plan/is.d.mts +59 -3
  49. package/dist/plan/is.mjs +82 -10
  50. package/dist/plan/misc.d.mts +51 -3
  51. package/dist/plan/misc.mjs +47 -30
  52. package/dist/plan/models.d.mts +2 -2
  53. package/dist/plan/result.d.mts +15 -3
  54. package/dist/plan/result.mjs +5 -11
  55. package/dist/plan/run.d.mts +1 -3
  56. package/dist/plan/run.mjs +5 -11
  57. package/dist/plan/use.d.mts +36 -0
  58. package/dist/plan/use.mjs +69 -0
  59. package/dist/promise/index.d.mts +6 -4
  60. package/dist/promise/index.mjs +4 -4
  61. package/dist/promise/misc.mjs +5 -2
  62. package/dist/promise/models.mjs +1 -2
  63. package/dist/promise/timed.mjs +2 -2
  64. package/dist/queue.mjs +4 -5
  65. package/dist/random.d.mts +2 -2
  66. package/dist/random.mjs +3 -3
  67. package/dist/result/index.mjs +1 -2
  68. package/dist/result/match.mjs +2 -2
  69. package/dist/result/misc.mjs +3 -10
  70. package/dist/result/work/pipe.d.mts +26 -23
  71. package/dist/result/work/pipe.mjs +7 -3
  72. package/dist/string/fuzzy.mjs +1 -1
  73. package/dist/string/index.mjs +1 -1
  74. package/dist/subscription.mjs +1 -2
  75. package/dist/value/clone.mjs +1 -1
  76. package/dist/value/merge.mjs +17 -4
  77. package/package.json +8 -10
@@ -9,15 +9,47 @@ function createFindParameters(original) {
9
9
  value: length === 1 && typeof original[0] !== "function" ? original[0] : original[1]
10
10
  };
11
11
  }
12
+ function findComplexValues(parameters) {
13
+ const { array, keyCallback, length, mapAfter, mapBefore, result, type, value } = parameters;
14
+ const keys = /* @__PURE__ */ new Set();
15
+ for (let index = 0; index < length; index += 1) {
16
+ const item = array[index];
17
+ let keyed;
18
+ let transformed;
19
+ if (mapBefore == null) {
20
+ keyed = keyCallback?.(item, index, array) ?? item;
21
+ transformed = item;
22
+ } else {
23
+ transformed = mapBefore(item, index, array);
24
+ keyed = keyCallback?.(transformed, index, array) ?? transformed;
25
+ }
26
+ if (type === "all" && Object.is(keyed, value) || type === "unique" && !keys.has(keyed)) {
27
+ keys.add(keyed);
28
+ result.matched.push(mapAfter?.(item, index, array) ?? transformed);
29
+ } else result.notMatched.push(item);
30
+ }
31
+ return result;
32
+ }
33
+ function findSimpleValue(array, value, findIndex, reversed) {
34
+ if (findIndex) return reversed ? array.lastIndexOf(value) : array.indexOf(value);
35
+ return reversed ? array.findLast((item) => Object.is(item, value)) : array.find((item) => Object.is(item, value));
36
+ }
37
+ function findSimpleValues(array, length, value, boolCallback, mapBefore, mapAfter, result) {
38
+ const callback = boolCallback ?? ((item) => Object.is(item, value));
39
+ for (let index = 0; index < length; index += 1) {
40
+ const item = array[index];
41
+ const transformed = mapBefore?.(item, index, array) ?? item;
42
+ if (callback(transformed, index, array)) result.matched.push(mapAfter?.(item, index, array) ?? transformed);
43
+ else result.notMatched.push(item);
44
+ }
45
+ return result;
46
+ }
12
47
  function findValue(type, array, parameters, reversed) {
13
48
  const findIndex = type === ARRAY_FIND_VALUE_INDEX;
14
49
  if (!Array.isArray(array) || array.length === 0) return findIndex ? -1 : void 0;
15
50
  const { bool, key, value } = createFindParameters(parameters);
16
51
  const callbacks = getArrayCallbacks(bool, key);
17
- if (callbacks?.bool == null && callbacks?.keyed == null) {
18
- if (findIndex) return reversed ? array.lastIndexOf(value) : array.indexOf(value);
19
- return reversed ? array.findLast((item) => Object.is(item, value)) : array.find((item) => Object.is(item, value));
20
- }
52
+ if (callbacks?.bool == null && callbacks?.keyed == null) return findSimpleValue(array, value, findIndex, reversed);
21
53
  if (callbacks.bool != null) {
22
54
  const index = reversed ? array.findLastIndex(callbacks.bool) : array.findIndex(callbacks.bool);
23
55
  return findIndex ? index : array[index];
@@ -38,7 +70,8 @@ function findAbsoluteValueOrDefault(array, parameters, defaultValue, useDefaultV
38
70
  return useDefaultValue ? defaultValue : void 0;
39
71
  }
40
72
  const index = findValue(ARRAY_FIND_VALUE_INDEX, array, parameters, reversed);
41
- return index > -1 ? array[index] : useDefaultValue ? defaultValue : void 0;
73
+ if (index === -1) return useDefaultValue ? defaultValue : void 0;
74
+ return array[index];
42
75
  }
43
76
  function findValues(type, array, parameters, mapper) {
44
77
  const result = {
@@ -55,36 +88,26 @@ function findValues(type, array, parameters, mapper) {
55
88
  }
56
89
  const mapCallback = getArrayCallback(mapper?.callback);
57
90
  const mapReverse = mapper?.reverse ?? false;
58
- const mapAfter = mapCallback == null ? void 0 : mapReverse ? void 0 : mapCallback;
59
- const mapBefore = mapCallback == null ? void 0 : mapReverse ? mapCallback : void 0;
60
- if (callbacks?.bool != null || type === "all" && key == null) {
61
- const callback = callbacks?.bool ?? ((item) => Object.is(item, value));
62
- for (let index = 0; index < length; index += 1) {
63
- const item = array[index];
64
- const transformed = mapBefore?.(item, index, array) ?? item;
65
- if (callback(transformed, index, array)) result.matched.push(mapAfter?.(item, index, array) ?? transformed);
66
- else result.notMatched.push(item);
67
- }
68
- return result;
91
+ let mapAfter;
92
+ let mapBefore;
93
+ if (mapCallback == null) {
94
+ mapAfter = void 0;
95
+ mapBefore = void 0;
96
+ } else {
97
+ mapAfter = mapReverse ? void 0 : mapCallback;
98
+ mapBefore = mapReverse ? mapCallback : void 0;
69
99
  }
70
- const keys = /* @__PURE__ */ new Set();
71
- for (let index = 0; index < length; index += 1) {
72
- const item = array[index];
73
- let keyed;
74
- let transformed;
75
- if (mapBefore == null) {
76
- keyed = callbacks?.keyed?.(item, index, array) ?? item;
77
- transformed = item;
78
- } else {
79
- transformed = mapBefore(item, index, array);
80
- keyed = callbacks?.keyed?.(transformed, index, array) ?? transformed;
81
- }
82
- if (type === "all" && Object.is(keyed, value) || type === "unique" && !keys.has(keyed)) {
83
- keys.add(keyed);
84
- result.matched.push(mapAfter?.(item, index, array) ?? transformed);
85
- } else result.notMatched.push(item);
86
- }
87
- return result;
100
+ if (callbacks?.bool != null || type === "all" && key == null) return findSimpleValues(array, length, value, callbacks?.bool, mapBefore, mapAfter, result);
101
+ return findComplexValues({
102
+ array,
103
+ length,
104
+ mapAfter,
105
+ mapBefore,
106
+ result,
107
+ type,
108
+ value,
109
+ keyCallback: callbacks?.keyed
110
+ });
88
111
  }
89
112
  //#endregion
90
113
  export { createFindParameters, findAbsoluteValueOrDefault, findValue, findValues };
@@ -3,7 +3,7 @@ import { chunk } from "./chunk.mjs";
3
3
  import { max, min } from "../math/aggregate.mjs";
4
4
  //#region src/internal/array/insert.ts
5
5
  function insertChunkedValues(type, array, items, start, deleteCount) {
6
- const actualDeleteCount = deleteCount < 0 ? 0 : deleteCount;
6
+ const actualDeleteCount = max([deleteCount, 0]);
7
7
  const actualStart = min([max([0, start]), array.length]);
8
8
  const chunked = chunk(items);
9
9
  const lastIndex = chunked.length - 1;
@@ -4,6 +4,21 @@ import { ARRAY_MATCH_COMPARISON_INSIDE, ARRAY_MATCH_COMPARISON_SAME, ARRAY_MATCH
4
4
  function endsWithArray(haystack, needle, key) {
5
5
  return arrayMatchEndings.has(getPosition(haystack, needle, key)[1]);
6
6
  }
7
+ function evaluatePosition(haystack, haystackLength, needle, needleLength, key) {
8
+ const callback = getArrayCallback(key);
9
+ const limit = haystackLength - needleLength + 1;
10
+ let needleValues = callback == null ? needle : needle.slice();
11
+ if (callback != null) for (let needleIndex = 0; needleIndex < needleLength; needleIndex += 1) needleValues[needleIndex] = callback(needle[needleIndex], needleIndex, needle);
12
+ for (let haystackIndex = 0; haystackIndex < limit; haystackIndex += 1) {
13
+ if (!inHaystack(haystack, haystackIndex, needleValues, 0, callback)) continue;
14
+ if (needleLength === 1) return [haystackIndex, getName(haystackIndex, haystackLength, needleLength)];
15
+ for (let needleIndex = 1; needleIndex < needleLength; needleIndex += 1) {
16
+ if (!inHaystack(haystack, haystackIndex, needleValues, needleIndex, callback)) break;
17
+ if (needleIndex === needleLength - 1) return [haystackIndex, getName(haystackIndex, haystackLength, needleLength)];
18
+ }
19
+ }
20
+ return arrayMatchOutside;
21
+ }
7
22
  function getArrayComparison(haystack, needle, key) {
8
23
  return getPosition(haystack, needle, key)[1];
9
24
  }
@@ -17,23 +32,12 @@ function getPosition(haystack, needle, key) {
17
32
  const needleLength = needle.length;
18
33
  if (haystackLength === 0 || needleLength === 0) return arrayMatchOutside;
19
34
  if (needleLength > haystackLength) return arrayMatchOutside;
20
- const callback = getArrayCallback(key);
21
- const limit = haystackLength - needleLength + 1;
22
- let needleValues = callback == null ? needle : needle.slice();
23
- if (callback != null) for (let needleIndex = 0; needleIndex < needleLength; needleIndex += 1) needleValues[needleIndex] = callback(needle[needleIndex], needleIndex, needle);
24
- for (let haystackIndex = 0; haystackIndex < limit; haystackIndex += 1) {
25
- let haystackItem = haystack[haystackIndex];
26
- let haystackValue = callback?.(haystackItem, haystackIndex, haystack) ?? haystackItem;
27
- if (!Object.is(haystackValue, needleValues[0])) continue;
28
- if (needleLength === 1) return [haystackIndex, getName(haystackIndex, haystackLength, needleLength)];
29
- for (let needleIndex = 1; needleIndex < needleLength; needleIndex += 1) {
30
- haystackItem = haystack[haystackIndex + needleIndex];
31
- haystackValue = callback?.(haystackItem, haystackIndex + needleIndex, haystack) ?? haystackItem;
32
- if (!Object.is(haystackValue, needleValues[needleIndex])) break;
33
- if (needleIndex === needleLength - 1) return [haystackIndex, getName(haystackIndex, haystackLength, needleLength)];
34
- }
35
- }
36
- return arrayMatchOutside;
35
+ return evaluatePosition(haystack, haystackLength, needle, needleLength, key);
36
+ }
37
+ function inHaystack(haystack, haystackIndex, needleValues, needleIndex, callback) {
38
+ const haystackItem = haystack[haystackIndex + needleIndex];
39
+ const haystackValue = callback?.(haystackItem, haystackIndex + needleIndex, haystack) ?? haystackItem;
40
+ return Object.is(haystackValue, needleValues[needleIndex]);
37
41
  }
38
42
  function includesArray(haystack, needle, key) {
39
43
  return !arrayMatchOutsides.has(getPosition(haystack, needle, key)[1]);
@@ -6,8 +6,14 @@ function compareSets(type, first, second, key) {
6
6
  const isDifference = type === ARRAY_SETS_COMPARE_DIFFERENCE;
7
7
  const isIntersection = type === ARRAY_SETS_COMPARE_INTERSECTION;
8
8
  const isUnion = type === ARRAY_SETS_COMPARE_UNION;
9
- if (first.length === 0) return isDifference ? first.slice() : isIntersection ? [] : second.slice();
9
+ if (first.length === 0) {
10
+ if (isDifference) return first.slice();
11
+ return isIntersection ? [] : second.slice();
12
+ }
10
13
  if (!Array.isArray(second) || second.length === 0) return isIntersection ? [] : first.slice();
14
+ return getComparison(first, second, isIntersection, isUnion, key);
15
+ }
16
+ function getComparison(first, second, isIntersection, isUnion, key) {
11
17
  const callback = getArrayCallback(key);
12
18
  const values = isUnion ? first : second;
13
19
  let { length } = values;
@@ -44,7 +44,10 @@ function getAggregateCallback(key) {
44
44
  }
45
45
  function getAggregated(type, array, key, first) {
46
46
  const aggregation = aggregate(type, array, key, first);
47
- if (aggregation.count === 0) return aggregation.array ? aggregation.first ? void 0 : [] : NaN;
47
+ if (aggregation.count === 0) {
48
+ if (aggregation.array) return aggregation.first ? void 0 : [];
49
+ return NaN;
50
+ }
48
51
  if (aggregation.array) {
49
52
  const array = aggregation.items[aggregation.value];
50
53
  return aggregation.first ? array[0] : array;
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * @param value Value to check
6
6
  * @param minimum Minimum value
7
- * @param maximum Maximum value
7
+ * @param maximum Maximum value _(inclusive)_
8
8
  * @returns `true` if the value is between the minimum and maximum, otherwise `false`
9
9
  */
10
10
  export declare function between(value: number, minimum: number, maximum: number): boolean;
@@ -1,4 +1,5 @@
1
1
  import { isNumber } from "./is.mjs";
2
+ import { max, min } from "./math/aggregate.mjs";
2
3
  import { EXPRESSION_NUMBER_BINARY, EXPRESSION_NUMBER_OCTAL, EXPRESSION_NUMBER_ZEROISH } from "../models/misc.model.mjs";
3
4
  //#region src/internal/number.ts
4
5
  /**
@@ -6,7 +7,7 @@ import { EXPRESSION_NUMBER_BINARY, EXPRESSION_NUMBER_OCTAL, EXPRESSION_NUMBER_ZE
6
7
  *
7
8
  * @param value Value to check
8
9
  * @param minimum Minimum value
9
- * @param maximum Maximum value
10
+ * @param maximum Maximum value _(inclusive)_
10
11
  * @returns `true` if the value is between the minimum and maximum, otherwise `false`
11
12
  */
12
13
  function between(value, minimum, maximum) {
@@ -16,7 +17,8 @@ function between(value, minimum, maximum) {
16
17
  maximum
17
18
  ].every(isNumber)) return false;
18
19
  if (Object.is(minimum, maximum)) return Object.is(value, minimum);
19
- return value >= (maximum > minimum ? minimum : maximum) && value <= (maximum > minimum ? maximum : minimum);
20
+ const maximumValue = max([maximum, minimum]);
21
+ return value >= min([maximum, minimum]) && value <= maximumValue;
20
22
  }
21
23
  /**
22
24
  * Clamp a number between a minimum and maximum value
@@ -0,0 +1,7 @@
1
+ import { GenericPlanItem, InternalAsyncPlan, InternalPlan } from "../../models/plan.model.mjs";
2
+ //#region src/internal/plan/index.d.ts
3
+ export declare function attemptRunPlan(this: InternalPlan, ...parameters: unknown[]): unknown;
4
+ export declare function getGenerator(this: GenericPlanItem): AsyncGenerator | Generator;
5
+ export declare function runAsyncPlan(this: InternalAsyncPlan, first: never, second: never): Promise<unknown>;
6
+ export declare function runPlan(this: InternalPlan, ...parameters: unknown[]): unknown;
7
+ //#endregion
@@ -0,0 +1,18 @@
1
+ import { attempt } from "../result/attempt.mjs";
2
+ import { PLAN_SYMBOL } from "../../models/plan.model.mjs";
3
+ import { asyncGenerate, generate } from "./plan.generate.mjs";
4
+ //#region src/internal/plan/index.ts
5
+ function attemptRunPlan(...parameters) {
6
+ return attempt(() => generate(this[PLAN_SYMBOL], parameters, true));
7
+ }
8
+ function getGenerator() {
9
+ return this[PLAN_SYMBOL].generator();
10
+ }
11
+ function runAsyncPlan(first, second) {
12
+ return asyncGenerate(this[PLAN_SYMBOL], false, first, second);
13
+ }
14
+ function runPlan(...parameters) {
15
+ return generate(this[PLAN_SYMBOL], parameters, false);
16
+ }
17
+ //#endregion
18
+ export { attemptRunPlan, getGenerator, runAsyncPlan, runPlan };
@@ -1,5 +1,5 @@
1
- import { AsyncPlanState, PlanState } from "../models/plan.model.mjs";
2
- //#region src/plan/generate.d.ts
1
+ import { AsyncPlanState, PlanState } from "../../models/plan.model.mjs";
2
+ //#region src/internal/plan/plan.generate.d.ts
3
3
  export declare function asyncGenerate(input: AsyncPlanState | ((...args: unknown[]) => AsyncGenerator), unwrap: boolean, first?: unknown, second?: unknown): Promise<unknown>;
4
4
  export declare function generate(input: PlanState | ((...parameters: unknown[]) => Generator), parameters: unknown[], unwrap: boolean): unknown;
5
5
  //#endregion
@@ -1,10 +1,10 @@
1
- import { noop } from "../internal/function/misc.mjs";
2
- import { createAborter } from "../internal/aborter.mjs";
3
- import { isError, isOk } from "../internal/result/misc.mjs";
4
- //#region src/plan/generate.ts
1
+ import { noop } from "../function/misc.mjs";
2
+ import { createAborter } from "../aborter.mjs";
3
+ import { isError, isOk } from "../result/misc.mjs";
4
+ //#region src/internal/plan/plan.generate.ts
5
5
  async function asyncGenerate(input, unwrap, first, second) {
6
6
  const aborter = createAborter(second ?? first, noop);
7
- if (aborter != null && aborter.signal.aborted) throw aborter.signal.reason;
7
+ if (aborter?.signal.aborted) throw aborter.signal.reason;
8
8
  const parameters = Array.isArray(first) ? first : [];
9
9
  let generator;
10
10
  if (typeof input === "function") generator = input(...parameters);
@@ -13,7 +13,7 @@ async function asyncGenerate(input, unwrap, first, second) {
13
13
  let lastValue;
14
14
  try {
15
15
  while (true) {
16
- if (aborter != null && aborter.signal.aborted) await generator.throw(aborter.signal.reason);
16
+ if (aborter?.signal.aborted) await generator.throw(aborter.signal.reason);
17
17
  const next = await generator.next(lastValue);
18
18
  const done = next.done === true;
19
19
  const { value } = next;
@@ -29,7 +29,7 @@ async function asyncGenerate(input, unwrap, first, second) {
29
29
  aborter?.cancel();
30
30
  await generator.return(lastValue);
31
31
  }
32
- if (aborter != null && aborter.signal.aborted) throw aborter.signal.reason;
32
+ if (aborter?.signal.aborted) throw aborter.signal.reason;
33
33
  if (success) return unwrap && isOk(lastValue) ? lastValue.value : lastValue;
34
34
  throw lastValue;
35
35
  }
@@ -1,4 +1,10 @@
1
1
  //#region src/internal/random.d.ts
2
+ /**
3
+ * Get a random number between 0 _(inclusive)_ and 1 _(exclusive)_
4
+ *
5
+ * @returns Random number
6
+ */
7
+ export declare function getRandom(): number;
2
8
  /**
3
9
  * Get a random floating-point number
4
10
  *
@@ -1,12 +1,22 @@
1
1
  import { isNumber } from "./is.mjs";
2
2
  import { floor } from "./math/misc.mjs";
3
3
  //#region src/internal/random.ts
4
+ /**
5
+ * Get a random number between 0 _(inclusive)_ and 1 _(exclusive)_
6
+ *
7
+ * @returns Random number
8
+ */
9
+ function getRandom() {
10
+ /* istanbul ignore if */
11
+ if (globalThis.crypto == null) return Math.random();
12
+ return globalThis.crypto.getRandomValues(/* @__PURE__ */ new Uint32Array(1))[0] / RANDOM_DIVISOR;
13
+ }
4
14
  function getRandomFloatingNumberValue(inclusive, minimum, maximum) {
5
15
  let maxFloat = isNumber(maximum) && maximum <= Number.MAX_SAFE_INTEGER ? maximum : Number.MAX_SAFE_INTEGER;
6
16
  let minFloat = isNumber(minimum) && minimum >= Number.MIN_SAFE_INTEGER ? minimum : Number.MIN_SAFE_INTEGER;
7
17
  if (minFloat === maxFloat) return minFloat;
8
18
  if (minFloat > maxFloat) [minFloat, maxFloat] = [maxFloat, minFloat];
9
- return Math.random() * (maxFloat + (inclusive ? 1 : 0) - minFloat) + minFloat;
19
+ return getRandom() * (maxFloat + (inclusive ? 1 : 0) - minFloat) + minFloat;
10
20
  }
11
21
  /**
12
22
  * Get a random floating-point number
@@ -28,5 +38,6 @@ function getRandomFloatingNumber(minimum, maximum) {
28
38
  function getRandomInteger(minimum, maximum) {
29
39
  return floor(getRandomFloatingNumberValue(true, minimum, maximum));
30
40
  }
41
+ const RANDOM_DIVISOR = 2 ** 32;
31
42
  //#endregion
32
- export { getRandomFloatingNumber, getRandomInteger };
43
+ export { getRandom, getRandomFloatingNumber, getRandomInteger };
@@ -7,16 +7,16 @@ async function asyncAttempt(value, err) {
7
7
  else result = value;
8
8
  if (result instanceof Promise) result = await result;
9
9
  return ok(result);
10
- } catch (thrown) {
11
- return getError(err ?? thrown, err == null ? void 0 : thrown);
10
+ } catch (error) {
11
+ return getError(err ?? error, err == null ? void 0 : error);
12
12
  }
13
13
  }
14
14
  function attempt(callback, err) {
15
15
  try {
16
16
  const value = callback();
17
17
  return ok(value);
18
- } catch (thrown) {
19
- return getError(err ?? thrown, err == null ? void 0 : thrown);
18
+ } catch (error) {
19
+ return getError(err ?? error, err == null ? void 0 : error);
20
20
  }
21
21
  }
22
22
  attempt.async = asyncAttempt;
@@ -75,7 +75,8 @@ function tryEncode(value) {
75
75
  * @returns Array of words found in the string
76
76
  */
77
77
  function words(value) {
78
- return typeof value === "string" ? value.match(STRING_EXPRESSION_WORDS) ?? [] : [];
78
+ if (typeof value === "string") return value.match(STRING_EXPRESSION_WORDS) ?? [];
79
+ return [];
79
80
  }
80
81
  //#endregion
81
82
  export { getString, ignoreKey, interpolate, join, tryDecode, tryEncode, words };
@@ -125,7 +125,7 @@ function createSubscriptionsProperty(input) {
125
125
  const values = isPlainObject(input) ? input : {};
126
126
  return {
127
127
  key: typeof values.key === "string" ? values.key : SUBSCRIPTION_PROPERTY,
128
- value: values.value == null ? SUBSCRIPTION_NAME : values.value
128
+ value: values.value ?? "subscription"
129
129
  };
130
130
  }
131
131
  function createSubscriptionsState(property, keys) {
@@ -1,5 +1,6 @@
1
1
  import { isNonPlainObject, isPlainObject, isPrimitive, isTypedArray } from "../is.mjs";
2
2
  import { round } from "../math/misc.mjs";
3
+ import { min } from "../math/aggregate.mjs";
3
4
  import { createCompareHandler } from "./handlers.mjs";
4
5
  import { EQUAL_ERROR_PROPERTIES, EQUAL_EXPRESSION_PROPERTIES, EQUAL_SYMBOL } from "../../models/value/value.equal.model.mjs";
5
6
  //#region src/internal/value/equal.ts
@@ -63,7 +64,7 @@ function equalArray(first, second, options) {
63
64
  let offset = 0;
64
65
  if (length >= 100) {
65
66
  offset = round(length / 10);
66
- offset = offset > 100 ? 100 : offset;
67
+ offset = min([offset, 100]);
67
68
  for (let index = 0; index < offset; index += 1) if (!(equalValue(first[index], second[index], options) && equalValue(first[length - index - 1], second[length - index - 1], options))) return false;
68
69
  }
69
70
  const end = length - offset;
@@ -2,7 +2,9 @@ import { isPlainObject } from "../is.mjs";
2
2
  //#region src/internal/value/partial.ts
3
3
  function partial(value, providedKeys, omit) {
4
4
  if (!isPlainObject(value)) return {};
5
- const keys = omit ? Object.keys(value) : Array.isArray(providedKeys) ? providedKeys : [];
5
+ let keys;
6
+ if (omit) keys = Object.keys(value);
7
+ else keys = Array.isArray(providedKeys) ? providedKeys : [];
6
8
  const { length } = keys;
7
9
  if (length === 0) return omit ? value : {};
8
10
  const partials = {};
@@ -307,4 +307,5 @@ export type ColorValue = string | HSLColor | HWBColor | RGBColor;
307
307
  * Extended color values
308
308
  */
309
309
  export type ColorValueExtended = ColorValue | HSLAColor | HWBAColor | RGBAColor;
310
- //#endregion
310
+ //#endregion
311
+ export {};
@@ -73,4 +73,5 @@ export declare const ONCE_PROPERTY = "$once";
73
73
  export declare const ONCE_MESSAGE_CLEARED = "Once has been cleared";
74
74
  export declare const ONCE_MESSAGE_EXPECTATION = "Once expected a function";
75
75
  export declare const ONCE_SYMBOL: unique symbol;
76
- //#endregion
76
+ //#endregion
77
+ export {};
@@ -124,4 +124,5 @@ export type UnionToIntersection<Union> = (Union extends unknown ? (distributedUn
124
124
  * A function that unsubscribes from a subscription
125
125
  */
126
126
  export type Unsubscriber = () => void;
127
- //#endregion
127
+ //#endregion
128
+ export {};