@koine/utils 1.2.1 → 1.2.3

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.
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Ensure to transform a JavaScript `Error` into a string (uses its `message`)
3
+ *
4
+ * @category Error
5
+ */
6
+ export declare const errorToString: (e: unknown) => string;
7
+ export default errorToString;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.errorToString = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var isString_1 = tslib_1.__importDefault(require("./isString"));
6
+ /**
7
+ * Ensure to transform a JavaScript `Error` into a string (uses its `message`)
8
+ *
9
+ * @category Error
10
+ */
11
+ var errorToString = function (e) {
12
+ return e instanceof Error ? e.message : (0, isString_1.default)(e) ? e : "";
13
+ };
14
+ exports.errorToString = errorToString;
15
+ exports.default = exports.errorToString;
@@ -0,0 +1,10 @@
1
+ import isString from "./isString";
2
+ /**
3
+ * Ensure to transform a JavaScript `Error` into a string (uses its `message`)
4
+ *
5
+ * @category Error
6
+ */
7
+ export var errorToString = function (e) {
8
+ return e instanceof Error ? e.message : isString(e) ? e : "";
9
+ };
10
+ export default errorToString;
package/index.d.ts CHANGED
@@ -21,6 +21,7 @@ export * from "./Defer";
21
21
  export * from "./Emitter";
22
22
  export * from "./encode";
23
23
  export * from "./ensureInt";
24
+ export * from "./errorToString";
24
25
  export * from "./findDuplicatedIndexes";
25
26
  export * from "./forin";
26
27
  export * from "./gbToBytes";
package/index.js CHANGED
@@ -25,6 +25,7 @@ tslib_1.__exportStar(require("./Emitter"), exports);
25
25
  tslib_1.__exportStar(require("./encode"), exports);
26
26
  tslib_1.__exportStar(require("./ensureInt"), exports);
27
27
  // export * from "./env"
28
+ tslib_1.__exportStar(require("./errorToString"), exports);
28
29
  tslib_1.__exportStar(require("./findDuplicatedIndexes"), exports);
29
30
  tslib_1.__exportStar(require("./forin"), exports);
30
31
  tslib_1.__exportStar(require("./gbToBytes"), exports);
package/index.mjs CHANGED
@@ -22,6 +22,7 @@ export * from "./Emitter";
22
22
  export * from "./encode";
23
23
  export * from "./ensureInt";
24
24
  // export * from "./env"
25
+ export * from "./errorToString";
25
26
  export * from "./findDuplicatedIndexes";
26
27
  export * from "./forin";
27
28
  export * from "./gbToBytes";
package/package.json CHANGED
@@ -11,6 +11,6 @@
11
11
  },
12
12
  "main": "./index.js",
13
13
  "types": "./index.d.ts",
14
- "version": "1.2.1",
14
+ "version": "1.2.3",
15
15
  "module": "./index.mjs"
16
16
  }