@clipboard-health/util-ts 0.5.9 → 0.6.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/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [0.6.1](https://github.com/ClipboardHealth/cbh-core/compare/util-ts-0.6.0...util-ts-0.6.1) (2023-07-05)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * sonarcloud code smells, reduce duplication ([#182](https://github.com/ClipboardHealth/cbh-core/issues/182)) ([5fd9bb6](https://github.com/ClipboardHealth/cbh-core/commit/5fd9bb6c2f79033ac0adaa8168a24835e24abc8b))
11
+
12
+ ## [0.6.0](https://github.com/ClipboardHealth/cbh-core/compare/util-ts-0.5.9...util-ts-0.6.0) (2023-07-05)
13
+
14
+
15
+ ### Features
16
+
17
+ * add toError, toErrorMessage, stringify, and isString to util-ts ([#181](https://github.com/ClipboardHealth/cbh-core/issues/181)) ([149390a](https://github.com/ClipboardHealth/cbh-core/commit/149390ab5e35852accbcf38245eb69e25a1f5323))
18
+
5
19
  ## [0.5.9](https://github.com/ClipboardHealth/cbh-core/compare/util-ts-0.5.8...util-ts-0.5.9) (2023-06-23)
6
20
 
7
21
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clipboard-health/util-ts",
3
- "version": "0.5.9",
3
+ "version": "0.6.1",
4
4
  "main": "./src/index.js",
5
5
  "scripts": {
6
6
  "build": "nx build util-ts",
@@ -0,0 +1,2 @@
1
+ export declare function isString(value: unknown): value is string;
2
+ //# sourceMappingURL=is-string.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-string.d.ts","sourceRoot":"","sources":["../../../../../packages/util-ts/src/lib/is-string.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isString = void 0;
4
+ function isString(value) {
5
+ return typeof value === "string" || value instanceof String;
6
+ }
7
+ exports.isString = isString;
8
+ //# sourceMappingURL=is-string.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-string.js","sourceRoot":"","sources":["../../../../../packages/util-ts/src/lib/is-string.ts"],"names":[],"mappings":";;;AAAA,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,YAAY,MAAM,CAAC;AAC9D,CAAC;AAFD,4BAEC"}
@@ -0,0 +1,2 @@
1
+ export declare function stringify(value: unknown): string;
2
+ //# sourceMappingURL=stringify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stringify.d.ts","sourceRoot":"","sources":["../../../../../packages/util-ts/src/lib/stringify.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAIhD"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stringify = void 0;
4
+ function stringify(value) {
5
+ return JSON.stringify(value, (_, value) => typeof value === "bigint" ? String(value) : value);
6
+ }
7
+ exports.stringify = stringify;
8
+ //# sourceMappingURL=stringify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stringify.js","sourceRoot":"","sources":["../../../../../packages/util-ts/src/lib/stringify.ts"],"names":[],"mappings":";;;AAAA,SAAgB,SAAS,CAAC,KAAc;IACtC,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,KAAc,EAAE,EAAE,CACjD,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAClD,CAAC;AACJ,CAAC;AAJD,8BAIC"}
@@ -0,0 +1,4 @@
1
+ export declare function isError(error: unknown): error is Error;
2
+ export declare function toError(error: unknown): Error;
3
+ export declare function toErrorMessage(error: unknown): string;
4
+ //# sourceMappingURL=to-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-error.d.ts","sourceRoot":"","sources":["../../../../../packages/util-ts/src/lib/to-error.ts"],"names":[],"mappings":"AAGA,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,KAAK,CAEtD;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAQ7C;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAErD"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toErrorMessage = exports.toError = exports.isError = void 0;
4
+ const is_string_1 = require("./is-string");
5
+ const stringify_1 = require("./stringify");
6
+ function isError(error) {
7
+ return error instanceof Error;
8
+ }
9
+ exports.isError = isError;
10
+ function toError(error) {
11
+ if (isError(error))
12
+ return error;
13
+ try {
14
+ return new Error((0, is_string_1.isString)(error) ? error : (0, stringify_1.stringify)(error));
15
+ }
16
+ catch {
17
+ return new Error(String(error));
18
+ }
19
+ }
20
+ exports.toError = toError;
21
+ function toErrorMessage(error) {
22
+ return toError(error).message;
23
+ }
24
+ exports.toErrorMessage = toErrorMessage;
25
+ //# sourceMappingURL=to-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-error.js","sourceRoot":"","sources":["../../../../../packages/util-ts/src/lib/to-error.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AACvC,2CAAwC;AAExC,SAAgB,OAAO,CAAC,KAAc;IACpC,OAAO,KAAK,YAAY,KAAK,CAAC;AAChC,CAAC;AAFD,0BAEC;AAED,SAAgB,OAAO,CAAC,KAAc;IACpC,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAEjC,IAAI;QACF,OAAO,IAAI,KAAK,CAAC,IAAA,oBAAQ,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAA,qBAAS,EAAC,KAAK,CAAC,CAAC,CAAC;KAC9D;IAAC,MAAM;QACN,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;KACjC;AACH,CAAC;AARD,0BAQC;AAED,SAAgB,cAAc,CAAC,KAAc;IAC3C,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AAChC,CAAC;AAFD,wCAEC"}