@koine/utils 1.2.2 → 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.
- package/errorToString.d.ts +7 -0
- package/errorToString.js +15 -0
- package/errorToString.mjs +10 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.mjs +1 -0
- package/package.json +1 -1
package/errorToString.js
ADDED
|
@@ -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
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