@oscarpalmer/atoms 0.194.0 → 0.195.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 (81) hide show
  1. package/dist/array/index.d.mts +2 -2
  2. package/dist/array/index.mjs +2 -2
  3. package/dist/array/move.mjs +1 -1
  4. package/dist/array/swap.mjs +1 -1
  5. package/dist/color/instance.mjs +1 -1
  6. package/dist/color/misc/state.d.mts +1 -1
  7. package/dist/color/models.d.mts +1 -1
  8. package/dist/color/space/hex.mjs +1 -1
  9. package/dist/color/space/rgb.mjs +1 -1
  10. package/dist/function/index.d.mts +1 -2
  11. package/dist/function/index.mjs +1 -2
  12. package/dist/function/once.mjs +1 -1
  13. package/dist/herald.d.mts +2 -71
  14. package/dist/herald.mjs +1 -109
  15. package/dist/index.d.mts +3270 -3271
  16. package/dist/index.mjs +1500 -1498
  17. package/dist/{array → internal/array}/get.d.mts +2 -2
  18. package/dist/{array → internal/array}/get.mjs +2 -2
  19. package/dist/{array → internal/array}/match.d.mts +2 -2
  20. package/dist/{array → internal/array}/match.mjs +2 -2
  21. package/dist/internal/defaults.d.mts +5 -0
  22. package/dist/internal/defaults.mjs +9 -0
  23. package/dist/{function → internal/function}/assert.d.mts +2 -2
  24. package/dist/{function → internal/function}/assert.mjs +2 -2
  25. package/dist/{function → internal/function}/memoize.d.mts +2 -2
  26. package/dist/{function → internal/function}/memoize.mjs +3 -3
  27. package/dist/{function → internal/function}/work.d.mts +2 -2
  28. package/dist/{function → internal/function}/work.mjs +2 -2
  29. package/dist/internal/herald.d.mts +71 -0
  30. package/dist/internal/herald.mjs +110 -0
  31. package/dist/internal/number.d.mts +1 -2
  32. package/dist/internal/number.mjs +1 -4
  33. package/dist/internal/{result.d.mts → result/misc.d.mts} +42 -3
  34. package/dist/internal/{result.mjs → result/misc.mjs} +29 -3
  35. package/dist/{result → internal/result}/models.d.mts +2 -2
  36. package/dist/{sized → internal/sized}/map.d.mts +1 -1
  37. package/dist/{sized → internal/sized}/map.mjs +2 -2
  38. package/dist/internal/{sized.d.mts → sized/misc.d.mts} +1 -1
  39. package/dist/internal/{sized.mjs → sized/misc.mjs} +2 -2
  40. package/dist/{string → internal/string}/case.d.mts +1 -1
  41. package/dist/{string → internal/string}/case.mjs +2 -2
  42. package/dist/internal/{string.d.mts → string/misc.d.mts} +1 -1
  43. package/dist/internal/{string.mjs → string/misc.mjs} +1 -1
  44. package/dist/internal/value/compare.mjs +1 -1
  45. package/dist/internal/value/has.d.mts +1 -1
  46. package/dist/internal/value/misc.d.mts +1 -1
  47. package/dist/internal/value/misc.mjs +2 -2
  48. package/dist/is.mjs +2 -2
  49. package/dist/logger.mjs +1 -1
  50. package/dist/promise/helpers.d.mts +1 -1
  51. package/dist/promise/helpers.mjs +2 -2
  52. package/dist/promise/index.d.mts +1 -1
  53. package/dist/promise/misc.d.mts +1 -1
  54. package/dist/promise/misc.mjs +2 -1
  55. package/dist/promise/models.d.mts +1 -1
  56. package/dist/query.mjs +1 -1
  57. package/dist/queue.mjs +1 -4
  58. package/dist/random.mjs +1 -1
  59. package/dist/result/index.d.mts +1 -1
  60. package/dist/result/index.mjs +1 -1
  61. package/dist/result/match.d.mts +1 -1
  62. package/dist/result/match.mjs +1 -1
  63. package/dist/result/misc.d.mts +3 -42
  64. package/dist/result/misc.mjs +2 -28
  65. package/dist/result/work/flow.d.mts +1 -1
  66. package/dist/result/work/flow.mjs +2 -2
  67. package/dist/result/work/pipe.d.mts +1 -1
  68. package/dist/result/work/pipe.mjs +2 -2
  69. package/dist/sized/set.mjs +1 -1
  70. package/dist/string/fuzzy.mjs +2 -2
  71. package/dist/string/index.d.mts +1 -1
  72. package/dist/string/index.mjs +1 -1
  73. package/dist/string/match.mjs +1 -1
  74. package/dist/string/normalize.mjs +2 -2
  75. package/dist/string/template.mjs +1 -1
  76. package/dist/subscription.d.mts +2 -0
  77. package/dist/subscription.mjs +2 -0
  78. package/dist/value/diff.mjs +1 -1
  79. package/dist/value/smush.mjs +1 -1
  80. package/package.json +23 -11
  81. /package/dist/{result → internal/result}/models.mjs +0 -0
