@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,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 {
@@ -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
@@ -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;
@@ -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
@@ -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) {
@@ -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
  /**
@@ -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) {
@@ -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.0",
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