@oscarpalmer/atoms 0.188.0 → 0.189.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 (130) hide show
  1. package/dist/array/difference.d.mts +0 -1
  2. package/dist/array/exists.d.mts +0 -1
  3. package/dist/array/filter.d.mts +0 -1
  4. package/dist/array/find.d.mts +0 -1
  5. package/dist/array/first.d.mts +0 -1
  6. package/dist/array/flatten.d.mts +0 -1
  7. package/dist/array/get.d.mts +0 -1
  8. package/dist/array/group-by.d.mts +0 -1
  9. package/dist/array/last.d.mts +0 -1
  10. package/dist/array/match.d.mts +0 -1
  11. package/dist/array/match.mjs +3 -3
  12. package/dist/array/move.d.mts +0 -1
  13. package/dist/array/partition.d.mts +0 -1
  14. package/dist/array/select.d.mts +0 -1
  15. package/dist/array/select.mjs +2 -1
  16. package/dist/array/single.d.mts +0 -1
  17. package/dist/array/slice.d.mts +0 -1
  18. package/dist/array/sort.d.mts +1 -2
  19. package/dist/array/sort.mjs +0 -1
  20. package/dist/array/swap.d.mts +0 -1
  21. package/dist/array/to-map.d.mts +0 -1
  22. package/dist/array/to-record.d.mts +0 -1
  23. package/dist/array/to-set.d.mts +0 -1
  24. package/dist/array/toggle.d.mts +0 -1
  25. package/dist/array/unique.d.mts +0 -1
  26. package/dist/array/update.d.mts +0 -1
  27. package/dist/color/constants.d.mts +9 -10
  28. package/dist/color/constants.mjs +15 -7
  29. package/dist/color/index.d.mts +9 -9
  30. package/dist/color/index.mjs +8 -7
  31. package/dist/color/instance.d.mts +35 -8
  32. package/dist/color/instance.mjs +53 -13
  33. package/dist/color/misc/alpha.d.mts +0 -1
  34. package/dist/color/misc/alpha.mjs +5 -5
  35. package/dist/color/misc/get.d.mts +42 -13
  36. package/dist/color/misc/get.mjs +45 -24
  37. package/dist/color/misc/index.d.mts +4 -4
  38. package/dist/color/misc/index.mjs +12 -12
  39. package/dist/color/misc/is.d.mts +56 -3
  40. package/dist/color/misc/is.mjs +72 -4
  41. package/dist/color/misc/state.d.mts +2 -2
  42. package/dist/color/misc/state.mjs +79 -43
  43. package/dist/color/models.d.mts +18 -2
  44. package/dist/color/space/hex.d.mts +38 -5
  45. package/dist/color/space/hex.mjs +57 -9
  46. package/dist/color/space/hsl.d.mts +33 -7
  47. package/dist/color/space/hsl.mjs +65 -14
  48. package/dist/color/space/hwb.d.mts +52 -0
  49. package/dist/color/space/hwb.mjs +99 -0
  50. package/dist/color/space/rgb.d.mts +26 -5
  51. package/dist/color/space/rgb.mjs +82 -28
  52. package/dist/function/assert.d.mts +1 -2
  53. package/dist/function/limit.d.mts +0 -1
  54. package/dist/function/memoize.d.mts +0 -1
  55. package/dist/function/once.d.mts +0 -1
  56. package/dist/function/retry.d.mts +0 -1
  57. package/dist/function/work.d.mts +0 -1
  58. package/dist/herald.d.mts +0 -1
  59. package/dist/index.d.mts +296 -51
  60. package/dist/index.mjs +664 -265
  61. package/dist/internal/array/callbacks.d.mts +0 -1
  62. package/dist/internal/array/callbacks.mjs +0 -1
  63. package/dist/internal/array/group.d.mts +0 -1
  64. package/dist/internal/array/index-of.d.mts +0 -1
  65. package/dist/internal/function/timer.d.mts +0 -1
  66. package/dist/internal/is.d.mts +0 -1
  67. package/dist/internal/is.mjs +1 -1
  68. package/dist/internal/math/aggregate.d.mts +0 -1
  69. package/dist/internal/math/misc.d.mts +12 -0
  70. package/dist/internal/math/misc.mjs +19 -0
  71. package/dist/internal/result.d.mts +0 -1
  72. package/dist/internal/value/compare.d.mts +0 -1
  73. package/dist/internal/value/equal.d.mts +0 -1
  74. package/dist/internal/value/get.d.mts +0 -1
  75. package/dist/internal/value/handlers.d.mts +0 -1
  76. package/dist/internal/value/has.d.mts +0 -1
  77. package/dist/internal/value/misc.d.mts +0 -1
  78. package/dist/internal/value/set.d.mts +0 -1
  79. package/dist/is.d.mts +0 -1
  80. package/dist/math.d.mts +1 -9
  81. package/dist/math.mjs +1 -16
  82. package/dist/models.d.mts +6 -6
  83. package/dist/promise/delay.d.mts +0 -1
  84. package/dist/promise/helpers.d.mts +0 -1
  85. package/dist/promise/index.d.mts +0 -1
  86. package/dist/promise/misc.d.mts +0 -1
  87. package/dist/promise/models.d.mts +4 -5
  88. package/dist/promise/models.mjs +1 -1
  89. package/dist/promise/timed.d.mts +0 -1
  90. package/dist/query.d.mts +0 -1
  91. package/dist/query.mjs +1 -1
  92. package/dist/queue.d.mts +0 -1
  93. package/dist/random.d.mts +0 -1
  94. package/dist/result/index.d.mts +0 -1
  95. package/dist/result/index.mjs +2 -1
  96. package/dist/result/match.d.mts +0 -1
  97. package/dist/result/misc.d.mts +0 -1
  98. package/dist/result/models.d.mts +0 -1
  99. package/dist/result/work/flow.d.mts +0 -1
  100. package/dist/result/work/pipe.d.mts +0 -1
  101. package/dist/string/fuzzy.d.mts +0 -1
  102. package/dist/string/index.d.mts +0 -1
  103. package/dist/string/index.mjs +8 -7
  104. package/dist/string/template.d.mts +0 -1
  105. package/dist/value/clone.d.mts +0 -1
  106. package/dist/value/freeze.d.mts +1 -2
  107. package/dist/value/merge.d.mts +0 -1
  108. package/dist/value/omit.d.mts +0 -1
  109. package/dist/value/pick.d.mts +0 -1
  110. package/dist/value/shake.d.mts +1 -2
  111. package/dist/value/smush.d.mts +1 -2
  112. package/dist/value/transform.d.mts +1 -2
  113. package/dist/value/unsmush.d.mts +1 -2
  114. package/package.json +5 -5
  115. package/src/color/constants.ts +17 -13
  116. package/src/color/index.ts +21 -6
  117. package/src/color/instance.ts +67 -14
  118. package/src/color/misc/alpha.ts +6 -10
  119. package/src/color/misc/get.ts +70 -16
  120. package/src/color/misc/index.ts +18 -17
  121. package/src/color/misc/is.ts +86 -3
  122. package/src/color/misc/state.ts +126 -40
  123. package/src/color/models.ts +19 -1
  124. package/src/color/space/hex.ts +55 -8
  125. package/src/color/space/hsl.ts +80 -14
  126. package/src/color/space/hwb.ts +123 -0
  127. package/src/color/space/rgb.ts +108 -27
  128. package/src/internal/math/misc.ts +28 -0
  129. package/src/math.ts +2 -29
  130. package/src/string/index.ts +13 -11
