Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

libskynet

Package Overview
Dependencies
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libskynet - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

dist/stringify.d.ts

2

dist/err.d.ts
declare function addContextToErr(err: string | null, context: string): string | null;
declare function composeErr(...inputs: any): string;
declare function composeErr(...inputs: any): string | null;
export { addContextToErr, composeErr };

@@ -0,1 +1,2 @@

import { tryStringify } from "./stringify.js";
// addContextToErr is a helper function that standardizes the formatting of

@@ -7,2 +8,6 @@ // adding context to an error. Within the world of go we discovered that being

// addContextToErr will return null if the input err is null.
//
// NOTE: To protect against accidental situations where an Error type or some
// other type is provided instead of a string, we wrap both of the inputs with
// tryStringify before returning them. This prevents runtime failures.
function addContextToErr(err, context) {

@@ -12,3 +17,3 @@ if (err === null) {

}
return context + ": " + err;
return tryStringify(context) + ": " + tryStringify(err);
}

@@ -23,24 +28,18 @@ // composeErr takes a series of inputs and composes them into a single string.

let result = "";
let resultEmpty = true;
for (let i = 0; i < inputs.length; i++) {
// Prepend a newline if this isn't the first element.
if (i !== 0) {
result += "\n";
}
// Strings can be added without modification.
if (typeof inputs[i] === "string") {
result += inputs[i];
if (inputs[i] === null) {
continue;
}
// Everything else needs to be stringified, log an error if it
// fails.
try {
let str = JSON.stringify(inputs[i]);
result += str;
if (resultEmpty) {
result += "\n";
resultEmpty = false;
}
catch (err) {
result += "unable to stringify object: " + err.toString();
}
result += tryStringify(inputs[i]);
}
if (resultEmpty) {
return null;
}
return result;
}
export { addContextToErr, composeErr };

@@ -15,2 +15,3 @@ export { blake2b } from "./blake2b.js";

export { verifyResolverLinkProofs } from "./skylinkverifyresolver.js";
export { tryStringify } from "./stringify.js";
export { verifyDownload } from "./verifydownload.js";

@@ -15,2 +15,3 @@ export { blake2b } from "./blake2b.js";

export { verifyResolverLinkProofs } from "./skylinkverifyresolver.js";
export { tryStringify } from "./stringify.js";
export { verifyDownload } from "./verifydownload.js";
{
"name": "libskynet",
"version": "0.0.2",
"version": "0.0.3",
"description": "helper library to interact with skynet's low level primitives",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc