Comparing version 0.0.8 to 0.0.9
@@ -0,2 +1,4 @@ | ||
import { error } from "./types.js"; | ||
declare function tryStringify(obj: any): string; | ||
export { tryStringify }; | ||
declare function jsonStringify(obj: any): [string, error]; | ||
export { jsonStringify, tryStringify }; |
@@ -0,1 +1,2 @@ | ||
import { addContextToErr } from "./err.js"; | ||
// tryStringify will try to turn the provided input into a string. If the input | ||
@@ -25,2 +26,13 @@ // object is already a string, the input object will be returned. If the input | ||
} | ||
export { tryStringify }; | ||
// jsonStringify is a replacement for JSON.stringify that returns an error | ||
// rather than throwing. | ||
function jsonStringify(obj) { | ||
try { | ||
let str = JSON.stringify(obj); | ||
return [str, null]; | ||
} | ||
catch (err) { | ||
return ["", addContextToErr(tryStringify(err), "unable to stringify object")]; | ||
} | ||
} | ||
export { jsonStringify, tryStringify }; |
{ | ||
"name": "libskynet", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "helper library to interact with skynet's low level primitives", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
115870
3834