@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.
- package/dist/array/index.d.mts +2 -2
- package/dist/array/index.mjs +2 -2
- package/dist/array/move.mjs +1 -1
- package/dist/array/swap.mjs +1 -1
- package/dist/color/instance.mjs +1 -1
- package/dist/color/misc/state.d.mts +1 -1
- package/dist/color/models.d.mts +1 -1
- package/dist/color/space/hex.mjs +1 -1
- package/dist/color/space/rgb.mjs +1 -1
- package/dist/function/index.d.mts +1 -2
- package/dist/function/index.mjs +1 -2
- package/dist/function/once.mjs +1 -1
- package/dist/herald.d.mts +2 -71
- package/dist/herald.mjs +1 -109
- package/dist/index.d.mts +3270 -3271
- package/dist/index.mjs +1500 -1498
- package/dist/{array → internal/array}/get.d.mts +2 -2
- package/dist/{array → internal/array}/get.mjs +2 -2
- package/dist/{array → internal/array}/match.d.mts +2 -2
- package/dist/{array → internal/array}/match.mjs +2 -2
- package/dist/internal/defaults.d.mts +5 -0
- package/dist/internal/defaults.mjs +9 -0
- package/dist/{function → internal/function}/assert.d.mts +2 -2
- package/dist/{function → internal/function}/assert.mjs +2 -2
- package/dist/{function → internal/function}/memoize.d.mts +2 -2
- package/dist/{function → internal/function}/memoize.mjs +3 -3
- package/dist/{function → internal/function}/work.d.mts +2 -2
- package/dist/{function → internal/function}/work.mjs +2 -2
- package/dist/internal/herald.d.mts +71 -0
- package/dist/internal/herald.mjs +110 -0
- package/dist/internal/number.d.mts +1 -2
- package/dist/internal/number.mjs +1 -4
- package/dist/internal/{result.d.mts → result/misc.d.mts} +42 -3
- package/dist/internal/{result.mjs → result/misc.mjs} +29 -3
- package/dist/{result → internal/result}/models.d.mts +2 -2
- package/dist/{sized → internal/sized}/map.d.mts +1 -1
- package/dist/{sized → internal/sized}/map.mjs +2 -2
- package/dist/internal/{sized.d.mts → sized/misc.d.mts} +1 -1
- package/dist/internal/{sized.mjs → sized/misc.mjs} +2 -2
- package/dist/{string → internal/string}/case.d.mts +1 -1
- package/dist/{string → internal/string}/case.mjs +2 -2
- package/dist/internal/{string.d.mts → string/misc.d.mts} +1 -1
- package/dist/internal/{string.mjs → string/misc.mjs} +1 -1
- package/dist/internal/value/compare.mjs +1 -1
- package/dist/internal/value/has.d.mts +1 -1
- package/dist/internal/value/misc.d.mts +1 -1
- package/dist/internal/value/misc.mjs +2 -2
- package/dist/is.mjs +2 -2
- package/dist/logger.mjs +1 -1
- package/dist/promise/helpers.d.mts +1 -1
- package/dist/promise/helpers.mjs +2 -2
- package/dist/promise/index.d.mts +1 -1
- package/dist/promise/misc.d.mts +1 -1
- package/dist/promise/misc.mjs +2 -1
- package/dist/promise/models.d.mts +1 -1
- package/dist/query.mjs +1 -1
- package/dist/queue.mjs +1 -4
- package/dist/random.mjs +1 -1
- package/dist/result/index.d.mts +1 -1
- package/dist/result/index.mjs +1 -1
- package/dist/result/match.d.mts +1 -1
- package/dist/result/match.mjs +1 -1
- package/dist/result/misc.d.mts +3 -42
- package/dist/result/misc.mjs +2 -28
- package/dist/result/work/flow.d.mts +1 -1
- package/dist/result/work/flow.mjs +2 -2
- package/dist/result/work/pipe.d.mts +1 -1
- package/dist/result/work/pipe.mjs +2 -2
- package/dist/sized/set.mjs +1 -1
- package/dist/string/fuzzy.mjs +2 -2
- package/dist/string/index.d.mts +1 -1
- package/dist/string/index.mjs +1 -1
- package/dist/string/match.mjs +1 -1
- package/dist/string/normalize.mjs +2 -2
- package/dist/string/template.mjs +1 -1
- package/dist/subscription.d.mts +2 -0
- package/dist/subscription.mjs +2 -0
- package/dist/value/diff.mjs +1 -1
- package/dist/value/smush.mjs +1 -1
- package/package.json +23 -11
- /package/dist/{result → internal/result}/models.mjs +0 -0
package/dist/result/index.mjs
CHANGED
package/dist/result/match.d.mts
CHANGED
package/dist/result/match.mjs
CHANGED
package/dist/result/misc.d.mts
CHANGED
|
@@ -1,29 +1,6 @@
|
|
|
1
|
-
import { AnyResult
|
|
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,
|
|
23
|
+
export { error, isError, isOk, isResult, ok, toPromise, unwrap };
|
package/dist/result/misc.mjs
CHANGED
|
@@ -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,
|
|
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 "
|
|
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 "
|
|
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) {
|
package/dist/sized/set.mjs
CHANGED
package/dist/string/fuzzy.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isPlainObject } from "../internal/is.mjs";
|
|
2
|
-
import { getString } from "../internal/string.mjs";
|
|
3
|
-
import { lowerCase } from "
|
|
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) {
|
package/dist/string/index.d.mts
CHANGED
package/dist/string/index.mjs
CHANGED
|
@@ -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;
|
package/dist/string/match.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isPlainObject } from "../internal/is.mjs";
|
|
2
|
-
import { memoize } from "../function/memoize.mjs";
|
|
3
|
-
import { lowerCase } from "
|
|
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
|
package/dist/string/template.mjs
CHANGED
|
@@ -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) {
|
package/dist/value/diff.mjs
CHANGED
package/dist/value/smush.mjs
CHANGED
|
@@ -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.
|
|
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
|