@@ -1,5 +1,4 @@
1
1
  import { GenericCallback } from "../../models.mjs";
2
-
3
2
  //#region src/internal/array/callbacks.d.ts
4
3
  type Callbacks = {
5
4
  bool?: GenericCallback;
@@ -4,7 +4,6 @@ function getArrayCallback(value) {
4
4
  case "function": return value;
5
5
  case "number":
6
6
  case "string": return typeof value === "string" && value.includes(".") ? void 0 : (obj) => obj[value];
7
- default: break;
8
7
  }
9
8
  }
10
9
  function getArrayCallbacks(bool, key, value) {
@@ -1,5 +1,4 @@
1
1
  import { Key } from "../../models.mjs";
2
-
3
2
  //#region src/internal/array/group.d.ts
4
3
  declare function groupValues(array: unknown[], key: unknown, value: unknown, arrays: boolean): Record<Key, unknown>;
5
4
  //#endregion
@@ -1,5 +1,4 @@
1
1
  import { PlainObject } from "../../models.mjs";
2
-
3
2
  //#region src/internal/array/index-of.d.ts
4
3
  /**
5
4
  * Get the index of the first matching item by callback
@@ -1,5 +1,4 @@
1
1
  import { AsyncCancelableCallback, CancelableCallback, GenericAsyncCallback, GenericCallback } from "../../models.mjs";
2
-
3
2
  //#region src/internal/function/timer.d.ts
4
3
  type TimerType = 'debounce' | 'throttle' | 'wait';
5
4
  declare function getAsyncTimer<Callback extends GenericAsyncCallback | GenericCallback>(type: TimerType, callback: Callback, time?: number): AsyncCancelableCallback<Callback>;
@@ -1,5 +1,4 @@
1
1
  import { ArrayOrPlainObject, Constructor, Key, PlainObject, Primitive, TypedArray } from "../models.mjs";
2
-
3
2
  //#region src/internal/is.d.ts
4
3
  /**
5
4
  * Is the value an array or a plain object?
@@ -166,7 +166,7 @@ function isTemplateStringsArray(value) {
166
166
  * @returns `true` if the value is a typed array, otherwise `false`
167
167
  */
168
168
  function isTypedArray(value) {
169
- isTypedArray.types ??= new Set([
169
+ isTypedArray.types ??= /* @__PURE__ */ new Set([
170
170
  Int8Array,
171
171
  Uint8Array,
172
172
  Uint8ClampedArray,
@@ -1,5 +1,4 @@
1
1
  import { NumericalValues, PlainObject } from "../../models.mjs";
2
-
3
2
  //#region src/internal/math/aggregate.d.ts
4
3
  type Aggregation = {
5
4
  count: number;
@@ -0,0 +1,12 @@
1
+ //#region src/internal/math/misc.d.ts
2
+ /**
3
+ * Round a number
4
+ *
5
+ * @param value Number to round
6
+ * @param decimals Number of decimal places to round to _(defaults to `0`)_
7
+ * @returns Rounded number, or `Number.NaN` if the value if unable to be rounded
8
+ */
9
+ declare function round(value: number, decimals?: number): number;
10
+ declare function roundNumber(callback: (value: number) => number, value: number, decimals?: number): number;
11
+ //#endregion
12
+ export { round, roundNumber };
@@ -0,0 +1,19 @@
1
+ //#region src/internal/math/misc.ts
2
+ /**
3
+ * Round a number
4
+ *
5
+ * @param value Number to round
6
+ * @param decimals Number of decimal places to round to _(defaults to `0`)_
7
+ * @returns Rounded number, or `Number.NaN` if the value if unable to be rounded
8
+ */
9
+ function round(value, decimals) {
10
+ return roundNumber(Math.round, value, decimals);
11
+ }
12
+ function roundNumber(callback, value, decimals) {
13
+ if (typeof value !== "number") return NaN;
14
+ if (typeof decimals !== "number" || decimals < 1) return callback(value);
15
+ const mod = 10 ** decimals;
16
+ return callback((value + Number.EPSILON) * mod) / mod;
17
+ }
18
+ //#endregion
19
+ export { round, roundNumber };
@@ -1,5 +1,4 @@
1
1
  import { Err, ExtendedErr, Ok, Result } from "../result/models.mjs";
2
-
3
2
  //#region src/internal/result.d.ts
4
3
  /**
5
4
  * Is the _Result_ an extended error?
@@ -1,5 +1,4 @@
1
1
  import { Constructor, GenericCallback } from "../../models.mjs";
2
-
3
2
  //#region src/internal/value/compare.d.ts
4
3
  type Comparator<Value = any> = (first: Value, second: Value) => number;
5
4
  /**
@@ -1,5 +1,4 @@
1
1
  import { Constructor, GenericCallback } from "../../models.mjs";
2
-
3
2
  //#region src/internal/value/equal.d.ts
4
3
  /**
5
4
  * Options for value equality comparison
@@ -1,5 +1,4 @@
1
1
  import { NestedKeys, NestedValue, PlainObject } from "../../models.mjs";
2
-
3
2
  //#region src/internal/value/get.d.ts
4
3
  /**
5
4
  * Get the value from an object using a known path
@@ -1,5 +1,4 @@
1
1
  import { Constructor, GenericCallback } from "../../models.mjs";
2
-
3
2
  //#region src/internal/value/handlers.d.ts
4
3
  type Options = {
5
4
  callback: GenericCallback;
@@ -1,6 +1,5 @@
1
1
  import { NestedKeys, NestedValue, PlainObject, ToString } from "../../models.mjs";
2
2
  import { Result } from "../../result/models.mjs";
3
-
4
3
  //#region src/internal/value/has.d.ts
5
4
  /**
6
5
  * Check if a property is defined in an object
@@ -1,5 +1,4 @@
1
1
  import { Result } from "../../result/models.mjs";
2
-
3
2
  //#region src/internal/value/misc.d.ts
4
3
  declare function findKey(needle: string, haystack: object): string;
5
4
  declare function getNestedValue(data: object, path: string, ignoreCase: boolean): Result<unknown, string>;
@@ -1,5 +1,4 @@
1
1
  import { NestedKeys, NestedValue, PlainObject } from "../../models.mjs";
2
-
3
2
  //#region src/internal/value/set.d.ts
4
3
  /**
5
4
  * Update the value in an object using a known path
package/dist/is.d.mts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { isArrayOrPlainObject, isConstructor, isInstanceOf, isKey, isNonArrayOrPlainObject, isNonConstructor, isNonInstanceOf, isNonKey, isNonNumber, isNonPlainObject, isNonPrimitive, isNonTypedArray, isNumber, isPlainObject, isPrimitive, isTypedArray } from "./internal/is.mjs";
2
-
3
2
  //#region src/is.d.ts
4
3
  /**
5
4
  * Is the value empty, or only containing `null` or `undefined` values?
package/dist/math.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { NumericalValues, PlainObject } from "./models.mjs";
2
2
  import { max } from "./internal/math/aggregate.mjs";
3
-
3
+ import { round } from "./internal/math/misc.mjs";
4
4
  //#region src/math.d.ts
5
5
  /**
6
6
  * Get the average value from a list of items
@@ -112,14 +112,6 @@ declare function min<Item extends PlainObject>(items: Item[], key: keyof Numeric
112
112
  * @returns Minimum value, or `Number.NaN` if no minimum can be found
113
113
  */
114
114
  declare function min(values: number[]): number;
115
- /**
116
- * Round a number
117
- *
118
- * @param value Number to round
119
- * @param decimals Number of decimal places to round to _(defaults to `0`)_
120
- * @returns Rounded number, or `Number.NaN` if the value if unable to be rounded
121
- */
122
- declare function round(value: number, decimals?: number): number;
123
115
  /**
124
116
  * Get the sum of a list of items
125
117
  *
package/dist/math.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { isNumber } from "./internal/is.mjs";
2
2
  import { AGGREGATION_AVERAGE, aggregate, getAggregateCallback, getAggregated, max } from "./internal/math/aggregate.mjs";
3
+ import { round, roundNumber } from "./internal/math/misc.mjs";
3
4
  //#region src/math.ts
4
5
  function average(array, key) {
5
6
  const aggregated = aggregate(AGGREGATION_AVERAGE, array, key);
@@ -56,22 +57,6 @@ function median(array, key) {
56
57
  function min(array, key) {
57
58
  return getAggregated("min", array, key);
58
59
  }
59
- /**
60
- * Round a number
61
- *
62
- * @param value Number to round
63
- * @param decimals Number of decimal places to round to _(defaults to `0`)_
64
- * @returns Rounded number, or `Number.NaN` if the value if unable to be rounded
65
- */
66
- function round(value, decimals) {
67
- return roundNumber(Math.round, value, decimals);
68
- }
69
- function roundNumber(callback, value, decimals) {
70
- if (typeof value !== "number") return NaN;
71
- if (typeof decimals !== "number" || decimals < 1) return callback(value);
72
- const mod = 10 ** decimals;
73
- return callback((value + Number.EPSILON) * mod) / mod;
74
- }
75
60
  function sum(array, key) {
76
61
  return getAggregated("sum", array, key);
77
62
  }
package/dist/models.d.mts CHANGED
@@ -59,11 +59,11 @@ type NestedArray<Value> = Value extends Array<infer NestedValue> ? NestedArray<N
59
59
  * All nested keys of an object as dot notation strings _(up to 5 levels deep)_
60
60
  */
61
61
  type NestedKeys<Value extends PlainObject> = _NestedKeys<Value>;
62
- type _NestedKeys<Value, Depth extends number = 5> = Depth extends 0 ? never : Value extends readonly any[] ? Value extends readonly [any, ...any] ? { [ItemKey in keyof Value]-?: ItemKey extends `${number}` ? NonNullable<Value[ItemKey]> extends readonly any[] | PlainObject ? `${ItemKey}` | `${ItemKey}.${_NestedKeys<NonNullable<Value[ItemKey]>, SubtractDepth<Depth>>}` : `${ItemKey}` : never }[number] : never : Value extends PlainObject ? { [ItemKey in keyof Value]-?: ItemKey extends number | string ? NonNullable<Value[ItemKey]> extends readonly any[] | PlainObject ? `${ItemKey}` | `${ItemKey}.${_NestedKeys<NonNullable<Value[ItemKey]>, SubtractDepth<Depth>>}` : `${ItemKey}` : never }[keyof Value] : never;
62
+ type _NestedKeys<Value, Depth extends number = 5> = Depth extends 0 ? never : Value extends readonly any[] ? Value extends readonly [any, ...any] ? { [ItemKey in keyof Value]-?: ItemKey extends `${number}` ? NonNullable<Value[ItemKey]> extends readonly any[] | PlainObject ? `${ItemKey}` | `${ItemKey}.${_NestedKeys<NonNullable<Value[ItemKey]>, SubtractDepth<Depth>>}` : `${ItemKey}` : never; }[number] : never : Value extends PlainObject ? { [ItemKey in keyof Value]-?: ItemKey extends number | string ? NonNullable<Value[ItemKey]> extends readonly any[] | PlainObject ? `${ItemKey}` | `${ItemKey}.${_NestedKeys<NonNullable<Value[ItemKey]>, SubtractDepth<Depth>>}` : `${ItemKey}` : never; }[keyof Value] : never;
63
63
  /**
64
64
  * An extended version of `Partial` that allows for nested properties to be optional
65
65
  */
66
- type NestedPartial<Value> = { [ItemKey in keyof Value]?: Value[ItemKey] extends object ? NestedPartial<Value[ItemKey]> : Value[ItemKey] };
66
+ type NestedPartial<Value> = { [ItemKey in keyof Value]?: Value[ItemKey] extends object ? NestedPartial<Value[ItemKey]> : Value[ItemKey]; };
67
67
  /**
68
68
  * The value for a nested key of an object
69
69
  */
@@ -72,15 +72,15 @@ type _NestedValue<Value, Path extends string> = Path extends `${infer ItemKey}.$
72
72
  /**
73
73
  * The nested _(keyed)_ values of an object _(up to 5 levels deep)_
74
74
  */
75
- type NestedValues<Value extends PlainObject> = { [Path in NestedKeys<Value>]: NestedValue<Value, Path> };
75
+ type NestedValues<Value extends PlainObject> = { [Path in NestedKeys<Value>]: NestedValue<Value, Path>; };
76
76
  /**
77
77
  * The numerical keys of an object
78
78
  */
79
- type NumericalKeys<Value> = { [ItemKey in keyof Value]: ItemKey extends number ? ItemKey : ItemKey extends `${number}` ? ItemKey : never }[keyof Value];
79
+ type NumericalKeys<Value> = { [ItemKey in keyof Value]: ItemKey extends number ? ItemKey : ItemKey extends `${number}` ? ItemKey : never; }[keyof Value];
80
80
  /**
81
81
  * The numerical values of an object
82
82
  */
83
- type NumericalValues<Item extends PlainObject> = { [ItemKey in keyof Item as Item[ItemKey] extends number ? ItemKey : never]: Item[ItemKey] };
83
+ type NumericalValues<Item extends PlainObject> = { [ItemKey in keyof Item as Item[ItemKey] extends number ? ItemKey : never]: Item[ItemKey]; };
84
84
  /**
85
85
  * An asynchronous function that can only be called once, returning the same value on subsequent calls
86
86
  */
@@ -131,7 +131,7 @@ type RequiredKeys<Model extends object, Keys extends keyof Model> = Required<Pic
131
131
  *
132
132
  * _(Thanks, type-fest!)_
133
133
  */
134
- type Simplify<Value> = { [ValueKey in keyof Value]: Value[ValueKey] } & {};
134
+ type Simplify<Value> = { [ValueKey in keyof Value]: Value[ValueKey]; } & {};
135
135
  type SubtractDepth<Value extends number> = Value extends 5 ? 4 : Value extends 4 ? 3 : Value extends 3 ? 2 : Value extends 2 ? 1 : Value extends 1 ? 0 : never;
136
136
  /**
137
137
  * Get the value's type as a string
@@ -1,5 +1,4 @@
1
1
  import { PromiseOptions } from "./models.mjs";
2
-
3
2
  //#region src/promise/delay.d.ts
4
3
  /**
5
4
  * Create a delayed promise that resolves after a certain amount of time, or rejects if aborted
@@ -1,7 +1,6 @@
1
1
  import { RequiredKeys } from "../models.mjs";
2
2
  import { Result } from "../result/models.mjs";
3
3
  import { FulfilledPromise, PromiseOptions, PromiseStrategy, PromisesOptions, PromisesValue, RejectedPromise } from "./models.mjs";
4
-
5
4
  //#region src/promise/helpers.d.ts
6
5
  declare function getPromiseOptions(input: unknown): RequiredKeys<PromiseOptions, 'time'>;
7
6
  declare function getPromisesOptions(input: unknown): RequiredKeys<PromisesOptions, 'strategy'>;
@@ -1,6 +1,5 @@
1
1
  import { Result } from "../result/models.mjs";
2
2
  import { PromiseOptions, PromisesItems, PromisesOptions, PromisesResult, PromisesUnwrapped, PromisesValue, PromisesValues } from "./models.mjs";
3
-
4
3
  //#region src/promise/index.d.ts
5
4
  /**
6
5
  * Wrap a _Promise_ with safety handlers, with optional abort capabilities and timeout
@@ -2,7 +2,6 @@ import { Result } from "../result/models.mjs";
2
2
  import { CancelablePromise, PromiseParameters } from "./models.mjs";
3
3
  import { toPromise } from "../result/misc.mjs";
4
4
  import { isFulfilled, isRejected } from "./helpers.mjs";
5
-
6
5
  //#region src/promise/misc.d.ts
7
6
  /**
8
7
  * Create a cancelable _Promise_
@@ -1,6 +1,5 @@
1
1
  import { GenericCallback } from "../models.mjs";
2
2
  import { Result } from "../result/models.mjs";
3
-
4
3
  //#region src/promise/models.d.ts
5
4
  /**
6
5
  * A _Promise_ that can be canceled
@@ -71,7 +70,7 @@ type PromiseStrategy = 'complete' | 'first';
71
70
  declare class PromiseTimeoutError extends Error {
72
71
  constructor();
73
72
  }
74
- type PromisesItems<Items extends unknown[]> = { [ItemsKey in keyof Items]: Items[ItemsKey] extends GenericCallback ? ReturnType<Items[ItemsKey]> extends Promise<infer Value> ? Promise<Value> : never : Items[ItemsKey] extends Promise<infer Value> ? Promise<Value> : Promise<Items[ItemsKey]> };
73
+ type PromisesItems<Items extends unknown[]> = { [ItemsKey in keyof Items]: Items[ItemsKey] extends GenericCallback ? ReturnType<Items[ItemsKey]> extends Promise<infer Value> ? Promise<Value> : never : Items[ItemsKey] extends Promise<infer Value> ? Promise<Value> : Promise<Items[ItemsKey]>; };
75
74
  /**
76
75
  * Options for handling multiple _Promises_
77
76
  */
@@ -85,10 +84,10 @@ type PromisesOptions = {
85
84
  */
86
85
  strategy?: PromiseStrategy;
87
86
  };
88
- type PromisesResult<Items extends unknown[]> = { [ItemsKey in keyof Items]: Items[ItemsKey] extends Promise<infer Value> ? Result<Awaited<Value>> : never };
89
- type PromisesUnwrapped<Items extends unknown[]> = { [ItemsKey in keyof Items]: Items[ItemsKey] extends GenericCallback ? ReturnType<Items[ItemsKey]> extends Promise<infer Value> ? Awaited<Value> : never : Items[ItemsKey] extends Promise<infer Value> ? Awaited<Value> : never };
87
+ type PromisesResult<Items extends unknown[]> = { [ItemsKey in keyof Items]: Items[ItemsKey] extends Promise<infer Value> ? Result<Awaited<Value>> : never; };
88
+ type PromisesUnwrapped<Items extends unknown[]> = { [ItemsKey in keyof Items]: Items[ItemsKey] extends GenericCallback ? ReturnType<Items[ItemsKey]> extends Promise<infer Value> ? Awaited<Value> : never : Items[ItemsKey] extends Promise<infer Value> ? Awaited<Value> : never; };
90
89
  type PromisesValue<Value> = FulfilledPromise<Value> | RejectedPromise;
91
- type PromisesValues<Items extends unknown[]> = { [ItemsKey in keyof Items]: Items[ItemsKey] extends GenericCallback ? ReturnType<Items[ItemsKey]> extends Promise<infer Value> ? PromisesValue<Awaited<Value>> : never : Items[ItemsKey] extends Promise<infer Value> ? PromisesValue<Awaited<Value>> : never };
90
+ type PromisesValues<Items extends unknown[]> = { [ItemsKey in keyof Items]: Items[ItemsKey] extends GenericCallback ? ReturnType<Items[ItemsKey]> extends Promise<infer Value> ? PromisesValue<Awaited<Value>> : never : Items[ItemsKey] extends Promise<infer Value> ? PromisesValue<Awaited<Value>> : never; };
92
91
  /**
93
92
  * A _Promise_ that was rejected
94
93
  */
@@ -37,7 +37,7 @@ const PROMISE_MESSAGE_EXPECTATION_ATTEMPT = "Attempt expected a function or a pr
37
37
  const PROMISE_MESSAGE_EXPECTATION_RESULT = "toResult expected a Promise";
38
38
  const PROMISE_MESSAGE_EXPECTATION_TIMED = "Timed function expected a Promise";
39
39
  const PROMISE_MESSAGE_TIMEOUT = "Promise timed out";
40
- const PROMISE_STRATEGY_ALL = new Set(["complete", "first"]);
40
+ const PROMISE_STRATEGY_ALL = /* @__PURE__ */ new Set(["complete", "first"]);
41
41
  const PROMISE_STRATEGY_DEFAULT = "complete";
42
42
  const PROMISE_TYPE_FULFILLED = "fulfilled";
43
43
  const PROMISE_TYPE_REJECTED = "rejected";
@@ -1,6 +1,5 @@
1
1
  import { RequiredKeys } from "../models.mjs";
2
2
  import { PromiseOptions } from "./models.mjs";
3
-
4
3
  //#region src/promise/timed.d.ts
5
4
  declare function getTimedPromise<Value>(promise: Promise<Value>, time: number, signal?: AbortSignal): Promise<Value>;
6
5
  /**
package/dist/query.d.mts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { PlainObject } from "./models.mjs";
2
-
3
2
  //#region src/query.d.ts
4
3
  /**
5
4
  * Convert a query string to a plain _(nested)_ object
package/dist/query.mjs CHANGED
@@ -78,7 +78,7 @@ const EQUAL = "=";
78
78
  const EXPRESSION_ARRAY_SUFFIX = /\[\]$/;
79
79
  const EXPRESSION_BOOLEAN = /^(false|true)$/;
80
80
  const TRUE = "true";
81
- const TYPES = new Set([
81
+ const TYPES = /* @__PURE__ */ new Set([
82
82
  "boolean",
83
83
  "number",
84
84
  "string"
package/dist/queue.d.mts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { GenericAsyncCallback, GenericCallback } from "./models.mjs";
2
-
3
2
  //#region src/queue.d.ts
4
3
  /**
5
4
  * A queue that can be used to manage (a)synchronous tasks with a specific key
package/dist/random.d.mts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { getRandomFloatingNumber, getRandomInteger } from "./internal/random.mjs";
2
-
3
2
  //#region src/random.d.ts
4
3
  /**
5
4
  * Get a random boolean
@@ -1,5 +1,4 @@
1
1
  import { ExtendedResult, Result } from "./models.mjs";
2
-
3
2
  //#region src/result/index.d.ts
4
3
  /**
5
4
  * Executes a _Promise_, catching any errors, and returns a result
@@ -11,7 +11,8 @@ async function asyncAttempt(value, err) {
11
11
  }
12
12
  function attempt(callback, err) {
13
13
  try {
14
- return ok(callback());
14
+ const value = callback();
15
+ return ok(value);
15
16
  } catch (thrown) {
16
17
  return getError(err ?? thrown, err == null ? void 0 : thrown);
17
18
  }
@@ -1,5 +1,4 @@
1
1
  import { AnyResult, ResultMatch } from "./models.mjs";
2
-
3
2
  //#region src/result/match.d.ts
4
3
  /**
5
4
  * Handles a _Result_ with match callbacks
@@ -1,6 +1,5 @@
1
1
  import { AnyResult, Err, ExtendedErr, Ok, Result } from "./models.mjs";
2
2
  import { isError, isOk, isResult } from "../internal/result.mjs";
3
-
4
3
  //#region src/result/misc.d.ts
5
4
  /**
6
5
  * Creates an extended error result
@@ -1,5 +1,4 @@
1
1
  import { GenericCallback } from "../models.mjs";
2
-
3
2
  //#region src/result/models.d.ts
4
3
  /**
5
4
  * An unknown result
@@ -1,6 +1,5 @@
1
1
  import { GenericCallback } from "../../models.mjs";
2
2
  import { Result, UnwrapValue } from "../models.mjs";
3
-
4
3
  //#region src/result/work/flow.d.ts
5
4
  /**
6
5
  * A synchronous _Flow_, a function that attempts to pipe values through a series of functions
@@ -1,6 +1,5 @@
1
1
  import { GenericCallback } from "../../models.mjs";
2
2
  import { Result, UnwrapValue } from "../models.mjs";
3
-
4
3
  //#region src/result/work/pipe.d.ts
5
4
  type WrapValue<Value> = Result<UnwrapValue<Value>>;
6
5
  /**
@@ -1,5 +1,4 @@
1
1
  import { PlainObject } from "../models.mjs";
2
-
3
2
  //#region src/string/fuzzy.d.ts
4
3
  /**
5
4
  * Fuzzy searcher for an array of items
@@ -1,5 +1,4 @@
1
1
  import { getString, join, words } from "../internal/string.mjs";
2
-
3
2
  //#region src/string/index.d.ts
4
3
  /**
5
4
  * Dedent a string template, removing common leading whitespace from each line
@@ -32,23 +32,22 @@ function dedent(value, ...values) {
32
32
  */
33
33
  function getUuid(html) {
34
34
  const forHTML = html === true;
35
- let uuid;
36
35
  while (true) {
37
- const bytes = new Uint8Array(16);
36
+ const bytes = /* @__PURE__ */ new Uint8Array(16);
38
37
  crypto.getRandomValues(bytes);
39
38
  bytes[6] = bytes[6] & 15 | 64;
40
39
  bytes[8] = bytes[8] & 63 | 128;
41
40
  const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, ZERO)).join("");
42
- uuid = [
43
- hex.substring(0, 8),
41
+ const first = hex.substring(0, 8);
42
+ if (forHTML && NUMERICAL_PREFIX_PATTERN.test(first)) continue;
43
+ return [
44
+ first,
44
45
  hex.substring(8, 12),
45
46
  hex.substring(12, 16),
46
47
  hex.substring(16, 20),
47
48
  hex.substring(20, 32)
48
- ].join("-");
49
- if (!forHTML || !NUMERICAL_PREFIX_PATTERN.test(uuid)) break;
49
+ ].join(forHTML ? DELIMITER_UUID_HTML : DELIMITER_UUID_DEFAULT);
50
50
  }
51
- return uuid;
52
51
  }
53
52
  /**
54
53
  * Parse a JSON string into its proper value _(or `undefined` if it fails)_
@@ -90,6 +89,8 @@ function truncate(value, length, suffix) {
90
89
  const truncatedLength = length - actualSuffixLength;
91
90
  return `${value.slice(0, truncatedLength)}${actualSuffix}`;
92
91
  }
92
+ const DELIMITER_UUID_DEFAULT = "-";
93
+ const DELIMITER_UUID_HTML = "_";
93
94
  const NUMERICAL_PREFIX_PATTERN = /^\d/;
94
95
  const ZERO = "0";
95
96
  //#endregion
@@ -1,5 +1,4 @@
1
1
  import { PlainObject } from "../models.mjs";
2
-
3
2
  //#region src/string/template.d.ts
4
3
  /**
5
4
  * Renderer for a string template with variables
@@ -1,5 +1,4 @@
1
1
  import { Constructor, GenericCallback } from "../models.mjs";
2
-
3
2
  //#region src/value/clone.d.ts
4
3
  /**
5
4
  * Clone any kind of value _(shallowly)_
@@ -1,10 +1,9 @@
1
1
  import { PlainObject } from "../models.mjs";
2
-
3
2
  //#region src/value/freeze.d.ts
4
3
  /**
5
4
  * A frozen value with readonly properties _(going as deep as possible)_
6
5
  */
7
- type Frozen<Value> = Value extends unknown[] ? Readonly<Value> : Value extends PlainObject ? { readonly [Key in keyof Value]: Frozen<Value[Key]> } : Value extends Map<infer Key, infer Value> ? ReadonlyMap<Key, Frozen<Value>> : Value extends Set<infer Item> ? ReadonlySet<Frozen<Item>> : Readonly<Value>;
6
+ type Frozen<Value> = Value extends unknown[] ? Readonly<Value> : Value extends PlainObject ? { readonly [Key in keyof Value]: Frozen<Value[Key]>; } : Value extends Map<infer Key, infer Value> ? ReadonlyMap<Key, Frozen<Value>> : Value extends Set<infer Item> ? ReadonlySet<Frozen<Item>> : Readonly<Value>;
8
7
  /**
9
8
  * Freeze an array and its indiced values, but not any nested values
10
9
  *
@@ -1,5 +1,4 @@
1
1
  import { ArrayOrPlainObject, NestedPartial, PlainObject, UnionToIntersection } from "../models.mjs";
2
-
3
2
  //#region src/value/merge.d.ts
4
3
  /**
5
4
  * Options for assigning values
@@ -1,5 +1,4 @@
1
1
  import { PlainObject } from "../models.mjs";
2
-
3
2
  //#region src/value/omit.d.ts
4
3
  /**
5
4
  * Create a new object without the specified keys
@@ -1,5 +1,4 @@
1
1
  import { PlainObject } from "../models.mjs";
2
-
3
2
  //#region src/value/pick.d.ts
4
3
  /**
5
4
  * Create a new object with only the specified keys
@@ -1,10 +1,9 @@
1
1
  import { PlainObject } from "../models.mjs";
2
-
3
2
  //#region src/value/shake.d.ts
4
3
  /**
5
4
  * A shaken object, without any `undefined` values
6
5
  */
7
- type Shaken<Value extends PlainObject> = { [Key in keyof Value]: Value[Key] extends undefined ? never : Value[Key] };
6
+ type Shaken<Value extends PlainObject> = { [Key in keyof Value]: Value[Key] extends undefined ? never : Value[Key]; };
8
7
  /**
9
8
  * Shake an object, removing all keys with `undefined` values
10
9
  *
@@ -1,10 +1,9 @@
1
1
  import { NestedKeys, NestedValue, PlainObject, Simplify, ToString } from "../models.mjs";
2
-
3
2
  //#region src/value/smush.d.ts
4
3
  /**
5
4
  * A smushed object, with all nested objects flattened into a single level, using dot notation keys
6
5
  */
7
- type Smushed<Value extends PlainObject> = Simplify<{ [NestedKey in NestedKeys<Value>]: NestedValue<Value, ToString<NestedKey>> }>;
6
+ type Smushed<Value extends PlainObject> = Simplify<{ [NestedKey in NestedKeys<Value>]: NestedValue<Value, ToString<NestedKey>>; }>;
8
7
  /**
9
8
  * Smush an object into a flat object that uses dot notation keys
10
9
  *
@@ -1,5 +1,4 @@
1
1
  import { PlainObject } from "../models.mjs";
2
-
3
2
  //#region src/value/transform.d.ts
4
3
  /**
5
4
  * A callback transform an object's properties
@@ -8,7 +7,7 @@ type TransformCallback<Value extends PlainObject, Key extends keyof Value> = (ke
8
7
  /**
9
8
  * A collection of keyed callbacks to transform an object's properties
10
9
  */
11
- type TransformCallbacks<Value extends PlainObject> = Partial<{ [Key in keyof Value]: (value: Value[Key]) => Value[Key] }>;
10
+ type TransformCallbacks<Value extends PlainObject> = Partial<{ [Key in keyof Value]: (value: Value[Key]) => Value[Key]; }>;
12
11
  /**
13
12
  * A transformer function for an object, with predefined callbacks for transforming its properties
14
13
  */
@@ -1,5 +1,4 @@
1
1
  import { PlainObject, Simplify, UnionToIntersection } from "../models.mjs";
2
-
3
2
  //#region src/value/unsmush.d.ts
4
3
  /**
5
4
  * Thanks, type-fest!
@@ -8,7 +7,7 @@ type KeysOfUnion<ObjectType> = keyof UnionToIntersection<ObjectType extends unkn
8
7
  /**
9
8
  * An unsmushed object, with all dot notation keys turned into nested keys
10
9
  */
11
- type Unsmushed<Value extends PlainObject> = Simplify<Omit<{ [UnionKey in KeysOfUnion<Value>]: Value[UnionKey] }, `${string}.${string}`>>;
10
+ type Unsmushed<Value extends PlainObject> = Simplify<Omit<{ [UnionKey in KeysOfUnion<Value>]: Value[UnionKey]; }, `${string}.${string}`>>;
12
11
  /**
13
12
  * Unsmush a smushed object _(turning dot notation keys into nested keys)_
14
13
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oscarpalmer/atoms",
3
- "version": "0.188.0",
3
+ "version": "0.189.0",
4
4
  "description": "Atomic utilities for making your JavaScript better.",
5
5
  "keywords": [
6
6
  "helper",
@@ -257,11 +257,11 @@
257
257
  "watch": "npx vite build --watch"
258
258
  },
259
259
  "devDependencies": {
260
- "@oxlint/plugins": "^1.69",
261
- "@types/node": "^25.9",
260
+ "@oxlint/plugins": "^1.78",
261
+ "@types/node": "^26.2",
262
262
  "@vitest/coverage-istanbul": "^4.1",
263
- "eslint": "^10.4",
264
- "jsdom": "^29.1",
263
+ "eslint": "^10.8",
264
+ "jsdom": "^30",
265
265
  "tsdown": "^0.22",
266
266
  "typescript": "^6",
267
267
  "vite": "npm:@voidzero-dev/vite-plus-core@latest",