@@ -1,5 +1,5 @@
1
- import { NumericalKeys, PlainObject } from "../models.mjs";
2
- //#region src/array/get.d.ts
1
+ import { NumericalKeys, PlainObject } from "../../models.mjs";
2
+ //#region src/internal/array/get.d.ts
3
3
  /**
4
4
  * Get an array from an object, where only values with numerical keys will be included
5
5
  *
@@ -1,5 +1,5 @@
1
- import { isNonPlainObject } from "../internal/is.mjs";
2
- //#region src/array/get.ts
1
+ import { isNonPlainObject } from "../is.mjs";
2
+ //#region src/internal/array/get.ts
3
3
  function getArray(value, indiced) {
4
4
  if (Array.isArray(value)) return value;
5
5
  if (value instanceof Map) return [...value.entries()];
@@ -1,5 +1,5 @@
1
- import { PlainObject } from "../models.mjs";
2
- //#region src/array/match.d.ts
1
+ import { PlainObject } from "../../models.mjs";
2
+ //#region src/internal/array/match.d.ts
3
3
  /**
4
4
  * Comparison of an array within another array
5
5
  */
@@ -1,5 +1,5 @@
1
- import { getArrayCallback } from "../internal/array/callbacks.mjs";
2
- //#region src/array/match.ts
1
+ import { getArrayCallback } from "./callbacks.mjs";
2
+ //#region src/internal/array/match.ts
3
3
  function endsWithArray(haystack, needle, key) {
4
4
  return endings.has(getPosition(haystack, needle, key)[1]);
5
5
  }
@@ -0,0 +1,5 @@
1
+ //#region src/internal/defaults.d.ts
2
+ declare function getBooleanOrDefault(value: unknown, defaultValue: boolean): boolean;
3
+ declare function getNumberOrDefault(value: unknown, defaultValue: number, minimum?: number): number;
4
+ //#endregion
5
+ export { getBooleanOrDefault, getNumberOrDefault };
@@ -0,0 +1,9 @@
1
+ //#region src/internal/defaults.ts
2
+ function getBooleanOrDefault(value, defaultValue) {
3
+ return typeof value === "boolean" ? value : defaultValue;
4
+ }
5
+ function getNumberOrDefault(value, defaultValue, minimum) {
6
+ return typeof value === "number" && !Number.isNaN(value) && value >= (minimum ?? 0) ? value : defaultValue;
7
+ }
8
+ //#endregion
9
+ export { getBooleanOrDefault, getNumberOrDefault };
@@ -1,5 +1,5 @@
1
- import { Constructor, NestedKeys, NestedValue, PlainObject } from "../models.mjs";
2
- //#region src/function/assert.d.ts
1
+ import { Constructor, NestedKeys, NestedValue, PlainObject } from "../../models.mjs";
2
+ //#region src/internal/function/assert.d.ts
3
3
  /**
4
4
  * Asserter for a property of a value
5
5
  */
@@ -1,5 +1,5 @@
1
- import { hasValueResult } from "../internal/value/has.mjs";
2
- //#region src/function/assert.ts
1
+ import { hasValueResult } from "../value/has.mjs";
2
+ //#region src/internal/function/assert.ts
3
3
  /**
4
4
  * Asserts that a condition is true, throwing an error if it is not
5
5
  *
@@ -1,5 +1,5 @@
1
- import { GenericCallback } from "../models.mjs";
2
- //#region src/function/memoize.d.ts
1
+ import { GenericCallback } from "../../models.mjs";
2
+ //#region src/internal/function/memoize.d.ts
3
3
  /**
4
4
  * A _Memoized_ function instance, caching and retrieving results based on the its parameters _(or a custom cache key)_
5
5
  */
