Socket
Socket
Sign inDemoInstall

@chainsafe/lodestar-utils

Package Overview
Dependencies
Maintainers
4
Versions
843
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.13.0 to 0.14.0

lib/timeout.d.ts

8

lib/errors.d.ts

@@ -9,3 +9,3 @@ import { Json } from "@chainsafe/ssz";

type: T;
constructor(type: T);
constructor(type: T, message?: string);
getMetadata(): {

@@ -27,2 +27,8 @@ [key: string]: Json;

}
/**
* Throw this error when wrapped timeout expires
*/
export declare class TimeoutError extends Error {
constructor(message?: string);
}
//# sourceMappingURL=errors.d.ts.map

@@ -6,3 +6,3 @@ "use strict";

});
exports.ErrorAborted = exports.LodestarError = void 0;
exports.TimeoutError = exports.ErrorAborted = exports.LodestarError = void 0;

@@ -19,4 +19,4 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

class LodestarError extends Error {
constructor(type) {
super(type.code);
constructor(type, message) {
super(message || type.code);

@@ -56,4 +56,17 @@ _defineProperty(this, "type", void 0);

}
/**
* Throw this error when wrapped timeout expires
*/
exports.ErrorAborted = ErrorAborted;
class TimeoutError extends Error {
constructor(message) {
super("Timeout ".concat(message || ""));
}
}
exports.TimeoutError = TimeoutError;
//# sourceMappingURL=errors.js.map

2

lib/index.d.ts

@@ -8,6 +8,6 @@ export * from "./events";

export * from "./math";
export * from "./misc";
export * from "./objects";
export * from "./sleep";
export * from "./sort";
export * from "./timeout";
export * from "./verifyMerkleBranch";

@@ -14,0 +14,0 @@ export * from "./json";

@@ -98,15 +98,2 @@ "use strict";

var _misc = require("./misc");
Object.keys(_misc).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _misc[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _misc[key];
}
});
});
var _objects = require("./objects");

@@ -151,2 +138,15 @@

var _timeout = require("./timeout");
Object.keys(_timeout).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _timeout[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _timeout[key];
}
});
});
var _verifyMerkleBranch = require("./verifyMerkleBranch");

@@ -153,0 +153,0 @@

@@ -0,6 +1,17 @@

import { Json } from "@chainsafe/ssz";
import { format } from "winston";
import { ILoggerOptions } from "./interface";
import { Context, ILoggerOptions } from "./interface";
declare type Format = ReturnType<typeof format.combine>;
export declare function getFormat(opts: ILoggerOptions): Format;
/**
* Extract stack property from context to allow appending at the end of the log
*/
export declare function printStackTraceLast(context?: Context | Error): string;
/**
* Extract 'stack' from Json-ified error recursively.
* Mutates the `json` argument deleting all 'stack' properties.
* `json` argument must not contain circular properties, which should be guaranteed by `toJson()`
*/
export declare function extractStackTraceFromJson(json: Json, stackTraces?: string[]): string[];
export {};
//# sourceMappingURL=format.d.ts.map

@@ -7,2 +7,4 @@ "use strict";

exports.getFormat = getFormat;
exports.printStackTraceLast = printStackTraceLast;
exports.extractStackTraceFromJson = extractStackTraceFromJson;

@@ -13,6 +15,2 @@ var _winston = require("winston");

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function getFormat(opts) {

@@ -69,10 +67,6 @@ switch (opts.format) {

const json = (0, _json.toJson)(context);
const stackTraces = extractStackTraceFromJson(json);
if (typeof json === "object" && json !== null && !Array.isArray(json) && json.stack) {
const {
stack
} = json,
errJsonData = _objectWithoutProperties(json, ["stack"]);
return "".concat((0, _json.toString)(errJsonData), " \n").concat((0, _json.toString)(stack));
if (stackTraces.length > 0) {
return [(0, _json.toString)(json), ...stackTraces].join("\n");
} else {

@@ -82,2 +76,28 @@ return (0, _json.toString)(json);

}
/**
* Extract 'stack' from Json-ified error recursively.
* Mutates the `json` argument deleting all 'stack' properties.
* `json` argument must not contain circular properties, which should be guaranteed by `toJson()`
*/
function extractStackTraceFromJson(json, stackTraces = []) {
if (typeof json === "object" && json !== null && !Array.isArray(json)) {
let stack = null;
for (const [key, value] of Object.entries(json)) {
if (key === "stack" && typeof value === "string") {
stack = value;
delete json[key];
} else {
extractStackTraceFromJson(value, stackTraces);
}
} // Push stack trace last so nested errors come first
if (stack) stackTraces.push(stack);
}
return stackTraces;
}
//# sourceMappingURL=format.js.map

@@ -1,4 +0,1 @@

/**
* @module objects
*/
export declare function isPlainObject(o: any): boolean;

@@ -10,2 +7,3 @@ export declare function mapValues<T, R>(obj: {

};
export declare function objectToExpectedCase(obj: Record<string, unknown>, expectedCase?: "snake" | "camel"): Record<string, unknown>;
//# sourceMappingURL=objects.d.ts.map

@@ -8,3 +8,6 @@ "use strict";

exports.mapValues = mapValues;
exports.objectToExpectedCase = objectToExpectedCase;
var _utils = require("@chainsafe/ssz/lib/backings/utils");
/**

@@ -44,2 +47,32 @@ * @module objects

}
function objectToExpectedCase(obj, expectedCase = "camel") {
if (Array.isArray(obj)) {
const newArr = [];
for (let i = 0; i < obj.length; i++) {
newArr[i] = objectToExpectedCase(obj[i], expectedCase);
}
return newArr;
}
if (Object(obj) === obj) {
const newObj = {};
for (const name of Object.getOwnPropertyNames(obj)) {
const newName = (0, _utils.toExpectedCase)(name, expectedCase);
if (newName !== name && obj.hasOwnProperty(newName)) {
throw new Error("object already has a ".concat(newName, " property"));
}
newObj[newName] = objectToExpectedCase(obj[name], expectedCase);
}
return newObj;
}
return obj;
}
//# sourceMappingURL=objects.js.map

@@ -13,6 +13,6 @@ "use strict";

var _misc = require("../misc");
var _objects = require("../objects");
function loadYaml(yaml) {
return (0, _misc.objectToExpectedCase)((0, _jsYaml.load)(yaml, {
return (0, _objects.objectToExpectedCase)((0, _jsYaml.load)(yaml, {
schema: _schema.schema

@@ -19,0 +19,0 @@ }));

@@ -14,3 +14,3 @@ {

},
"version": "0.13.0",
"version": "0.14.0",
"main": "lib/index.js",

@@ -43,2 +43,3 @@ "files": [

"abort-controller": "^3.0.0",
"any-signal": "2.1.1",
"bigint-buffer": "^1.1.5",

@@ -62,3 +63,3 @@ "chalk": "^2.4.2",

],
"gitHead": "739f164b086dab2584b7a55d5bdeb69071542a75"
"gitHead": "9652b089838480b801ca9d9ff3ca0abda0df587b"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc