@oscarpalmer/atoms 0.194.0 → 0.195.1

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 (86) 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/limit.d.mts +6 -0
  13. package/dist/function/limit.mjs +2 -0
  14. package/dist/function/once.d.mts +3 -0
  15. package/dist/function/once.mjs +2 -1
  16. package/dist/function/retry.d.mts +24 -1
  17. package/dist/function/retry.mjs +1 -0
  18. package/dist/herald.d.mts +2 -71
  19. package/dist/herald.mjs +1 -109
  20. package/dist/index.d.mts +3325 -3282
  21. package/dist/index.mjs +1508 -1498
  22. package/dist/{array → internal/array}/get.d.mts +2 -2
  23. package/dist/{array → internal/array}/get.mjs +2 -2
  24. package/dist/{array → internal/array}/match.d.mts +2 -2
  25. package/dist/{array → internal/array}/match.mjs +2 -2
  26. package/dist/internal/defaults.d.mts +5 -0
  27. package/dist/internal/defaults.mjs +9 -0
  28. package/dist/{function → internal/function}/assert.d.mts +2 -2
  29. package/dist/{function → internal/function}/assert.mjs +2 -2
  30. package/dist/{function → internal/function}/memoize.d.mts +2 -2
  31. package/dist/{function → internal/function}/memoize.mjs +3 -3
  32. package/dist/{function → internal/function}/work.d.mts +2 -2
  33. package/dist/{function → internal/function}/work.mjs +2 -2
  34. package/dist/internal/herald.d.mts +71 -0
  35. package/dist/internal/herald.mjs +110 -0
  36. package/dist/internal/number.d.mts +1 -2
  37. package/dist/internal/number.mjs +1 -4
  38. package/dist/internal/{result.d.mts → result/misc.d.mts} +42 -3
  39. package/dist/internal/{result.mjs → result/misc.mjs} +29 -3
  40. package/dist/{result → internal/result}/models.d.mts +2 -2
  41. package/dist/{sized → internal/sized}/map.d.mts +1 -1
  42. package/dist/{sized → internal/sized}/map.mjs +2 -2
  43. package/dist/internal/{sized.d.mts → sized/misc.d.mts} +1 -1
  44. package/dist/internal/{sized.mjs → sized/misc.mjs} +2 -2
  45. package/dist/{string → internal/string}/case.d.mts +1 -1
  46. package/dist/{string → internal/string}/case.mjs +2 -2
  47. package/dist/internal/{string.d.mts → string/misc.d.mts} +1 -1
  48. package/dist/internal/{string.mjs → string/misc.mjs} +1 -1
  49. package/dist/internal/value/compare.mjs +1 -1
  50. package/dist/internal/value/has.d.mts +1 -1
  51. package/dist/internal/value/misc.d.mts +1 -1
  52. package/dist/internal/value/misc.mjs +2 -2
  53. package/dist/is.mjs +2 -2
  54. package/dist/logger.mjs +1 -1
  55. package/dist/promise/helpers.d.mts +1 -1
  56. package/dist/promise/helpers.mjs +2 -2
  57. package/dist/promise/index.d.mts +1 -1
  58. package/dist/promise/misc.d.mts +1 -1
  59. package/dist/promise/misc.mjs +2 -1
  60. package/dist/promise/models.d.mts +1 -1
  61. package/dist/query.mjs +1 -1
  62. package/dist/queue.mjs +1 -4
  63. package/dist/random.mjs +1 -1
  64. package/dist/result/index.d.mts +4 -1
  65. package/dist/result/index.mjs +2 -1
  66. package/dist/result/match.d.mts +4 -1
  67. package/dist/result/match.mjs +2 -1
  68. package/dist/result/misc.d.mts +3 -42
  69. package/dist/result/misc.mjs +2 -28
  70. package/dist/result/work/flow.d.mts +4 -1
  71. package/dist/result/work/flow.mjs +3 -2
  72. package/dist/result/work/pipe.d.mts +4 -1
  73. package/dist/result/work/pipe.mjs +3 -2
  74. package/dist/sized/set.mjs +1 -1
  75. package/dist/string/fuzzy.mjs +2 -2
  76. package/dist/string/index.d.mts +1 -1
  77. package/dist/string/index.mjs +1 -1
  78. package/dist/string/match.mjs +1 -1
  79. package/dist/string/normalize.mjs +2 -2
  80. package/dist/string/template.mjs +1 -1
  81. package/dist/subscription.d.mts +2 -0
  82. package/dist/subscription.mjs +2 -0
  83. package/dist/value/diff.mjs +1 -1
  84. package/dist/value/smush.mjs +1 -1
  85. package/package.json +23 -11
  86. /package/dist/{result → internal/result}/models.mjs +0 -0
@@ -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
@@ -53,5 +53,8 @@ declare function attempt<Value, E>(callback: () => Value, error: E): ExtendedRes
53
53
  * @returns Callback result
54
54
  */
55
55
  declare function attempt<Value>(callback: () => Value): Result<Value, Error>;
56
+ declare namespace attempt {
57
+ var async: typeof asyncAttempt;
58
+ }
56
59
  //#endregion
57
60
  export { asyncAttempt, attempt };
@@ -1,4 +1,4 @@
1
- import { getError, ok } from "./misc.mjs";
1
+ import { getError, ok } from "../internal/result/misc.mjs";
2
2
  //#region src/result/index.ts
3
3
  async function asyncAttempt(value, err) {
4
4
  try {
@@ -17,6 +17,7 @@ function attempt(callback, err) {
17
17
  return getError(err ?? thrown, err == null ? void 0 : thrown);
18
18
  }
19
19
  }
20
+ attempt.async = asyncAttempt;
20
21
  Object.defineProperty(attempt, "async", { value: asyncAttempt });
21
22
  //#endregion
22
23
  export { asyncAttempt, attempt };
@@ -1,4 +1,4 @@
1
- import { AnyResult, ResultMatch } from "./models.mjs";
1
+ import { AnyResult, ResultMatch } from "../internal/result/models.mjs";
2
2
  //#region src/result/match.d.ts
3
3
  /**
4
4
  * Handles a _Result_ with match callbacks
@@ -38,5 +38,8 @@ declare function matchResult<Value, Returned, E = Error>(result: AnyResult<Value
38
38
  * @returns Matched value
39
39
  */
40
40
  declare function matchResult<Value, Returned, E = Error>(result: AnyResult<Value, E> | (() => AnyResult<Value, E>), ok: ResultMatch<Value, Returned, E>['ok'], error: ResultMatch<Value, Returned, E>['error']): Returned;
41
+ declare namespace matchResult {
42
+ var async: typeof asyncMatchResult;
43
+ }
41
44
  //#endregion
42
45
  export { asyncMatchResult, matchResult };
@@ -1,4 +1,4 @@
1
- import { isOk, isResult } from "../internal/result.mjs";
1
+ import { isOk, isResult } from "../internal/result/misc.mjs";
2
2
  //#region src/result/match.ts
3
3
  async function asyncMatchResult(result, first, error) {
4
4
  let value;
@@ -22,6 +22,7 @@ function matchResult(result, first, error) {
22
22
  return errorHandler(value.error, value.original);
23
23
  }
24
24
  const MATCH_MESSAGE = "`result.match` expected a Result or a function that returns a Result";
25
+ matchResult.async = asyncMatchResult;
25
26
  Object.defineProperty(matchResult, "async", { value: asyncMatchResult });
26
27
  //#endregion
27
28
  export { asyncMatchResult, matchResult };
@@ -1,29 +1,6 @@
1
- import { AnyResult, Err, ExtendedErr, Ok, Result } from "./models.mjs";
2
- import { isError, isOk, isResult } from "../internal/result.mjs";
1
+ import { AnyResult } from "../internal/result/models.mjs";
2
+ import { error, isError, isOk, isResult, ok, unwrap } from "../internal/result/misc.mjs";
3
3
  //#region src/result/misc.d.ts
4
- /**
5
- * Creates an extended error result
6
- *
7
- * @param value Error value
8
- * @param original Original error
9
- * @returns Error result
10
- */
11
- declare function error<E>(value: E, original: Error): ExtendedErr<E>;
12
- /**
13
- * Creates an error result
14
- *
15
- * @param value Error value
16
- * @returns Error result
17
- */
18
- declare function error<E>(value: E): Err<E>;
19
- declare function getError<E>(value: E, original?: Error): Err<E> | ExtendedErr<E>;
20
- /**
21
- * Creates an ok result
22
- *
23
- * @param value Value
24
- * @returns Ok result
25
- */
26
- declare function ok<Value>(value: Value): Ok<Value>;
27
4
  /**
28
5
  * Converts a result to a _Promise_
29
6
  *
@@ -42,21 +19,5 @@ declare function toPromise<Value, E = Error>(callback: () => AnyResult<Value, E>
42
19
  * @returns Promised result
43
20
  */
44
21
  declare function toPromise<Value, E = Error>(result: AnyResult<Value, E>): Promise<Value>;
45
- /**
46
- * Gets the value of an ok result _(or a default value)_
47
- *
48
- * @param value _Result_ to unwrap
49
- * @param defaultValue Default value
50
- * @returns Value of the _Result_ _(or the default value)_
51
- */
52
- declare function unwrap<Value, E = Error>(value: Result<Value, E>, defaultValue: Value): Value;
53
- /**
54
- * Gets the value of an ok result _(or a default value)_
55
- *
56
- * @param value _Result_ to unwrap
57
- * @param defaultValue Default value
58
- * @returns Value of the _Result_ _(or the default value)_
59
- */
60
- declare function unwrap(value: unknown, defaultValue: unknown): unknown;
61
22
  //#endregion
62
- export { error, getError, isError, isOk, isResult, ok, toPromise, unwrap };
23
+ export { error, isError, isOk, isResult, ok, toPromise, unwrap };
@@ -1,28 +1,5 @@
1
- import { isError, isOk, isResult } from "../internal/result.mjs";
1
+ import { error, isError, isOk, isResult, ok, unwrap } from "../internal/result/misc.mjs";
2
2
  //#region src/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
- }
14
- /**
15
- * Creates an ok result
16
- *
17
- * @param value Value
18
- * @returns Ok result
19
- */
20
- function ok(value) {
21
- return {
22
- ok: true,
23
- value
24
- };
25
- }
26
3
  /**
27
4
  * Converts a _Result_ to a _Promise_
28
5
  *
@@ -36,9 +13,6 @@ async function toPromise(result) {
36
13
  if (!isResult(actual)) return Promise.reject(new Error(RESULT_MESSAGE_PROMISE));
37
14
  return isOk(actual) ? Promise.resolve(actual.value) : Promise.reject(actual.error);
38
15
  }
39
- function unwrap(value, defaultValue) {
40
- return isOk(value) ? value.value : defaultValue;
41
- }
42
16
  const RESULT_MESSAGE_PROMISE = "toPromise expected to receive a Result";
43
17
  //#endregion
44
- export { error, getError, isError, isOk, isResult, ok, toPromise, unwrap };
18
+ export { error, isError, isOk, isResult, ok, toPromise, unwrap };
@@ -1,5 +1,5 @@
1
1
  import { GenericCallback } from "../../models.mjs";
2
- import { Result, UnwrapValue } from "../models.mjs";
2
+ import { Result, UnwrapValue } from "../../internal/result/models.mjs";
3
3
  //#region src/result/work/flow.d.ts
4
4
  /**
5
5
  * A synchronous _Flow_, a function that attempts to pipe values through a series of functions
@@ -177,5 +177,8 @@ declare function attemptFlow<First extends GenericCallback>(first: First, ...fns
177
177
  * @returns _Flow_ function
178
178
  */
179
179
  declare function attemptFlow(...fns: GenericCallback[]): (...args: unknown[]) => Result<unknown>;
180
+ declare namespace attemptFlow {
181
+ var async: typeof attemptAsyncFlow;
182
+ }
180
183
  //#endregion
181
184
  export { AttemptFlow, AttemptFlowPromise, attemptAsyncFlow, attemptFlow };
@@ -1,5 +1,5 @@
1
- import { isError, isOk } from "../../internal/result.mjs";
2
- import { asyncFlow, flow } from "../../function/work.mjs";
1
+ import { isError, isOk } from "../../internal/result/misc.mjs";
2
+ import { asyncFlow, flow } from "../../internal/function/work.mjs";
3
3
  import { asyncAttempt, attempt } from "../index.mjs";
4
4
  //#region src/result/work/flow.ts
5
5
  function attemptAsyncFlow(...fns) {
@@ -22,6 +22,7 @@ function attemptFlow(...fns) {
22
22
  }));