@@ -1,7 +1,7 @@
1
- import { isPlainObject } from "../internal/is.mjs";
2
- import { getString, join } from "../internal/string.mjs";
1
+ import { isPlainObject } from "../is.mjs";
2
+ import { getString, join } from "../string/misc.mjs";
3
3
  import { SizedMap } from "../sized/map.mjs";
4
- //#region src/function/memoize.ts
4
+ //#region src/internal/function/memoize.ts
5
5
  function getMemoizationOptions(input) {
6
6
  const { cacheKey, cacheSize } = isPlainObject(input) ? input : {};
7
7
  return {
@@ -1,6 +1,6 @@
1
- import { GenericCallback } from "../models.mjs";
1
+ import { GenericCallback } from "../../models.mjs";
2
2
  import { UnwrapValue } from "../result/models.mjs";
3
- //#region src/function/work.d.ts
3
+ //#region src/internal/function/work.d.ts
4
4
  /**
5
5
  * A synchronous _Flow_, a function that pipe a value through a series of functions
6
6
  */
@@ -1,6 +1,6 @@
1
- import { isError, isOk } from "../internal/result.mjs";
1
+ import { isError, isOk } from "../result/misc.mjs";
2
2
  import { assert } from "./assert.mjs";
3
- //#region src/function/work.ts
3
+ //#region src/internal/function/work.ts
4
4
  function asyncFlow(...fns) {
5
5
  assertFlowFunctions(fns);
6
6
  return (...args) => asyncWork(args.map((value) => {
@@ -0,0 +1,71 @@
1
+ import { GenericCallback } from "../models.mjs";
2
+ import { Subscription, SubscriptionProperty } from "./subscription.mjs";
3
+ //#region src/internal/herald.d.ts
4
+ type Herald<Events extends Record<string, GenericCallback>> = {
5
+ readonly events: HeraldEvents<Events>;
6
+ /**
7
+ * Remove all event subscribers
8
+ */
9
+ clear(): void;
10
+ /**
11
+ * Emit an event with parameters
12
+ *
13
+ * @param event Event name
14
+ * @param parameters Event parameters
15
+ */
16
+ emit<Event extends keyof Events>(event: Event, ...parameters: Parameters<Events[Event]>): void;
17
+ /**
18
+ * Is the event observed by any subscribers?
19
+ *
20
+ * @param event Event name
21
+ * @returns `true` if the event is observed, otherwise `false`
22
+ */
23
+ observed<Event extends keyof Events>(event: Event): boolean;
24
+ /**
25
+ * Subscribe to an event with a callback
26
+ *
27
+ * @param event Event name
28
+ * @param callback Callback function
29
+ * @param signal Optional abort signal to cancel the subscription
30
+ * @returns Subscription instance
31
+ */
32
+ subscribe<Event extends keyof Events>(event: Event, callback: Events[Event], signal?: AbortSignal): Subscription;
33
+ };
34
+ type HeraldEvents<Events extends Record<string, GenericCallback>> = { [Key in keyof Events]: Key extends '*' ? never : (callback: Events[Key], signal?: AbortSignal) => void; };
35
+ type HeraldOnCreate<Events extends Record<string, GenericCallback>> = <Event extends keyof Events>(event: Event, callback: Events[Event], subscription: Subscription) => void;
36
+ type HeraldOptions<Events extends Record<string, GenericCallback>> = {
37
+ names: Array<keyof Events>;
38
+ property?: SubscriptionProperty;
39
+ onCreate?: HeraldOnCreate<Events>;
40
+ };
41
+ /**
42
+ * Create a _Herald_ for announcing named events
43
+ *
44
+ * @param names Event names
45
+ * @param property Optional property for subscription identification _(defaults to `$herald`)_
46
+ * @returns _Herald_ instance
47
+ */
48
+ declare function herald<Events extends Record<string, GenericCallback>>(options: HeraldOptions<Events>): Herald<Events>;
49
+ /**
50
+ * Is the value a herald?
51
+ *
52
+ * @param value Value to check
53
+ * @returns `true` if the value is a herald, otherwise `false`
54
+ */
55
+ declare function isHerald<Events extends Record<string, GenericCallback> = Record<string, GenericCallback>>(value: unknown): value is Herald<Events>;
56
+ /**
57
+ * Is the value events for a herald?
58
+ *
59
+ * @param value Value to check
60
+ * @returns `true` if the value is events for a herald, otherwise `false`
61
+ */
62
+ declare function isHeraldEvents<Events extends Record<string, GenericCallback> = Record<string, GenericCallback>>(value: unknown): value is HeraldEvents<Events>;
63
+ /**
64
+ * Is the value a herald subscription?
65
+ *
66
+ * @param value Value to check
67
+ * @returns `true` if the value is a herald subscription, otherwise `false`
68
+ */
69
+ declare function isHeraldSubscription(value: unknown): value is Subscription;
70
+ //#endregion
71
+ export { Herald, HeraldEvents, HeraldOptions, herald, isHerald, isHeraldEvents, isHeraldSubscription };
@@ -0,0 +1,110 @@
1
+ import { isPlainObject } from "./is.mjs";
2
+ import { createSubscriptions, isSubscription } from "./subscription.mjs";
3
+ //#region src/internal/herald.ts
4
+ function createEvents(herald, state) {
5
+ const events = {};
6
+ Object.defineProperty(events, HERALD_PROPERTY, { value: HERALD_NAME_EVENTS });
7
+ for (const key of state.keys) events[key] = (callback, signal) => herald.subscribe(key, callback, signal);
8
+ return Object.freeze(events);
9
+ }
10
+ function emitForHerald(state, event, ...parameters) {
11
+ const items = state.subscriptions.state.values.from.keyed?.get(event);
12
+ if (items == null || items.size === 0) return;
13
+ for (const [callback] of items) callback(...parameters);
14
+ }
15
+ function getHeraldSubscriptionProperty(input) {
16
+ if (input == null) return heraldSubscription;
17
+ const property = isPlainObject(input) ? input : {};
18
+ if (typeof property.key !== "string" || property.value != null && typeof property.value !== "string") throw new Error(HERALD_MESSAGE_PROPERTY);
19
+ return {
20
+ key: property.key,
21
+ value: property.value
22
+ };
23
+ }
24
+ function getHeraldState(input) {
25
+ const options = isPlainObject(input) ? input : {};
26
+ if (!Array.isArray(options.names) || options.names.length === 0 || !options.names.every((name) => typeof name === "string")) throw new Error(HERALD_MESSAGE_ARRAY);
27
+ if (options.onCreate != null && typeof options.onCreate !== "function") throw new Error(HERALD_MESSAGE_ONCREATE);
28
+ const keys = new Set(options.names);
29
+ const property = getHeraldSubscriptionProperty(options.property);
30
+ return {
31
+ keys,
32
+ subscriptions: createSubscriptions({
33
+ keys,
34
+ property
35
+ }),
36
+ onCreate: options.onCreate
37
+ };
38
+ }
39
+ /**
40
+ * Create a _Herald_ for announcing named events
41
+ *
42
+ * @param names Event names
43
+ * @param property Optional property for subscription identification _(defaults to `$herald`)_
44
+ * @returns _Herald_ instance
45
+ */
46
+ function herald(options) {
47
+ const state = getHeraldState(options);
48
+ const instance = {
49
+ clear: () => state.subscriptions.clear(),
50
+ emit: (event, ...parameters) => emitForHerald(state, event, ...parameters),
51
+ observed: (event) => (state.subscriptions.state.items.keyed?.get(event)?.size ?? 0) > 0,
52
+ subscribe: (key, callback, signal) => subscribeToHerald(state, key, callback, signal)
53
+ };
54
+ Object.defineProperties(instance, {
55
+ [HERALD_PROPERTY]: { value: HERALD_NAME_HERALD },
56
+ events: {
57
+ enumerable: true,
58
+ value: createEvents(instance, state)
59
+ }
60
+ });
61
+ return Object.freeze(instance);
62
+ }
63
+ /**
64
+ * Is the value a herald?
65
+ *
66
+ * @param value Value to check
67
+ * @returns `true` if the value is a herald, otherwise `false`
68
+ */
69
+ function isHerald(value) {
70
+ return isHeraldInstance(HERALD_NAME_HERALD, value);
71
+ }
72
+ /**
73
+ * Is the value events for a herald?
74
+ *
75
+ * @param value Value to check
76
+ * @returns `true` if the value is events for a herald, otherwise `false`
77
+ */
78
+ function isHeraldEvents(value) {
79
+ return isHeraldInstance(HERALD_NAME_EVENTS, value);
80
+ }
81
+ function isHeraldInstance(name, value) {
82
+ return isPlainObject(value) && HERALD_PROPERTY in value && value[HERALD_PROPERTY] === name;
83
+ }
84
+ /**
85
+ * Is the value a herald subscription?
86
+ *
87
+ * @param value Value to check
88
+ * @returns `true` if the value is a herald subscription, otherwise `false`
89
+ */
90
+ function isHeraldSubscription(value) {
91
+ return isSubscription(value) && value[HERALD_PROPERTY] === "subscription";
92
+ }
93
+ function subscribeToHerald(state, key, callback, signal) {
94
+ const [subscription, existing] = state.subscriptions.create({
95
+ key,
96
+ signal,
97
+ value: callback
98
+ });
99
+ if (!existing) state.onCreate?.(key, callback, subscription);
100
+ return subscription;
101
+ }
102
+ const HERALD_PROPERTY = "$herald";
103
+ const HERALD_MESSAGE_ARRAY = "Herald requires an array of event names.";
104
+ const HERALD_MESSAGE_ONCREATE = `Herald requires a valid onCreate callback for subscription creation`;
105
+ const HERALD_MESSAGE_PROPERTY = `Herald requires valid property information for subscription identification`;
106
+ const HERALD_NAME_EVENTS = "events";
107
+ const HERALD_NAME_HERALD = "herald";
108
+ const heraldSubscription = { key: HERALD_PROPERTY };
109
+ //#endregion
110
+ export { herald, isHerald, isHeraldEvents, isHeraldSubscription };
@@ -33,6 +33,5 @@ declare function clamp(value: number, minimum: number, maximum: number, loop?: b
33
33
  * @returns Original value as a number, or `Number.NaN` if the value is unable to be parsed
34
34
  */
35
35
  declare function getNumber(value: unknown): number;
36
- declare function getNumberOrDefault(value: unknown, defaultValue: number, minimum?: number): number;
37
36
  //#endregion
38
- export { between, clamp, getNumber, getNumberOrDefault };
37
+ export { between, clamp, getNumber };
@@ -64,12 +64,9 @@ function getNumber(value) {
64
64
  if (isBinary || NUMBER_EXPRESSION_OCTAL.test(trimmed)) return Number.parseInt(trimmed.slice(2), isBinary ? 2 : NUMBER_OCTAL_VALUE);
65
65
  return Number(trimmed);
66
66
  }
67
- function getNumberOrDefault(value, defaultValue, minimum) {
68
- return typeof value === "number" && !Number.isNaN(value) && value >= (minimum ?? 0) ? Math.floor(value) : defaultValue;
69
- }
70
67
  const NUMBER_EXPRESSION_BINARY = /^0b[01]+$/i;
71
68
  const NUMBER_EXPRESSION_OCTAL = /^0o[0-7]+$/i;
72
69
  const NUMBER_EXPRESSION_ZEROISH = /^\s*0+\s*$/;
73
70
  const NUMBER_OCTAL_VALUE = 8;
74
71
  //#endregion
75
- export { between, clamp, getNumber, getNumberOrDefault };
72
+ export { between, clamp, getNumber };
@@ -1,5 +1,21 @@
1
- import { Err, ExtendedErr, Ok, Result } from "../result/models.mjs";
2
- //#region src/internal/result.d.ts
1
+ import { Err, ExtendedErr, Ok, Result } from "./models.mjs";
2
+ //#region src/internal/result/misc.d.ts
3
+ /**
4
+ * Creates an extended error result
5
+ *
6
+ * @param value Error value
7
+ * @param original Original error
8
+ * @returns Error result
9
+ */
10
+ declare function error<E>(value: E, original: Error): ExtendedErr<E>;
11
+ /**
12
+ * Creates an error result
13
+ *
14
+ * @param value Error value
15
+ * @returns Error result
16
+ */
17
+ declare function error<E>(value: E): Err<E>;
18
+ declare function getError<E>(value: E, original?: Error): Err<E> | ExtendedErr<E>;
3
19
  /**
4
20
  * Is the _Result_ an extended error?
5
21
  *
@@ -42,5 +58,28 @@ declare function isOk(value: unknown): value is Ok<unknown>;
42
58
  * @returns `true` if the value is a _Result_, otherwise `false`
43
59
  */
44
60
  declare function isResult(value: unknown): value is ExtendedErr<unknown> | Result<unknown, unknown>;
61
+ /**
62
+ * Creates an ok result
63
+ *
64
+ * @param value Value
65
+ * @returns Ok result
66
+ */
67
+ declare function ok<Value>(value: Value): Ok<Value>;
68
+ /**
69
+ * Gets the value of an ok result _(or a default value)_
70
+ *
71
+ * @param value _Result_ to unwrap
72
+ * @param defaultValue Default value
73
+ * @returns Value of the _Result_ _(or the default value)_
74
+ */
75
+ declare function unwrap<Value, E = Error>(value: Result<Value, E>, defaultValue: Value): Value;
76
+ /**
77
+ * Gets the value of an ok result _(or a default value)_
78
+ *
79
+ * @param value _Result_ to unwrap
80
+ * @param defaultValue Default value
81
+ * @returns Value of the _Result_ _(or the default value)_
82
+ */
83
+ declare function unwrap(value: unknown, defaultValue: unknown): unknown;
45
84
  //#endregion
46
- export { isError, isOk, isResult };
85
+ export { error, getError, isError, isOk, isResult, ok, unwrap };
@@ -1,5 +1,16 @@
1
- import { isNonPlainObject } from "./is.mjs";
2
- //#region src/internal/result.ts
1
+ import { isNonPlainObject } from "../is.mjs";
2
+ //#region src/internal/result/misc.ts
3
+ function error(value, original) {
4
+ return getError(value, original);
5
+ }
6
+ function getError(value, original) {
7
+ const errorResult = {
8
+ error: value,
9
+ ok: false
10
+ };
11
+ if (original instanceof Error) errorResult.original = original;
12
+ return errorResult;
13
+ }
3
14
  function isError(value, extended) {
4
15
  return isResultValue(value, false) && (extended === true ? value.original instanceof Error : true);
5
16
  }
@@ -19,7 +30,22 @@ function isResultValue(value, okValue) {
19
30
  if (isNonPlainObject(value)) return false;
20
31
  return value.ok === okValue && (okValue ? RESULT_PROPERTY_VALUE : RESULT_PROPERTY_ERROR) in value;
21
32
  }
33
+ /**
34
+ * Creates an ok result
35
+ *
36
+ * @param value Value
37
+ * @returns Ok result
38
+ */
39
+ function ok(value) {
40
+ return {
41
+ ok: true,
42
+ value
43
+ };
44
+ }
45
+ function unwrap(value, defaultValue) {
46
+ return isOk(value) ? value.value : defaultValue;
47
+ }
22
48
  const RESULT_PROPERTY_ERROR = "error";
23
49
  const RESULT_PROPERTY_VALUE = "value";
24
50
  //#endregion
25
- export { isError, isOk, isResult };
51
+ export { error, getError, isError, isOk, isResult, ok, unwrap };
@@ -1,5 +1,5 @@
1
- import { GenericCallback } from "../models.mjs";
2
- //#region src/result/models.d.ts
1
+ import { GenericCallback } from "../../models.mjs";
2
+ //#region src/internal/result/models.d.ts
3
3
  /**
4
4
  * An unknown result
5
5
  */
@@ -1,4 +1,4 @@
1
- //#region src/sized/map.d.ts
1
+ //#region src/internal/sized/map.d.ts
2
2
  /**
3
3
  * A _Map_ with a maximum size
4
4
  *
@@ -1,5 +1,5 @@
1
- import { getSizedMaximum } from "../internal/sized.mjs";
2
- //#region src/sized/map.ts
1
+ import { getSizedMaximum } from "./misc.mjs";
2
+ //#region src/internal/sized/map.ts
3
3
  /**
4
4
  * A _Map_ with a maximum size
5
5
  *
@@ -1,4 +1,4 @@
1
- //#region src/internal/sized.d.ts
1
+ //#region src/internal/sized/misc.d.ts
2
2
  declare function getSizedMaximum(first?: unknown, second?: unknown): number;
3
3
  //#endregion
4
4
  export { getSizedMaximum };
@@ -1,5 +1,5 @@
1
- import { clamp } from "./number.mjs";
2
- //#region src/internal/sized.ts
1
+ import { clamp } from "../number.mjs";
2
+ //#region src/internal/sized/misc.ts
3
3
  function getSizedMaximum(first, second) {
4
4
  let actual;
5
5
  if (typeof first === "number") actual = first;
@@ -1,4 +1,4 @@
1
- //#region src/string/case.d.ts
1
+ //#region src/internal/string/case.d.ts
2
2
  /**
3
3
  * Convert a string to camel case _(thisIsCamelCase)_
4
4
  *
@@ -1,6 +1,6 @@
1
- import { join, words } from "../internal/string.mjs";
1
+ import { join, words } from "./misc.mjs";
2
2
  import { memoize } from "../function/memoize.mjs";
3
- //#region src/string/case.ts
3
+ //#region src/internal/string/case.ts
4
4
  /**
5
5
  * Convert a string to camel case _(thisIsCamelCase)_
6
6
  *
@@ -1,4 +1,4 @@
1
- //#region src/internal/string.d.ts
1
+ //#region src/internal/string/misc.d.ts
2
2
  /**
3
3
  * Get the string value from any value
4
4
  *
@@ -1,4 +1,4 @@
1
- //#region src/internal/string.ts
1
+ //#region src/internal/string/misc.ts
2
2
  /**
3
3
  * Get the string value from any value
4
4
  *
@@ -1,5 +1,5 @@
1
1
  import { max } from "../math/aggregate.mjs";
2
- import { getString, words } from "../string.mjs";
2
+ import { getString, words } from "../string/misc.mjs";
3
3
  import { getCompareHandlers } from "./handlers.mjs";
4
4
  //#region src/internal/value/compare.ts
5
5
  const COMPARE_NAME = "compare";
@@ -1,5 +1,5 @@
1
1
  import { NestedKeys, NestedValue, PlainObject, ToString } from "../../models.mjs";
2
- import { Result } from "../../result/models.mjs";
2
+ import { Result } from "../result/models.mjs";
3
3
  //#region src/internal/value/has.d.ts
4
4
  /**
5
5
  * Check if a property is defined in an object
@@ -1,4 +1,4 @@
1
- import { Result } from "../../result/models.mjs";
1
+ import { Result } from "../result/models.mjs";
2
2
  //#region src/internal/value/misc.d.ts
3
3
  declare function findKey(needle: string, haystack: object): string;
4
4
  declare function getNestedValue(data: object, path: string, ignoreCase: boolean): Result<unknown, string>;
@@ -1,5 +1,5 @@
1
- import { ignoreKey } from "../string.mjs";
2
- import { error, ok } from "../../result/misc.mjs";
1
+ import { ignoreKey } from "../string/misc.mjs";
2
+ import { error, ok } from "../result/misc.mjs";
3
3
  //#region src/internal/value/misc.ts
4
4
  function findKey(needle, haystack) {
5
5
  const keys = Object.keys(haystack);
package/dist/is.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { isArrayOrPlainObject, isConstructor, isInstanceOf, isKey, isNonArrayOrPlainObject, isNonConstructor, isNonInstanceOf, isNonKey, isNonNumber, isNonPlainObject, isNonPrimitive, isNonTypedArray, isNumber, isPlainObject, isPrimitive, isTypedArray } from "./internal/is.mjs";
2
- import { getArray } from "./array/get.mjs";
3
- import { getString } from "./internal/string.mjs";
2
+ import { getArray } from "./internal/array/get.mjs";
3
+ import { getString } from "./internal/string/misc.mjs";
4
4
  //#region src/is.ts
5
5
  /**
6
6
  * Is the value empty, or only containing `null` or `undefined` values?
package/dist/logger.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { noop } from "./internal/function/misc.mjs";
2
- import { getString } from "./internal/string.mjs";
2
+ import { getString } from "./internal/string/misc.mjs";
3
3
  //#region src/logger.ts
4
4
  function isLogger(value) {
5
5
  return isLoggerInstance(LOGGER_NAME, value);
@@ -1,5 +1,5 @@
1
1
  import { RequiredKeys } from "../models.mjs";
2
- import { Result } from "../result/models.mjs";
2
+ import { Result } from "../internal/result/models.mjs";
3
3
  import { FulfilledPromise, PromiseOptions, PromiseStrategy, PromisesOptions, PromisesValue, RejectedPromise } from "./models.mjs";
4
4
  //#region src/promise/helpers.d.ts
5
5
  declare function getPromiseOptions(input: unknown): RequiredKeys<PromiseOptions, 'time'>;
@@ -1,5 +1,5 @@
1
- import { error, ok } from "../result/misc.mjs";
2
- import { getNumberOrDefault } from "../internal/number.mjs";
1
+ import { error, ok } from "../internal/result/misc.mjs";
2
+ import { getNumberOrDefault } from "../internal/defaults.mjs";
3
3
  import { PROMISE_STRATEGY_ALL, PROMISE_STRATEGY_DEFAULT, PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED } from "./constants.mjs";
4
4
  //#region src/promise/helpers.ts
5
5
  function getPromiseOptions(input) {
@@ -1,4 +1,4 @@
1
- import { Result } from "../result/models.mjs";
1
+ import { Result } from "../internal/result/models.mjs";
2
2
  import { PromiseOptions, PromisesItems, PromisesOptions, PromisesResult, PromisesUnwrapped, PromisesValue, PromisesValues } from "./models.mjs";
3
3
  //#region src/promise/index.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { Result } from "../result/models.mjs";
1
+ import { Result } from "../internal/result/models.mjs";
2
2
  import { Aborter } from "../internal/abort.mjs";
3
3
  import { CancelablePromise, PromiseParameters } from "./models.mjs";
4
4
  import { toPromise } from "../result/misc.mjs";
@@ -1,7 +1,8 @@
1
- import { error, ok, toPromise } from "../result/misc.mjs";
1
+ import { error, ok } from "../internal/result/misc.mjs";
2
2
  import { PROMISE_MESSAGE_EXPECTATION_RESULT } from "./constants.mjs";
3
3
  import { CancelablePromise } from "./models.mjs";
4
4
  import { isFulfilled, isRejected } from "./helpers.mjs";
5
+ import { toPromise } from "../result/misc.mjs";
5
6
  //#region src/promise/misc.ts
6
7
  /**
7
8
  * Create a cancelable _Promise_
@@ -1,5 +1,5 @@
1
1
  import { GenericCallback } from "../models.mjs";
2
- import { Result } from "../result/models.mjs";
2
+ import { Result } from "../internal/result/models.mjs";
3
3
  import { Aborter } from "../internal/abort.mjs";
4
4
  import { PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED } from "./constants.mjs";
5
5
  //#region src/promise/models.d.ts
package/dist/query.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { isPlainObject } from "./internal/is.mjs";
2
- import { getString, ignoreKey, join, tryDecode, tryEncode } from "./internal/string.mjs";
2
+ import { getString, ignoreKey, join, tryDecode, tryEncode } from "./internal/string/misc.mjs";
3
3
  import { getNumber } from "./internal/number.mjs";
4
4
  import { setValue } from "./internal/value/set.mjs";
5
5
  //#region src/query.ts
package/dist/queue.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createAborter } from "./internal/abort.mjs";
2
- import { getNumberOrDefault } from "./internal/number.mjs";
2
+ import { getBooleanOrDefault, getNumberOrDefault } from "./internal/defaults.mjs";
3
3
  //#region src/queue.ts
4
4
  /**
5
5
  * An error thrown by the Queue when an operation fails
@@ -104,9 +104,6 @@ function createQueue(callback, options, key) {
104
104
  });
105
105
  return Object.freeze(instance);
106
106
  }
107
- function getBooleanOrDefault(value, defaultValue) {
108
- return typeof value === "boolean" ? value : defaultValue;
109
- }
110
107
  function getOptions(input) {
111
108
  const options = typeof input === "object" && input != null ? input : {};
112
109
  return {
package/dist/random.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { getRandomFloatingNumber, getRandomInteger } from "./internal/random.mjs";
2
2
  import { shuffle } from "./internal/array/shuffle.mjs";
3
- import { join } from "./internal/string.mjs";
3
+ import { join } from "./internal/string/misc.mjs";
4
4
  //#region src/random.ts
5
5
  /**
6
6
  * Get a random boolean
@@ -1,4 +1,4 @@
1
- import { ExtendedResult, Result } from "./models.mjs";
1
+ import { ExtendedResult, Result } from "../internal/result/models.mjs";
2
2
  //#region src/result/index.d.ts
3
3
  /**
4
4
  * Executes a _Promise_, catching any errors, and returns a result