@typeberry/convert 0.4.1-bb6dbac → 0.4.1-d3b18b3

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.
Files changed (3) hide show
  1. package/index.js +14 -13
  2. package/index.js.map +1 -1
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -4339,6 +4339,15 @@ class Compatibility {
4339
4339
  function isBrowser() {
4340
4340
  return typeof process === "undefined" || typeof process.abort === "undefined";
4341
4341
  }
4342
+ /**
4343
+ * Get current time in milliseconds (works in both Node and browser).
4344
+ *
4345
+ * Node.js implementation converts hrtime bigint nanoseconds to milliseconds.
4346
+ * This is safe because dividing nanoseconds by 1_000_000 yields milliseconds,
4347
+ * which remain well below Number.MAX_SAFE_INTEGER for practical runtimes
4348
+ * (would take ~285 years to overflow).
4349
+ */
4350
+ const now = isBrowser() ? () => performance.now() : () => Number(process.hrtime.bigint() / 1000000n);
4342
4351
  /**
4343
4352
  * A function to perform runtime assertions.
4344
4353
  *
@@ -4427,19 +4436,10 @@ function debug_inspect(val) {
4427
4436
  return v;
4428
4437
  }
4429
4438
  /** Utility function to measure time taken for some operation [ms]. */
4430
- const measure = isBrowser()
4431
- ? (id) => {
4432
- const start = performance.now();
4433
- return () => `${id} took ${performance.now() - start}ms`;
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
- };
4439
+ function measure(id) {
4440
+ const start = now();
4441
+ return () => `${id} took ${(now() - start).toFixed(2)}ms`;
4442
+ }
4443
4443
  /** A class that adds `toString` method that prints all properties of an object. */
4444
4444
  class WithDebug {
4445
4445
  toString() {
@@ -4843,6 +4843,7 @@ function isResult(x) {
4843
4843
 
4844
4844
 
4845
4845
 
4846
+
4846
4847
  // EXTERNAL MODULE: ./node_modules/minimist/index.js
4847
4848
  var minimist = __nccwpck_require__(595);
4848
4849
  var minimist_default = /*#__PURE__*/__nccwpck_require__.n(minimist);