@chainsafe/lodestar-utils
Advanced tools
Comparing version 0.12.0 to 0.13.0
@@ -13,2 +13,5 @@ import { Json } from "@chainsafe/ssz"; | ||
}; | ||
/** | ||
* Get the metadata and the stacktrace for the error. | ||
*/ | ||
toObject(): { | ||
@@ -15,0 +18,0 @@ [key: string]: Json; |
@@ -29,3 +29,7 @@ "use strict"; | ||
} | ||
/** | ||
* Get the metadata and the stacktrace for the error. | ||
*/ | ||
toObject() { | ||
@@ -32,0 +36,0 @@ return _objectSpread(_objectSpread({}, this.getMetadata()), {}, { |
@@ -24,3 +24,3 @@ "use strict"; | ||
length: validatorCount | ||
}, (_, i) => { | ||
}, (ignored, i) => { | ||
return interopSecretKey(i); | ||
@@ -27,0 +27,0 @@ }); |
@@ -84,3 +84,3 @@ "use strict"; | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/naming-convention | ||
@@ -87,0 +87,0 @@ |
@@ -34,5 +34,7 @@ "use strict"; | ||
function jsonLogFormat(opts) { | ||
return _winston.format.combine(...(opts.hideTimestamp ? [] : [_winston.format.timestamp()]), (0, _winston.format)(_info => { | ||
return _winston.format.combine(...(opts.hideTimestamp ? [] : [_winston.format.timestamp()]), // eslint-disable-next-line @typescript-eslint/naming-convention | ||
(0, _winston.format)(_info => { | ||
const info = _info; | ||
info.context = (0, _json.toJson)(info.context); | ||
info.error = (0, _json.toJson)(info.error); | ||
return info; | ||
@@ -44,3 +46,3 @@ })(), _winston.format.json()); | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/naming-convention | ||
@@ -53,7 +55,3 @@ | ||
const infoPad = paddingBetweenInfo - infoString.length; | ||
const { | ||
context, | ||
stack | ||
} = splitContextAndStackTrace(info.context); | ||
const logParts = [info.timestamp, "[".concat(infoString.toUpperCase(), "]"), "".concat(info.level.padStart(infoPad), ":"), info.message, context, info.durationMs && " - duration=".concat(info.durationMs, "ms"), stack && "\n".concat(stack)]; | ||
const logParts = [info.timestamp, "[".concat(infoString.toUpperCase(), "]"), "".concat(info.level.padStart(infoPad), ":"), info.message, info.context ? printStackTraceLast(info.context) : undefined, info.error ? printStackTraceLast(info.error) : undefined, info.durationMs && " - duration=".concat(info.durationMs, "ms")]; | ||
return logParts.filter(s => s).join(" "); | ||
@@ -66,5 +64,5 @@ } | ||
function splitContextAndStackTrace(context) { | ||
function printStackTraceLast(context) { | ||
if (!context) { | ||
return {}; | ||
return ""; | ||
} | ||
@@ -80,12 +78,7 @@ | ||
return { | ||
context: (0, _json.toString)(errJsonData), | ||
stack: (0, _json.toString)(stack) | ||
}; | ||
return "".concat((0, _json.toString)(errJsonData), " \n").concat((0, _json.toString)(stack)); | ||
} else { | ||
return { | ||
context: (0, _json.toString)(json) | ||
}; | ||
return (0, _json.toString)(json); | ||
} | ||
} | ||
//# sourceMappingURL=format.js.map |
@@ -35,12 +35,13 @@ /** | ||
} | Context[]; | ||
export declare type LogHandler = (message: string, context?: Context, error?: Error) => void; | ||
export interface ILogger { | ||
level: LogLevel; | ||
silent: boolean; | ||
error(message: string, context?: Context | Error): void; | ||
warn(message: string, context?: Context | Error): void; | ||
info(message: string, context?: Context): void; | ||
important(message: string, context?: Context): void; | ||
verbose(message: string, context?: Context): void; | ||
debug(message: string, context?: Context): void; | ||
silly(message: string, context?: Context): void; | ||
error: LogHandler; | ||
warn: LogHandler; | ||
info: LogHandler; | ||
important: LogHandler; | ||
verbose: LogHandler; | ||
debug: LogHandler; | ||
silly: LogHandler; | ||
profile(message: string, option?: { | ||
@@ -47,0 +48,0 @@ level: string; |
@@ -11,3 +11,4 @@ "use strict"; | ||
*/ | ||
let LogLevel; | ||
let LogLevel; // eslint-disable-next-line @typescript-eslint/naming-convention | ||
exports.LogLevel = LogLevel; | ||
@@ -14,0 +15,0 @@ |
@@ -15,9 +15,9 @@ /** | ||
constructor(options?: Partial<ILoggerOptions>, transports?: TransportStream[]); | ||
debug(message: string, context?: Context): void; | ||
info(message: string, context?: Context): void; | ||
important(message: string, context?: Context): void; | ||
error(message: string, context?: Context | Error): void; | ||
warn(message: string, context?: Context | Error): void; | ||
verbose(message: string, context?: Context): void; | ||
silly(message: string, context?: Context): void; | ||
error(message: string, context?: Context, error?: Error): void; | ||
warn(message: string, context?: Context, error?: Error): void; | ||
info(message: string, context?: Context, error?: Error): void; | ||
important(message: string, context?: Context, error?: Error): void; | ||
verbose(message: string, context?: Context, error?: Error): void; | ||
debug(message: string, context?: Context, error?: Error): void; | ||
silly(message: string, context?: Context, error?: Error): void; | ||
profile(message: string, option?: { | ||
@@ -24,0 +24,0 @@ level: string; |
@@ -71,28 +71,28 @@ "use strict"; | ||
debug(message, context) { | ||
this.createLogEntry(_interface.LogLevel.debug, message, context); | ||
error(message, context, error) { | ||
this.createLogEntry(_interface.LogLevel.error, message, context, error); | ||
} | ||
info(message, context) { | ||
this.createLogEntry(_interface.LogLevel.info, message, context); | ||
warn(message, context, error) { | ||
this.createLogEntry(_interface.LogLevel.warn, message, context, error); | ||
} | ||
important(message, context) { | ||
this.createLogEntry(_interface.LogLevel.info, _chalk.default.red(message), context); | ||
info(message, context, error) { | ||
this.createLogEntry(_interface.LogLevel.info, message, context, error); | ||
} | ||
error(message, context) { | ||
this.createLogEntry(_interface.LogLevel.error, message, context); | ||
important(message, context, error) { | ||
this.createLogEntry(_interface.LogLevel.info, _chalk.default.red(message), context, error); | ||
} | ||
warn(message, context) { | ||
this.createLogEntry(_interface.LogLevel.warn, message, context); | ||
verbose(message, context, error) { | ||
this.createLogEntry(_interface.LogLevel.verbose, message, context, error); | ||
} | ||
verbose(message, context) { | ||
this.createLogEntry(_interface.LogLevel.verbose, message, context); | ||
debug(message, context, error) { | ||
this.createLogEntry(_interface.LogLevel.debug, message, context, error); | ||
} | ||
silly(message, context) { | ||
this.createLogEntry(_interface.LogLevel.silly, message, context); | ||
silly(message, context, error) { | ||
this.createLogEntry(_interface.LogLevel.silly, message, context, error); | ||
} | ||
@@ -149,3 +149,3 @@ | ||
createLogEntry(level, message, context) { | ||
createLogEntry(level, message, context, error) { | ||
//don't propagate if silenced or message level is more detailed than logger level | ||
@@ -157,3 +157,4 @@ if (this.silent || this.winston.levels[level] > this.winston.levels[this._level]) { | ||
this.winston[level](message, { | ||
context | ||
context, | ||
error | ||
}); | ||
@@ -160,0 +161,0 @@ } |
@@ -1,2 +0,2 @@ | ||
export declare function objectToExpectedCase(obj: Record<string, unknown>, expectedCase?: "snake" | "camel"): object; | ||
export declare function objectToExpectedCase(obj: Record<string, unknown>, expectedCase?: "snake" | "camel"): Record<string, unknown>; | ||
//# sourceMappingURL=misc.d.ts.map |
@@ -12,3 +12,3 @@ "use strict"; | ||
if (Object(obj) === obj) { | ||
Object.getOwnPropertyNames(obj).forEach(name => { | ||
for (const name of Object.getOwnPropertyNames(obj)) { | ||
const newName = (0, _utils.toExpectedCase)(name, expectedCase); | ||
@@ -26,3 +26,3 @@ | ||
objectToExpectedCase(obj[newName], expectedCase); | ||
}); | ||
} | ||
} else if (Array.isArray(obj)) { | ||
@@ -29,0 +29,0 @@ for (let i = 0; i < obj.length; i++) { |
@@ -5,3 +5,3 @@ /** | ||
export declare function isPlainObject(o: any): boolean; | ||
export declare function mapValues<T, R>(obj: object | { | ||
export declare function mapValues<T, R>(obj: { | ||
[key: string]: T; | ||
@@ -8,0 +8,0 @@ }, iteratee: (value: T, key: string) => R): { |
@@ -1,3 +0,3 @@ | ||
export declare function loadYaml(yaml: string): object; | ||
export declare function loadYaml(yaml: string): Record<string, unknown>; | ||
export declare function dumpYaml(yaml: any): string; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -144,11 +144,14 @@ "use strict"; | ||
if (value.indexOf(":") !== -1) { | ||
value.split(":").forEach(function (v) { | ||
for (const v of value.split(":")) { | ||
digits.unshift(parseInt(v, 10)); | ||
}); | ||
} | ||
value = BigInt(0); | ||
base = BigInt(1); | ||
digits.forEach(function (d) { | ||
for (const d of digits) { | ||
value = (BigInt(value) + BigInt(base)) * BigInt(d); | ||
base = BigInt(base) * BigInt(60); | ||
}); | ||
} | ||
return value * BigInt(sign); | ||
@@ -155,0 +158,0 @@ } |
@@ -14,3 +14,3 @@ { | ||
}, | ||
"version": "0.12.0", | ||
"version": "0.13.0", | ||
"main": "lib/index.js", | ||
@@ -40,3 +40,3 @@ "files": [ | ||
"dependencies": { | ||
"@chainsafe/bls": "5.0.1", | ||
"@chainsafe/bls": "5.1.0", | ||
"@chainsafe/ssz": "^0.6.13", | ||
@@ -62,3 +62,3 @@ "abort-controller": "^3.0.0", | ||
], | ||
"gitHead": "5162c9136854c8c0b3816bb7622468ee0f3cc61b" | ||
"gitHead": "739f164b086dab2584b7a55d5bdeb69071542a75" | ||
} |
@@ -8,4 +8,6 @@ # lodestar-utils | ||
A suite of various utility functions/classes that are used across the various `lodestar-*` monorepo packages. | ||
## License | ||
Apache-2.0 [ChainSafe Systems](https://chainsafe.io) |
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
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
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
118717
1381
13
+ Added@chainsafe/bls@5.1.0(transitive)
- Removed@chainsafe/bls@5.0.1(transitive)
Updated@chainsafe/bls@5.1.0