23
23
  });
24
24
  }
25
+ attemptFlow.async = attemptAsyncFlow;
25
26
  Object.defineProperty(attemptFlow, "async", { value: attemptAsyncFlow });
26
27
  //#endregion
27
28
  export { attemptAsyncFlow, attemptFlow };
@@ -1,5 +1,5 @@
1
1
  import { GenericCallback } from "../../models.mjs";
2
- import { Result, UnwrapValue } from "../models.mjs";
2
+ import { Result, UnwrapValue } from "../../internal/result/models.mjs";
3
3
  //#region src/result/work/pipe.d.ts
4
4
  type WrapValue<Value> = Result<UnwrapValue<Value>>;
5
5
  /**
@@ -178,5 +178,8 @@ declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth
178
178
  * @returns _Piped_ result
179
179
  */
180
180
  declare function attemptPipe<Initial>(initial: GenericCallback | Initial | Result<Initial>, first?: (value: UnwrapValue<Initial>) => unknown, ...seconds: Array<(value: unknown) => unknown>): WrapValue<Initial>;
181
+ declare namespace attemptPipe {
182
+ var async: typeof attemptAsyncPipe;
183
+ }
181
184
  //#endregion
182
185
  export { attemptAsyncPipe, attemptPipe };
@@ -1,5 +1,5 @@
1
- import { isError, isOk } from "../../internal/result.mjs";
2
- import { asyncPipe, pipe } from "../../function/work.mjs";
1
+ import { isError, isOk } from "../../internal/result/misc.mjs";
2
+ import { asyncPipe, pipe } from "../../internal/function/work.mjs";
3
3
  import { asyncAttempt, attempt } from "../index.mjs";
