@typeberry/convert 0.4.1-bb6dbac → 0.4.1-c2b0fdd
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/index.js +28 -19
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -4133,8 +4133,7 @@ class InfoConsoleTransport extends ConsoleTransport {
|
|
|
4133
4133
|
}
|
|
4134
4134
|
}
|
|
4135
4135
|
|
|
4136
|
-
;// CONCATENATED MODULE: ./packages/core/logger/
|
|
4137
|
-
|
|
4136
|
+
;// CONCATENATED MODULE: ./packages/core/logger/logger.ts
|
|
4138
4137
|
|
|
4139
4138
|
|
|
4140
4139
|
const DEFAULT_OPTIONS = {
|
|
@@ -4175,13 +4174,13 @@ class Logger {
|
|
|
4175
4174
|
*
|
|
4176
4175
|
* Changing the options affects all previously created loggers.
|
|
4177
4176
|
*/
|
|
4178
|
-
static configureAllFromOptions(options) {
|
|
4177
|
+
static configureAllFromOptions(options, createTransport = ConsoleTransport.create) {
|
|
4179
4178
|
// find minimal level to optimise logging in case
|
|
4180
4179
|
// we don't care about low-level logs.
|
|
4181
4180
|
const minimalLevel = Array.from(options.modules.values()).reduce((level, modLevel) => {
|
|
4182
4181
|
return level < modLevel ? level : modLevel;
|
|
4183
4182
|
}, options.defaultLevel);
|
|
4184
|
-
const transport =
|
|
4183
|
+
const transport = createTransport(minimalLevel, options);
|
|
4185
4184
|
// set the global config
|
|
4186
4185
|
GLOBAL_CONFIG.options = options;
|
|
4187
4186
|
GLOBAL_CONFIG.transport = transport;
|
|
@@ -4207,8 +4206,11 @@ class Logger {
|
|
|
4207
4206
|
}
|
|
4208
4207
|
getLevelAndName() {
|
|
4209
4208
|
if (this.cachedLevelAndName === undefined) {
|
|
4210
|
-
|
|
4211
|
-
|
|
4209
|
+
// since we pad module name for better alignment, we need to
|
|
4210
|
+
// trim it for the lookup
|
|
4211
|
+
const moduleTrimmed = this.moduleName.trim();
|
|
4212
|
+
const level = findLevel(this.config.options, moduleTrimmed);
|
|
4213
|
+
const shortName = moduleTrimmed.replace(this.config.options.workingDir, "");
|
|
4212
4214
|
this.cachedLevelAndName = [level, shortName];
|
|
4213
4215
|
}
|
|
4214
4216
|
return this.cachedLevelAndName;
|
|
@@ -4239,6 +4241,12 @@ class Logger {
|
|
|
4239
4241
|
}
|
|
4240
4242
|
}
|
|
4241
4243
|
|
|
4244
|
+
;// CONCATENATED MODULE: ./packages/core/logger/index.ts
|
|
4245
|
+
|
|
4246
|
+
|
|
4247
|
+
|
|
4248
|
+
|
|
4249
|
+
|
|
4242
4250
|
;// CONCATENATED MODULE: ./packages/core/utils/env.ts
|
|
4243
4251
|
const env = typeof process === "undefined" ? {} : process.env;
|
|
4244
4252
|
|
|
@@ -4339,6 +4347,15 @@ class Compatibility {
|
|
|
4339
4347
|
function isBrowser() {
|
|
4340
4348
|
return typeof process === "undefined" || typeof process.abort === "undefined";
|
|
4341
4349
|
}
|
|
4350
|
+
/**
|
|
4351
|
+
* Get current time in milliseconds (works in both Node and browser).
|
|
4352
|
+
*
|
|
4353
|
+
* Node.js implementation converts hrtime bigint nanoseconds to milliseconds.
|
|
4354
|
+
* This is safe because dividing nanoseconds by 1_000_000 yields milliseconds,
|
|
4355
|
+
* which remain well below Number.MAX_SAFE_INTEGER for practical runtimes
|
|
4356
|
+
* (would take ~285 years to overflow).
|
|
4357
|
+
*/
|
|
4358
|
+
const now = isBrowser() ? () => performance.now() : () => Number(process.hrtime.bigint() / 1000000n);
|
|
4342
4359
|
/**
|
|
4343
4360
|
* A function to perform runtime assertions.
|
|
4344
4361
|
*
|
|
@@ -4427,19 +4444,10 @@ function debug_inspect(val) {
|
|
|
4427
4444
|
return v;
|
|
4428
4445
|
}
|
|
4429
4446
|
/** Utility function to measure time taken for some operation [ms]. */
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
}
|
|
4435
|
-
: (id) => {
|
|
4436
|
-
const start = process.hrtime.bigint();
|
|
4437
|
-
return () => {
|
|
4438
|
-
const tookNano = process.hrtime.bigint() - start;
|
|
4439
|
-
const tookMilli = Number(tookNano / 1000000n).toFixed(2);
|
|
4440
|
-
return `${id} took ${tookMilli}ms`;
|
|
4441
|
-
};
|
|
4442
|
-
};
|
|
4447
|
+
function measure(id) {
|
|
4448
|
+
const start = now();
|
|
4449
|
+
return () => `${id} took ${(now() - start).toFixed(2)}ms`;
|
|
4450
|
+
}
|
|
4443
4451
|
/** A class that adds `toString` method that prints all properties of an object. */
|
|
4444
4452
|
class WithDebug {
|
|
4445
4453
|
toString() {
|
|
@@ -4843,6 +4851,7 @@ function isResult(x) {
|
|
|
4843
4851
|
|
|
4844
4852
|
|
|
4845
4853
|
|
|
4854
|
+
|
|
4846
4855
|
// EXTERNAL MODULE: ./node_modules/minimist/index.js
|
|
4847
4856
|
var minimist = __nccwpck_require__(595);
|
|
4848
4857
|
var minimist_default = /*#__PURE__*/__nccwpck_require__.n(minimist);
|