@oscarpalmer/atoms 0.141.0 → 0.141.2

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.
@@ -3279,6 +3279,7 @@ function result(callback, err) {
3279
3279
  return getError(err ?? thrown, err == null ? void 0 : thrown);
3280
3280
  }
3281
3281
  }
3282
+ result.async = asyncResult;
3282
3283
  async function asyncResult(callback, err) {
3283
3284
  try {
3284
3285
  return ok(await callback());
@@ -3341,4 +3342,4 @@ var SizedSet = class extends Set {
3341
3342
  }
3342
3343
  }
3343
3344
  };
3344
- export { frame_rate_default as FRAME_RATE_MS, PromiseTimeoutError, QueueError, SizedMap, SizedSet, asyncResult, average, beacon, between, camelCase, capitalize, chunk, clamp, clone, compact, compare, count, debounce, delay, diff, endsWith, equal, error, exists, filter, find, flatten, fromQuery, getArray, getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getNormalizedHex, getNumber, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getString, getUuid, getValue, groupBy, hexToHsl, hexToHsla, hexToRgb, hexToRgba, hslToHex, hslToRgb, hslToRgba, ignoreKey, includes, indexOf, insert, isArrayOrPlainObject, isColor, isConstructor, isEmpty, isError, isFulfilled, isHexColor, isHslColor, isHslLike, isHslaColor, isKey, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isOk, isPlainObject, isPrimitive, isRejected, isResult, isRgbColor, isRgbLike, isRgbaColor, isTypedArray, join, kebabCase, logger, lowerCase, max, memoize, merge, min, noop, ok, parse, partial, pascalCase, promises, push, queue, result, rgbToHex, rgbToHsl, rgbToHsla, round, setValue, shuffle, smush, snakeCase, sort, splice, startsWith, sum, template, throttle, timed, titleCase, toMap, toQuery, toRecord, toSet, trim, truncate, tryDecode, tryEncode, unique, unsmush, unwrap, upperCase, words };
3345
+ export { frame_rate_default as FRAME_RATE_MS, PromiseTimeoutError, QueueError, SizedMap, SizedSet, average, beacon, between, camelCase, capitalize, chunk, clamp, clone, compact, compare, count, debounce, delay, diff, endsWith, equal, error, exists, filter, find, flatten, fromQuery, getArray, getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getNormalizedHex, getNumber, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getString, getUuid, getValue, groupBy, hexToHsl, hexToHsla, hexToRgb, hexToRgba, hslToHex, hslToRgb, hslToRgba, ignoreKey, includes, indexOf, insert, isArrayOrPlainObject, isColor, isConstructor, isEmpty, isError, isFulfilled, isHexColor, isHslColor, isHslLike, isHslaColor, isKey, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isOk, isPlainObject, isPrimitive, isRejected, isResult, isRgbColor, isRgbLike, isRgbaColor, isTypedArray, join, kebabCase, logger, lowerCase, max, memoize, merge, min, noop, ok, parse, partial, pascalCase, promises, push, queue, result, rgbToHex, rgbToHsl, rgbToHsla, round, setValue, shuffle, smush, snakeCase, sort, splice, startsWith, sum, template, throttle, timed, titleCase, toMap, toQuery, toRecord, toSet, trim, truncate, tryDecode, tryEncode, unique, unsmush, unwrap, upperCase, words };
package/dist/index.js CHANGED
@@ -55,6 +55,6 @@ import { PromiseTimeoutError, delay, isFulfilled, isRejected, promises, timed }
55
55
  import { fromQuery, toQuery } from "./query.js";
56
56
  import { QueueError, queue } from "./queue.js";
57
57
  import { getRandomBoolean, getRandomCharacters, getRandomColor, getRandomHex, getRandomItem, getRandomItems } from "./random.js";
58
- import { asyncResult, error, isError, isOk, isResult, ok, result, unwrap } from "./result.js";
58
+ import { error, isError, isOk, isResult, ok, result, unwrap } from "./result.js";
59
59
  import { SizedSet } from "./sized/set.js";