4
4
  //#region src/result/work/pipe.ts
5
5
  async function attemptAsyncPipe(initial, first, ...seconds) {
@@ -18,6 +18,7 @@ function attemptPipe(initial, first, ...seconds) {
18
18
  return pipe(value, ...[first, ...seconds]);
19
19
  });
20
20
  }
21
+ attemptPipe.async = attemptAsyncPipe;
21
22
  Object.defineProperty(attemptPipe, "async", { value: attemptAsyncPipe });
22
23
  //#endregion
23
24
  export { attemptAsyncPipe, attemptPipe };
@@ -1,4 +1,4 @@
1
- import { getSizedMaximum } from "../internal/sized.mjs";
1
+ import { getSizedMaximum } from "../internal/sized/misc.mjs";
2
2
  //#region src/sized/set.ts
3
3
  /**
4
4
  * A _Set_ with a maximum size
@@ -1,6 +1,6 @@
1
1
  import { isPlainObject } from "../internal/is.mjs";
2
- import { getString } from "../internal/string.mjs";
3
- import { lowerCase } from "./case.mjs";
2
+ import { getString } from "../internal/string/misc.mjs";
3
+ import { lowerCase } from "../internal/string/case.mjs";
4
4
  import { includes } from "./match.mjs";
5
5
  //#region src/string/fuzzy.ts
6
6
  function getHandler(input) {
@@ -1,4 +1,4 @@
1
- import { getString, join, words } from "../internal/string.mjs";
1
+ import { getString, join, words } from "../internal/string/misc.mjs";
2
2
  //#region src/string/index.d.ts
3
3
  /**
4
4
  * Dedent a string template, removing common leading whitespace from each line
@@ -1,5 +1,5 @@
1
1
  import { isTemplateStringsArray } from "../internal/is.mjs";
2
- import { getString, interpolate, join, words } from "../internal/string.mjs";
2
+ import { getString, interpolate, join, words } from "../internal/string/misc.mjs";
3
3
  //#region src/string/index.ts
4
4
  function dedent(value, ...values) {
5
5
  let actual;
@@ -1,4 +1,4 @@
1
- import { memoize } from "../function/memoize.mjs";
1
+ import { memoize } from "../internal/function/memoize.mjs";
2
2
  //#region src/string/match.ts
3
3
  /**
4
4
  * Check if a string ends with a specified substring
@@ -1,6 +1,6 @@
1
1
  import { isPlainObject } from "../internal/is.mjs";
2
- import { memoize } from "../function/memoize.mjs";
3
- import { lowerCase } from "./case.mjs";
2
+ import { memoize } from "../internal/function/memoize.mjs";
3
+ import { lowerCase } from "../internal/string/case.mjs";
4
4
  //#region src/string/normalize.ts
5
5
  /**
6
6
  * Deburr a string, removing diacritical marks
@@ -1,5 +1,5 @@
1
1
  import { isPlainObject, isTemplateStringsArray } from "../internal/is.mjs";
2
- import { getString, interpolate } from "../internal/string.mjs";
2
+ import { getString, interpolate } from "../internal/string/misc.mjs";
3
3
  import { getValue } from "../internal/value/get.mjs";
4
4
  //#region src/string/template.ts
5
5
  function getRenderer(strings, values) {
@@ -0,0 +1,2 @@
1
+ import { Subscription, isSubscription } from "./internal/subscription.mjs";
2
+ export { type Subscription, isSubscription };
@@ -0,0 +1,2 @@
1
+ import { isSubscription } from "./internal/subscription.mjs";
2
+ export { isSubscription };
@@ -1,5 +1,5 @@
1
1
  import { isArrayOrPlainObject } from "../internal/is.mjs";
2
- import { join } from "../internal/string.mjs";
2
+ import { join } from "../internal/string/misc.mjs";
3
3
  import { equal } from "../internal/value/equal.mjs";
4
4
  //#region src/value/diff.ts
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { isArrayOrPlainObject } from "../internal/is.mjs";
2
- import { join } from "../internal/string.mjs";
2
+ import { join } from "../internal/string/misc.mjs";
3
3
  //#region src/value/smush.ts
4
4
  function flattenObject(value, depth, smushed, prefix) {
5
5
  if (depth >= SMUSH_MAX_DEPTH) return {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oscarpalmer/atoms",
3
- "version": "0.194.0",
3
+ "version": "0.195.1",
4
4
  "description": "Atomic utilities for making your JavaScript better.",
5
5
  "keywords": [
6
6
  "array",
@@ -90,13 +90,17 @@
90
90
  "default": "./dist/function/index.mjs"
91
91
  },
92
92
  "./function/assert": {
93
- "types": "./dist/function/assert.d.mts",
94
- "default": "./dist/function/assert.mjs"
93
+ "types": "./dist/internal/function/assert.d.mts",
94
+ "default": "./dist/internal/function/assert.mjs"
95
95
  },
96
96
  "./function/limit": {
97
97
  "types": "./dist/function/limit.d.mts",
98
98
  "default": "./dist/function/limit.mjs"
99
99
  },
100
+ "./function/memoize": {
101
+ "types": "./dist/internal/function/memoize.d.mts",
102
+ "default": "./dist/internal/function/memoize.mjs"
103
+ },
100
104
  "./function/once": {
101
105
  "types": "./dist/function/once.d.mts",
102
106
  "default": "./dist/function/once.mjs"
@@ -106,8 +110,8 @@
106
110
  "default": "./dist/function/retry.mjs"
107
111
  },
108
112
  "./function/work": {
109
- "types": "./dist/function/work.d.mts",
110
- "default": "./dist/function/work.mjs"
113
+ "types": "./dist/internal/function/work.d.mts",
114
+ "default": "./dist/internal/function/work.mjs"
111
115
  },
112
116
  "./herald": {
113
117
  "types": "./dist/herald.d.mts",
@@ -181,16 +185,16 @@
181
185
  "default": "./dist/result/misc.mjs"
182
186
  },
183
187
  "./result/models": {
184
- "types": "./dist/result/models.d.mts",
185
- "default": "./dist/result/models.mjs"
188
+ "types": "./dist/internal/result/models.d.mts",
189
+ "default": "./dist/internal/result/models.mjs"
186
190
  },
187
191
  "./result/pipe": {
188
192
  "types": "./dist/result/work/pipe.d.mts",
189
193
  "default": "./dist/result/work/pipe.mjs"
190
194
  },
191
195
  "./sized/map": {
192
- "types": "./dist/sized/map.d.mts",
193
- "default": "./dist/sized/map.mjs"
196
+ "types": "./dist/internal/sized/map.d.mts",
197
+ "default": "./dist/internal/sized/map.mjs"
194
198
  },
195
199
  "./sized/set": {
196
200
  "types": "./dist/sized/set.d.mts",
@@ -201,8 +205,8 @@
201
205
  "default": "./dist/string/index.mjs"
202
206
  },
203
207
  "./string/case": {
204
- "types": "./dist/string/case.d.mts",
205
- "default": "./dist/string/case.mjs"
208
+ "types": "./dist/internal/string/case.d.mts",
209
+ "default": "./dist/internal/string/case.mjs"
206
210
  },
207
211
  "./string/fuzzy": {
208
212
  "types": "./dist/string/fuzzy.d.mts",
@@ -220,6 +224,10 @@
220
224
  "types": "./dist/string/template.d.mts",
221
225
  "default": "./dist/string/template.mjs"
222
226
  },
227
+ "./subscription": {
228
+ "types": "./dist/subscription.d.mts",
229
+ "default": "./dist/subscription.mjs"
230
+ },
223
231
  "./value": {
224
232
  "types": "./dist/value/index.d.mts",
225
233
  "default": "./dist/value/index.mjs"
@@ -255,6 +263,10 @@
255
263
  "./value/merge": {
256
264
  "types": "./dist/value/merge.d.mts",
257
265
  "default": "./dist/value/merge.mjs"
266
+ },
267
+ "./value/transform": {
268
+ "types": "./dist/value/transform.d.mts",
269
+ "default": "./dist/value/transform.mjs"
258
270
  }
259
271
  },
260
272
  "scripts": {
File without changes