yummies 4.2.0 → 4.2.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.
package/errors.d.ts CHANGED
@@ -1,19 +1,19 @@
1
1
  import { Maybe } from './utils/types.js';
2
- type ErrorToTextEnhancer = (error: any) => string;
3
- type ErrorToTextFormatErrorFn = (error: Error) => string;
2
+ type GetErrorTextEnhancer = (error: any) => string;
3
+ type GetErrorTextFormatErrorFn = (error: Error) => string;
4
4
  /**
5
5
  * Universal function for transforming any errors into readable error text
6
6
  *
7
7
  * This function can be enhanced with custom handlers using:
8
- * - `errorToText.unknownErrorText`
9
- * - `errorToText.formatError`
10
- * - `errorToText.enhance`
8
+ * - `getErrorText.unknownErrorText`
9
+ * - `getErrorText.formatError`
10
+ * - `getErrorText.enhance`
11
11
  */
12
- export declare const errorToText: {
12
+ export declare const getErrorText: {
13
13
  (error: unknown): string;
14
14
  unknownErrorText: string;
15
- formatError: Maybe<ErrorToTextFormatErrorFn>;
16
- enhance: Maybe<ErrorToTextEnhancer>;
15
+ formatError: Maybe<GetErrorTextFormatErrorFn>;
16
+ enhance: Maybe<GetErrorTextEnhancer>;
17
17
  };
18
18
  export {};
19
19
  //# sourceMappingURL=errors.d.ts.map
package/errors.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,KAAK,mBAAmB,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAC;AAClD,KAAK,wBAAwB,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC;AAEzD;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW;YAAW,OAAO;;;;CAkBzC,CAAC"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,KAAK,oBAAoB,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAC;AACnD,KAAK,yBAAyB,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC;AAE1D;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY;YAAW,OAAO;;;;CAkB1C,CAAC"}
package/errors.js CHANGED
@@ -3,27 +3,27 @@ import { typeGuard } from './type-guard/index.js';
3
3
  * Universal function for transforming any errors into readable error text
4
4
  *
5
5
  * This function can be enhanced with custom handlers using:
6
- * - `errorToText.unknownErrorText`
7
- * - `errorToText.formatError`
8
- * - `errorToText.enhance`
6
+ * - `getErrorText.unknownErrorText`
7
+ * - `getErrorText.formatError`
8
+ * - `getErrorText.enhance`
9
9
  */
10
- export const errorToText = (error) => {
10
+ export const getErrorText = (error) => {
11
11
  if (!error) {
12
- return errorToText.unknownErrorText;
12
+ return getErrorText.unknownErrorText;
13
13
  }
14
14
  if (typeGuard.isString(error)) {
15
15
  return error;
16
16
  }
17
17
  if (error instanceof Error) {
18
- return errorToText.formatError?.(error) ?? error.message;
18
+ return getErrorText.formatError?.(error) ?? error.message;
19
19
  }
20
- if (errorToText.enhance) {
21
- return errorToText.enhance(error);
20
+ if (getErrorText.enhance) {
21
+ return getErrorText.enhance(error);
22
22
  }
23
23
  else {
24
- return errorToText.unknownErrorText;
24
+ return getErrorText.unknownErrorText;
25
25
  }
26
26
  };
27
- errorToText.unknownErrorText = '';
28
- errorToText.formatError = null;
29
- errorToText.enhance = null;
27
+ getErrorText.unknownErrorText = '';
28
+ getErrorText.formatError = null;
29
+ getErrorText.enhance = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yummies",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
4
4
  "keywords": [],
5
5
  "author": "js2me",
6
6
  "license": "MIT",