60
- export { frame_rate_default as FRAME_RATE_MS, PromiseTimeoutError, QueueError, SizedMap, SizedSet, asyncResult, average, beacon, between, camelCase, capitalize, chunk, clamp, clone, compact, compare, count, debounce, delay, diff, endsWith, equal, error, exists, filter, find, flatten, fromQuery, getArray, getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getNormalizedHex, getNumber, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getString, getUuid, getValue, groupBy, hexToHsl, hexToHsla, hexToRgb, hexToRgba, hslToHex, hslToRgb, hslToRgba, ignoreKey, includes, indexOf, insert, isArrayOrPlainObject, isColor, isConstructor, isEmpty, isError, isFulfilled, isHexColor, isHslColor, isHslLike, isHslaColor, isKey, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isOk, isPlainObject, isPrimitive, isRejected, isResult, isRgbColor, isRgbLike, isRgbaColor, isTypedArray, join, kebabCase, logger, lowerCase, max, memoize, merge, min, noop, ok, parse, partial, pascalCase, promises, push, queue, result, rgbToHex, rgbToHsl, rgbToHsla, round, setValue, shuffle, smush, snakeCase, sort, splice, startsWith, sum, template, throttle, timed, titleCase, toMap, toQuery, toRecord, toSet, trim, truncate, tryDecode, tryEncode, unique, unsmush, unwrap, upperCase, words };
60
+ export { frame_rate_default as FRAME_RATE_MS, PromiseTimeoutError, QueueError, SizedMap, SizedSet, average, beacon, between, camelCase, capitalize, chunk, clamp, clone, compact, compare, count, debounce, delay, diff, endsWith, equal, error, exists, filter, find, flatten, fromQuery, getArray, getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getNormalizedHex, getNumber, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getString, getUuid, getValue, groupBy, hexToHsl, hexToHsla, hexToRgb, hexToRgba, hslToHex, hslToRgb, hslToRgba, ignoreKey, includes, indexOf, insert, isArrayOrPlainObject, isColor, isConstructor, isEmpty, isError, isFulfilled, isHexColor, isHslColor, isHslLike, isHslaColor, isKey, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isOk, isPlainObject, isPrimitive, isRejected, isResult, isRgbColor, isRgbLike, isRgbaColor, isTypedArray, join, kebabCase, logger, lowerCase, max, memoize, merge, min, noop, ok, parse, partial, pascalCase, promises, push, queue, result, rgbToHex, rgbToHsl, rgbToHsla, round, setValue, shuffle, smush, snakeCase, sort, splice, startsWith, sum, template, throttle, timed, titleCase, toMap, toQuery, toRecord, toSet, trim, truncate, tryDecode, tryEncode, unique, unsmush, unwrap, upperCase, words };
package/dist/result.js CHANGED
@@ -51,6 +51,7 @@ function result(callback, err) {
51
51
  return getError(err ?? thrown, err == null ? void 0 : thrown);
52
52
  }
53
53
  }
54
+ result.async = asyncResult;
54
55
  async function asyncResult(callback, err) {
55
56
  try {
56
57
  return ok(await callback());
@@ -61,4 +62,4 @@ async function asyncResult(callback, err) {
61
62
  function unwrap(value, defaultValue) {
62
63
  return isOk(value) ? value.value : defaultValue;
63
64
  }
64
- export { asyncResult, error, isError, isOk, isResult, ok, result, unwrap };
65
+ export { error, isError, isOk, isResult, ok, result, unwrap };
package/package.json CHANGED
@@ -236,5 +236,5 @@
236
236
  },
237
237
  "type": "module",
238
238
  "types": "./types/index.d.ts",
239
- "version": "0.141.0"
239
+ "version": "0.141.2"
240
240
  }
package/src/result.ts CHANGED
@@ -180,13 +180,15 @@ export function result<Value, E>(
180
180
  }
181
181
  }
182
182
 
183
+ result.async = asyncResult;
184
+
183
185
  /**
184
186
  * Executes a callback asynchronously, catching any errors, and returns a result
185
187
  * @param callback Callback to execute
186
188
  * @param error Error value
187
189
  * @returns Callback result
188
190
  */
189
- export async function asyncResult<Value, E>(
191
+ async function asyncResult<Value, E>(
190
192
  callback: () => Promise<Value>,
191
193
  error: E,
192
194
  ): Promise<ExtendedErr<E> | Ok<Value>>;
@@ -196,9 +198,9 @@ export async function asyncResult<Value, E>(
196
198
  * @param callback Callback to execute
197
199
  * @returns Callback result
198
200
  */
199
- export async function asyncResult<Value>(callback: () => Promise<Value>): Promise<Result<Value>>;
201
+ async function asyncResult<Value>(callback: () => Promise<Value>): Promise<Result<Value>>;
200
202
 
201
- export async function asyncResult<Value, E>(
203
+ async function asyncResult<Value, E>(
202
204
  callback: () => Promise<Value>,
203
205
  err?: E,
204
206
  ): Promise<Result<Value, E>> {
package/types/result.d.ts CHANGED
@@ -90,19 +90,22 @@ export declare function result<Value, E>(callback: () => Value, error: E): Exten
90
90
  * @returns Callback result
91
91
  */
92
92
  export declare function result<Value>(callback: () => Value): Result<Value, Error>;
93
+ export declare namespace result {
94
+ var async: typeof asyncResult;
95
+ }
93
96
  /**
94
97
  * Executes a callback asynchronously, catching any errors, and returns a result
95
98
  * @param callback Callback to execute
96
99
  * @param error Error value
97
100
  * @returns Callback result
98
101
  */
99
- export declare function asyncResult<Value, E>(callback: () => Promise<Value>, error: E): Promise<ExtendedErr<E> | Ok<Value>>;
102
+ declare function asyncResult<Value, E>(callback: () => Promise<Value>, error: E): Promise<ExtendedErr<E> | Ok<Value>>;
100
103
  /**
101
104
  * Executes a callback asynchronously, catching any errors, and returns a result
102
105
  * @param callback Callback to execute
103
106
  * @returns Callback result
104
107
  */
105
- export declare function asyncResult<Value>(callback: () => Promise<Value>): Promise<Result<Value>>;
108
+ declare function asyncResult<Value>(callback: () => Promise<Value>): Promise<Result<Value>>;
106
109
  /**
107
110
  * Gets the value of an ok result _(or a default value)_
108
111
  * @param value Result to unwrap
@@ -117,3 +120,4 @@ export declare function unwrap<Value, E = Error>(value: Result<Value, E>, defaul
117
120
  * @returns Value of the result _(or the default value)_
118
121
  */
119
122
  export declare function unwrap(value: unknown, defaultValue: unknown): unknown;
123
+ export {};