@oscarpalmer/atoms 0.195.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.
@@ -36,6 +36,9 @@ declare function asyncThrottle<Callback extends GenericAsyncCallback | GenericCa
36
36
  * @returns Debounced callback handler with a `cancel` method
37
37
  */
38
38
  declare function debounce<Callback extends GenericCallback>(callback: Callback, time?: number): CancelableCallback<Callback>;
39
+ declare namespace debounce {
40
+ var async: typeof asyncDebounce;
41
+ }
39
42
  /**
40
43
  * Throttle a function, ensuring it is only called once every `time` milliseconds
41
44
  *
@@ -44,5 +47,8 @@ declare function debounce<Callback extends GenericCallback>(callback: Callback,
44
47
  * @returns Throttled callback handler with a `cancel` method
45
48
  */
46
49
  declare function throttle<Callback extends GenericCallback>(callback: Callback, time?: number): CancelableCallback<Callback>;
50
+ declare namespace throttle {
51
+ var async: typeof asyncThrottle;
52
+ }
47
53
  //#endregion
48
54
  export { asyncDebounce, asyncThrottle, debounce, throttle };
@@ -52,6 +52,8 @@ function debounce(callback, time) {
52
52
  function throttle(callback, time) {
53
53
  return getTimer(TIMER_THROTTLE, callback, time);
54
54
  }
55
+ debounce.async = asyncDebounce;
56
+ throttle.async = asyncThrottle;
55
57
  Object.defineProperty(debounce, "async", { value: asyncDebounce });
56
58
  Object.defineProperty(throttle, "async", { value: asyncThrottle });
57
59
  //#endregion
@@ -16,5 +16,8 @@ declare function asyncOnce<Callback extends GenericAsyncCallback>(callback: Call
16
16
  * @returns _Once_ callback
17
17
  */
18
18
  declare function once<Callback extends GenericCallback>(callback: Callback): OnceCallback<Callback>;
19
+ declare namespace once {
20
+ var async: typeof asyncOnce;
21
+ }
19
22
  //#endregion
20
23
  export { asyncOnce, once };
@@ -113,6 +113,7 @@ function once(callback) {
113
113
  }
114
114
  const ONCE_MESSAGE_CLEARED = "Once has been cleared";
115
115
  const ONCE_MESSAGE_EXPECTATION = "Once expected a function";
116
+ once.async = asyncOnce;
116
117
  Object.defineProperty(once, "async", { value: asyncOnce });
117
118
  //#endregion
118
119
  export { asyncOnce, once };
@@ -1,4 +1,4 @@
1
- import { GenericCallback } from "../models.mjs";
1
+ import { GenericAsyncCallback, GenericCallback } from "../models.mjs";
2
2
  //#region src/function/retry.d.ts
3
3
  /**
4
4
  * An error thrown when a retry fails
@@ -12,6 +12,26 @@ type RetryOptions = {
12
12
  times?: number;
13
13
  when?: (error: unknown) => boolean;
14
14
  };
15
+ /**
16
+ * Retry a callback a specified number of times, with a delay between attempts
17
+ *
18
+ * _Available as `asyncRetry` and `retry.async`_
19
+ *
20
+ * @param callback Callback to retry
21
+ * @param options Retry options
22
+ * @returns Callback result
23
+ */
24
+ declare function asyncRetry<Callback extends GenericAsyncCallback>(callback: Callback, options?: RetryOptions): Promise<Awaited<ReturnType<Callback>>>;
25
+ /**
26
+ * Retry a callback a specified number of times, with a delay between attempts
27
+ *
28
+ * _Available as `asyncRetry` and `retry.async`_
29
+ *
30
+ * @param callback Callback to retry
31
+ * @param options Retry options
32
+ * @returns Callback result
33
+ */
34
+ declare function asyncRetry<Callback extends GenericCallback>(callback: Callback, options?: RetryOptions): Promise<ReturnType<Callback>>;
15
35
  /**
16
36
  * Retry a callback a specified number of times
17
37
  *
@@ -20,5 +40,8 @@ type RetryOptions = {
20
40
  * @returns Callback result
21
41
  */
22
42
  declare function retry<Callback extends GenericCallback>(callback: Callback, options?: Omit<RetryOptions, 'delay'>): ReturnType<Callback>;
43
+ declare namespace retry {
44
+ var async: typeof asyncRetry;
45
+ }
23
46
  //#endregion
24
47
  export { RetryError, RetryOptions, retry };
@@ -84,6 +84,7 @@ function shouldRetry() {
84
84
  const RETRY_ERROR_NAME = "RetryError";
85
85
  const RETRY_MESSAGE_EXPECTATION = "Retry expected a function";
86
86
  const RETRY_MESSAGE_FAILED = "Retry failed";
87
+ retry.async = asyncRetry;
87
88
  Object.defineProperty(retry, "async", { value: asyncRetry });
88
89
  //#endregion
89
90
  export { RetryError, retry };
package/dist/index.d.mts CHANGED
@@ -3829,6 +3829,9 @@ declare function asyncThrottle<Callback extends GenericAsyncCallback | GenericCa
3829
3829
  * @returns Debounced callback handler with a `cancel` method
3830
3830
  */
3831
3831
  declare function debounce<Callback extends GenericCallback>(callback: Callback, time?: number): CancelableCallback<Callback>;
3832
+ declare namespace debounce {
3833
+ var async: typeof asyncDebounce;
3834
+ }
3832
3835
  /**
3833
3836
  * Throttle a function, ensuring it is only called once every `time` milliseconds
3834
3837
  *
@@ -3837,6 +3840,9 @@ declare function debounce<Callback extends GenericCallback>(callback: Callback,
3837
3840
  * @returns Throttled callback handler with a `cancel` method
3838
3841
  */
3839
3842
  declare function throttle<Callback extends GenericCallback>(callback: Callback, time?: number): CancelableCallback<Callback>;
3843
+ declare namespace throttle {
3844
+ var async: typeof asyncThrottle;
3845
+ }
3840
3846
  //#endregion
3841
3847
  //#region src/function/once.d.ts
3842
3848
  /**
@@ -3855,6 +3861,9 @@ declare function asyncOnce<Callback extends GenericAsyncCallback>(callback: Call
3855
3861
  * @returns _Once_ callback
3856
3862
  */
3857
3863
  declare function once<Callback extends GenericCallback>(callback: Callback): OnceCallback<Callback>;
3864
+ declare namespace once {
3865
+ var async: typeof asyncOnce;
3866
+ }
3858
3867
  //#endregion
3859
3868
  //#region src/function/retry.d.ts
3860
3869
  /**
@@ -3869,6 +3878,26 @@ type RetryOptions = {
3869
3878
  times?: number;
3870
3879
  when?: (error: unknown) => boolean;
3871
3880
  };
3881
+ /**
3882
+ * Retry a callback a specified number of times, with a delay between attempts
3883
+ *
3884
+ * _Available as `asyncRetry` and `retry.async`_
3885
+ *
3886
+ * @param callback Callback to retry
3887
+ * @param options Retry options
3888
+ * @returns Callback result
3889
+ */
3890
+ declare function asyncRetry<Callback extends GenericAsyncCallback>(callback: Callback, options?: RetryOptions): Promise<Awaited<ReturnType<Callback>>>;
3891
+ /**
3892
+ * Retry a callback a specified number of times, with a delay between attempts
3893
+ *
3894
+ * _Available as `asyncRetry` and `retry.async`_
3895
+ *
3896
+ * @param callback Callback to retry
3897
+ * @param options Retry options
3898
+ * @returns Callback result
3899
+ */
3900
+ declare function asyncRetry<Callback extends GenericCallback>(callback: Callback, options?: RetryOptions): Promise<ReturnType<Callback>>;
3872
3901
  /**
3873
3902
  * Retry a callback a specified number of times
3874
3903
  *
@@ -3877,6 +3906,9 @@ type RetryOptions = {
3877
3906
  * @returns Callback result
3878
3907
  */
3879
3908
  declare function retry<Callback extends GenericCallback>(callback: Callback, options?: Omit<RetryOptions, 'delay'>): ReturnType<Callback>;
3909
+ declare namespace retry {
3910
+ var async: typeof asyncRetry;
3911
+ }
3880
3912
  //#endregion
3881
3913
  //#region src/internal/result/models.d.ts
3882
3914
  /**
@@ -5396,6 +5428,9 @@ declare function attempt<Value, E>(callback: () => Value, error: E): ExtendedRes
5396
5428
  * @returns Callback result
5397
5429
  */
5398
5430
  declare function attempt<Value>(callback: () => Value): Result<Value, Error>;
5431
+ declare namespace attempt {
5432
+ var async: typeof asyncAttempt;
5433
+ }
5399
5434
  //#endregion
5400
5435
  //#region src/result/match.d.ts
5401
5436
  /**
@@ -5436,6 +5471,9 @@ declare function matchResult<Value, Returned, E = Error>(result: AnyResult<Value
5436
5471
  * @returns Matched value
5437
5472
  */
5438
5473
  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;
5474
+ declare namespace matchResult {
5475
+ var async: typeof asyncMatchResult;
5476
+ }
5439
5477
  //#endregion
5440
5478
  //#region src/result/work/flow.d.ts
5441
5479
  /**
@@ -5614,6 +5652,9 @@ declare function attemptFlow<First extends GenericCallback>(first: First, ...fns
5614
5652
  * @returns _Flow_ function
5615
5653
  */
5616
5654
  declare function attemptFlow(...fns: GenericCallback[]): (...args: unknown[]) => Result<unknown>;
5655
+ declare namespace attemptFlow {
5656
+ var async: typeof attemptAsyncFlow;
5657
+ }
5617
5658
  //#endregion
5618
5659
  //#region src/result/work/pipe.d.ts
5619
5660
  type WrapValue<Value> = Result<UnwrapValue<Value>>;
@@ -5793,6 +5834,9 @@ declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth
5793
5834
  * @returns _Piped_ result
5794
5835
  */
5795
5836
  declare function attemptPipe<Initial>(initial: GenericCallback | Initial | Result<Initial>, first?: (value: UnwrapValue<Initial>) => unknown, ...seconds: Array<(value: unknown) => unknown>): WrapValue<Initial>;
5837
+ declare namespace attemptPipe {
5838
+ var async: typeof attemptAsyncPipe;
5839
+ }
5796
5840
  //#endregion
5797
5841
  //#region src/string/fuzzy.d.ts
5798
5842
  /**
package/dist/index.mjs CHANGED
@@ -1528,6 +1528,8 @@ function debounce(callback, time) {
1528
1528
  function throttle(callback, time) {
1529
1529
  return getTimer(TIMER_THROTTLE, callback, time);
1530
1530
  }
1531
+ debounce.async = asyncDebounce;
1532
+ throttle.async = asyncThrottle;
1531
1533
  Object.defineProperty(debounce, "async", { value: asyncDebounce });
1532
1534
  Object.defineProperty(throttle, "async", { value: asyncThrottle });
1533
1535
  //#endregion
@@ -1841,6 +1843,7 @@ function once(callback) {
1841
1843
  }
1842
1844
  const ONCE_MESSAGE_CLEARED = "Once has been cleared";
1843
1845
  const ONCE_MESSAGE_EXPECTATION = "Once expected a function";
1846
+ once.async = asyncOnce;
1844
1847
  Object.defineProperty(once, "async", { value: asyncOnce });
1845
1848
  //#endregion
1846
1849
  //#region src/function/retry.ts
@@ -1927,6 +1930,7 @@ function shouldRetry() {
1927
1930
  const RETRY_ERROR_NAME = "RetryError";
1928
1931
  const RETRY_MESSAGE_EXPECTATION = "Retry expected a function";
1929
1932
  const RETRY_MESSAGE_FAILED = "Retry failed";
1933
+ retry.async = asyncRetry;
1930
1934
  Object.defineProperty(retry, "async", { value: asyncRetry });
1931
1935
  //#endregion
1932
1936
  //#region src/internal/function/work.ts
@@ -2822,6 +2826,7 @@ function attempt(callback, err) {
2822
2826
  return getError(err ?? thrown, err == null ? void 0 : thrown);
2823
2827
  }
2824
2828
  }
2829
+ attempt.async = asyncAttempt;
2825
2830
  Object.defineProperty(attempt, "async", { value: asyncAttempt });
2826
2831
  //#endregion
2827
2832
  //#region src/result/match.ts
@@ -2847,6 +2852,7 @@ function matchResult(result, first, error) {
2847
2852
  return errorHandler(value.error, value.original);
2848
2853
  }
2849
2854
  const MATCH_MESSAGE = "`result.match` expected a Result or a function that returns a Result";
2855
+ matchResult.async = asyncMatchResult;
2850
2856
  Object.defineProperty(matchResult, "async", { value: asyncMatchResult });
2851
2857
  //#endregion
2852
2858
  //#region src/result/work/flow.ts
@@ -2870,6 +2876,7 @@ function attemptFlow(...fns) {
2870
2876
  }));
2871
2877
  });
2872
2878
  }
2879
+ attemptFlow.async = attemptAsyncFlow;
2873
2880
  Object.defineProperty(attemptFlow, "async", { value: attemptAsyncFlow });
2874
2881
  //#endregion
2875
2882
  //#region src/result/work/pipe.ts
@@ -2889,6 +2896,7 @@ function attemptPipe(initial, first, ...seconds) {
2889
2896
  return pipe(value, ...[first, ...seconds]);
2890
2897
  });
2891
2898
  }
2899
+ attemptPipe.async = attemptAsyncPipe;
2892
2900
  Object.defineProperty(attemptPipe, "async", { value: attemptAsyncPipe });
2893
2901
  //#endregion
2894
2902
  //#region src/string/match.ts
@@ -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 };
@@ -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 };
@@ -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 };
@@ -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 };
@@ -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 };
@@ -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 };
@@ -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 };
@@ -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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oscarpalmer/atoms",
3
- "version": "0.195.0",
3
+ "version": "0.195.1",
4
4
  "description": "Atomic utilities for making your JavaScript better.",
5
5
  "keywords": [
6
6
  "array",