wpilog-parser 3.2.1 → 4.0.0

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/README.md CHANGED
@@ -26,7 +26,7 @@ for (const record of parseDataLog(bytes)) {
26
26
  Use `readRecords()` and `decodeRecords()` separately when you need access to raw records or want to transform the record stream before decoding it. Both approaches produce the same decoded records.
27
27
 
28
28
  Struct schemas are compiled lazily into reusable decoders, and struct payloads are returned as plain objects, including nested structs and arrays of structs.
29
- In environments where Content Security Policy blocks runtime code generation, structs are decoded by the interpreter automatically.
29
+ In environments where Content Security Policy blocks runtime code generation, decoding falls back to a CSP-safe implementation.
30
30
 
31
31
  A summary of the full API is available in [wpilog-parser.api.md](https://github.com/jonahsnider/wpilog-parser/blob/main/packages/wpilog-parser/etc/wpilog-parser.api.md).
32
32
 
@@ -201,18 +201,14 @@ function readVarInt(view, offset, length) {
201
201
  }
202
202
  function readTimestamp(view, offset, length) {
203
203
  switch (length) {
204
- case 1: return BigInt(view.getUint8(offset));
205
- case 2: return BigInt(view.getUint16(offset, true));
206
- case 3: return BigInt(view.getUint16(offset, true) + view.getUint8(offset + 2) * 2 ** 16);
207
- case 4: return BigInt(view.getUint32(offset, true));
208
- case 5: return BigInt(view.getUint32(offset, true) + view.getUint8(offset + 4) * 2 ** 32);
209
- case 6: return BigInt(view.getUint32(offset, true) + view.getUint16(offset + 4, true) * 2 ** 32);
210
- case 7: {
211
- const low = view.getUint32(offset, true);
212
- const high = view.getUint16(offset + 4, true) + view.getUint8(offset + 6) * 2 ** 16;
213
- return BigInt(high) << 32n | BigInt(low);
214
- }
215
- case 8: return view.getBigUint64(offset, true);
204
+ case 1: return view.getUint8(offset);
205
+ case 2: return view.getUint16(offset, true);
206
+ case 3: return view.getUint16(offset, true) + view.getUint8(offset + 2) * 2 ** 16;
207
+ case 4: return view.getUint32(offset, true);
208
+ case 5: return view.getUint32(offset, true) + view.getUint8(offset + 4) * 2 ** 32;
209
+ case 6: return view.getUint32(offset, true) + view.getUint16(offset + 4, true) * 2 ** 32;
210
+ case 7: return view.getUint32(offset, true) + (view.getUint16(offset + 4, true) + view.getUint8(offset + 6) * 2 ** 16) * 2 ** 32;
211
+ case 8: return view.getUint32(offset, true) + view.getUint32(offset + 4, true) * 2 ** 32;
216
212
  default: throw new RangeError(`Invalid timestamp length ${length}`);
217
213
  }
218
214
  }
@@ -222,7 +218,7 @@ var RecordCursor = class {
222
218
  view;
223
219
  header;
224
220
  entryId = 0;
225
- timestamp = 0n;
221
+ timestamp = 0;
226
222
  payloadOffset = 0;
227
223
  payloadSize = 0;
228
224
  offset;
@@ -391,6 +387,18 @@ const TEXT_DECODER = new TextDecoder();
391
387
  const STRUCT_PREFIX = "struct:";
392
388
  const STRUCT_ARRAY_SUFFIX = "[]";
393
389
  const STRUCT_SCHEMA_NAME_PREFIX = "/.schema/struct:";
390
+ /**
391
+ * Build a non-struct data record as one flat object literal.
392
+ * Struct records are built inline with the same field order plus `structName`.
393
+ */
394
+ function dataRecord(entry, timestamp, type, payload) {
395
+ return {
396
+ entry,
397
+ timestamp,
398
+ type,
399
+ payload
400
+ };
401
+ }
394
402
  function byteToBoolean(byte) {
395
403
  switch (byte) {
396
404
  case 0: return false;
@@ -404,8 +412,8 @@ function normalizeEntryName(rawName) {
404
412
  }
405
413
  var RecordDecoder = class {
406
414
  delayedRecords = [];
407
- context = /* @__PURE__ */ new Map();
408
- recordContexts = /* @__PURE__ */ new WeakMap();
415
+ entries = /* @__PURE__ */ new Map();
416
+ recordEntries = /* @__PURE__ */ new WeakMap();
409
417
  structDecodeQueue;
410
418
  structRegistry;
411
419
  options;
@@ -413,29 +421,25 @@ var RecordDecoder = class {
413
421
  this.options = options;
414
422
  this.structDecodeQueue = new StructDecodeQueue((_structName, queuedRecords) => {
415
423
  for (const raw of queuedRecords) {
416
- const context = this.recordContexts.get(raw);
417
- if (!context) continue;
418
- const { entryType, name, metadata } = context;
419
- const structName = entryType.slice(7);
420
- const base = {
421
- entryId: raw.entryId,
422
- timestamp: raw.timestamp,
423
- name,
424
- metadata,
425
- structName
426
- };
427
- if (entryType.endsWith(STRUCT_ARRAY_SUFFIX)) {
424
+ const entry = this.recordEntries.get(raw);
425
+ if (!entry) continue;
426
+ const structName = entry.type.slice(7);
427
+ if (entry.type.endsWith(STRUCT_ARRAY_SUFFIX)) {
428
428
  const payload = this.structRegistry.decodeArray(structName, raw.payload);
429
429
  if (typeof payload !== "string") this.delayedRecords.push({
430
- ...base,
430
+ entry,
431
+ timestamp: raw.timestamp,
431
432
  type: RecordType.StructArray,
433
+ structName,
432
434
  payload
433
435
  });
434
436
  } else {
435
437
  const payload = this.structRegistry.decode(structName, raw.payload);
436
438
  if (typeof payload !== "string") this.delayedRecords.push({
437
- ...base,
439
+ entry,
440
+ timestamp: raw.timestamp,
438
441
  type: RecordType.Struct,
442
+ structName,
439
443
  payload
440
444
  });
441
445
  }
@@ -446,18 +450,19 @@ var RecordDecoder = class {
446
450
  decodeControl(entryId, timestamp, payload) {
447
451
  switch (payload.controlRecordType) {
448
452
  case ControlRecordType.Start:
449
- this.context.set(payload.entryId, {
453
+ this.entries.set(payload.entryId, {
454
+ entryId: payload.entryId,
450
455
  name: normalizeEntryName(payload.entryName),
451
- entryType: payload.entryType,
456
+ type: payload.entryType,
452
457
  metadata: payload.entryMetadata
453
458
  });
454
459
  break;
455
460
  case ControlRecordType.Finish:
456
- this.context.delete(payload.entryId);
461
+ this.entries.delete(payload.entryId);
457
462
  break;
458
463
  case ControlRecordType.SetMetadata: {
459
- const existing = this.context.get(payload.entryId);
460
- if (existing) this.context.set(payload.entryId, {
464
+ const existing = this.entries.get(payload.entryId);
465
+ if (existing) this.entries.set(payload.entryId, {
461
466
  ...existing,
462
467
  metadata: payload.entryMetadata
463
468
  });
@@ -472,38 +477,16 @@ var RecordDecoder = class {
472
477
  };
473
478
  }
474
479
  decodeData(entryId, timestamp, bytes, view, payloadOffset, payloadSize) {
475
- const context = this.context.get(entryId);
476
- if (!context) {
480
+ const entry = this.entries.get(entryId);
481
+ if (!entry) {
477
482
  if (this.options.strict) throw diagnostics.WPILOG_R0006({ entryId });
478
483
  return;
479
484
  }
480
- const base = {
481
- entryId,
482
- timestamp,
483
- name: context.name,
484
- metadata: context.metadata
485
- };
486
- switch (context.entryType) {
487
- case "boolean": return {
488
- ...base,
489
- type: RecordType.Boolean,
490
- payload: byteToBoolean(view.getUint8(payloadOffset))
491
- };
492
- case "int64": return {
493
- ...base,
494
- type: RecordType.Int64,
495
- payload: view.getBigInt64(payloadOffset, true)
496
- };
497
- case "float": return {
498
- ...base,
499
- type: RecordType.Float,
500
- payload: view.getFloat32(payloadOffset, true)
501
- };
502
- case "double": return {
503
- ...base,
504
- type: RecordType.Double,
505
- payload: view.getFloat64(payloadOffset, true)
506
- };
485
+ switch (entry.type) {
486
+ case "boolean": return dataRecord(entry, timestamp, RecordType.Boolean, byteToBoolean(view.getUint8(payloadOffset)));
487
+ case "int64": return dataRecord(entry, timestamp, RecordType.Int64, view.getBigInt64(payloadOffset, true));
488
+ case "float": return dataRecord(entry, timestamp, RecordType.Float, view.getFloat32(payloadOffset, true));
489
+ case "double": return dataRecord(entry, timestamp, RecordType.Double, view.getFloat64(payloadOffset, true));
507
490
  }
508
491
  const payload = payloadOffset === 0 && payloadSize === bytes.byteLength ? bytes : bytes.subarray(payloadOffset, payloadOffset + payloadSize);
509
492
  const raw = {
@@ -511,9 +494,8 @@ var RecordDecoder = class {
511
494
  timestamp,
512
495
  payload
513
496
  };
514
- const payloadView = new DataView(payload.buffer, payload.byteOffset, payload.byteLength);
515
- const decoded = decodeNonScalarPayload(raw, context.entryType, context.name, context.metadata, payloadView, this.structRegistry, this.structDecodeQueue);
516
- if (!decoded) this.recordContexts.set(raw, context);
497
+ const decoded = decodeNonScalarPayload(raw, entry, new DataView(payload.buffer, payload.byteOffset, payload.byteLength), this.structRegistry, this.structDecodeQueue);
498
+ if (!decoded) this.recordEntries.set(raw, entry);
517
499
  return decoded;
518
500
  }
519
501
  };
@@ -571,54 +553,30 @@ function* parseDataLog(input, options = { strict: false }) {
571
553
  * Decode non-scalar payloads that require a byte slice or payload-local view.
572
554
  * Fixed-width scalar types return from {@link RecordDecoder#decodeData} before this function so their payloads can be read directly from the input buffer.
573
555
  */
574
- function decodeNonScalarPayload(raw, entryType, name, metadata, view, structRegistry, structDecodeQueue) {
575
- const base = {
576
- entryId: raw.entryId,
577
- timestamp: raw.timestamp,
578
- name,
579
- metadata
580
- };
556
+ function decodeNonScalarPayload(raw, entry, view, structRegistry, structDecodeQueue) {
557
+ const { timestamp } = raw;
558
+ const { type: entryType, name } = entry;
581
559
  switch (entryType) {
582
- case "string": return {
583
- ...base,
584
- type: RecordType.String,
585
- payload: TEXT_DECODER.decode(raw.payload)
586
- };
560
+ case "string": return dataRecord(entry, timestamp, RecordType.String, TEXT_DECODER.decode(raw.payload));
587
561
  case "boolean[]": {
588
562
  const payload = [];
589
563
  for (let i = 0; i < raw.payload.byteLength; i++) payload.push(byteToBoolean(view.getUint8(i)));
590
- return {
591
- ...base,
592
- type: RecordType.BooleanArray,
593
- payload
594
- };
564
+ return dataRecord(entry, timestamp, RecordType.BooleanArray, payload);
595
565
  }
596
566
  case "int64[]": {
597
567
  const payload = [];
598
568
  for (let i = 0; i < raw.payload.byteLength; i += 8) payload.push(view.getBigUint64(i, true));
599
- return {
600
- ...base,
601
- type: RecordType.Int64Array,
602
- payload
603
- };
569
+ return dataRecord(entry, timestamp, RecordType.Int64Array, payload);
604
570
  }
605
571
  case "float[]": {
606
572
  const payload = [];
607
573
  for (let i = 0; i < raw.payload.byteLength; i += 4) payload.push(view.getFloat32(i, true));
608
- return {
609
- ...base,
610
- type: RecordType.FloatArray,
611
- payload
612
- };
574
+ return dataRecord(entry, timestamp, RecordType.FloatArray, payload);
613
575
  }
614
576
  case "double[]": {
615
577
  const payload = [];
616
578
  for (let i = 0; i < raw.payload.byteLength; i += 8) payload.push(view.getFloat64(i, true));
617
- return {
618
- ...base,
619
- type: RecordType.DoubleArray,
620
- payload
621
- };
579
+ return dataRecord(entry, timestamp, RecordType.DoubleArray, payload);
622
580
  }
623
581
  case "string[]": {
624
582
  const payload = [];
@@ -632,21 +590,13 @@ function decodeNonScalarPayload(raw, entryType, name, metadata, view, structRegi
632
590
  offset.advance(stringLength);
633
591
  payload.push(string);
634
592
  }
635
- return {
636
- ...base,
637
- type: RecordType.StringArray,
638
- payload
639
- };
593
+ return dataRecord(entry, timestamp, RecordType.StringArray, payload);
640
594
  }
641
595
  case "structschema": {
642
596
  const structName = name.slice(name.indexOf(STRUCT_SCHEMA_NAME_PREFIX) + 16);
643
597
  const payload = TEXT_DECODER.decode(raw.payload);
644
598
  structRegistry.register(structName, payload);
645
- return {
646
- ...base,
647
- type: RecordType.String,
648
- payload
649
- };
599
+ return dataRecord(entry, timestamp, RecordType.String, payload);
650
600
  }
651
601
  default:
652
602
  if (entryType.startsWith(STRUCT_PREFIX)) {
@@ -658,7 +608,8 @@ function decodeNonScalarPayload(raw, entryType, name, metadata, view, structRegi
658
608
  return;
659
609
  }
660
610
  return {
661
- ...base,
611
+ entry,
612
+ timestamp,
662
613
  type: RecordType.StructArray,
663
614
  structName,
664
615
  payload: decoded
@@ -670,17 +621,14 @@ function decodeNonScalarPayload(raw, entryType, name, metadata, view, structRegi
670
621
  return;
671
622
  }
672
623
  return {
673
- ...base,
624
+ entry,
625
+ timestamp,
674
626
  type: RecordType.Struct,
675
627
  structName,
676
628
  payload: decoded
677
629
  };
678
630
  }
679
- return {
680
- ...base,
681
- type: RecordType.Raw,
682
- payload: raw.payload
683
- };
631
+ return dataRecord(entry, timestamp, RecordType.Raw, new Uint8Array(raw.payload));
684
632
  }
685
633
  }
686
634
  // src/catalog.ts
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as readRecords, l as diagnostics, t as catalogEntries } from "./catalog-hof8DZhi.mjs";
2
+ import { a as readRecords, l as diagnostics, t as catalogEntries } from "./catalog-BPg-SswK.mjs";
3
3
  import { Diagnostic, formatDiagnostic } from "nostics";
4
4
  import { RootCommand, script } from "@bomb.sh/tab";
5
5
  import { boolean, command, commandsInfo, positional, run } from "@drizzle-team/brocli";
@@ -7,7 +7,7 @@ import oscStatus from "osc-status";
7
7
  import { readFile } from "node:fs/promises";
8
8
  import { encode } from "@toon-format/toon";
9
9
  // package.json
10
- var version = "3.2.1";
10
+ var version = "4.0.0";
11
11
  var description = "Read WPILib wpilog data log files in TypeScript & JavaScript";
12
12
  // src/cli/catalog.ts
13
13
  async function catalogFile(filePath) {
package/dist/index.d.mts CHANGED
@@ -35,11 +35,18 @@ type SetMetadataControlRecord = {
35
35
  };
36
36
  /** A control record payload (start, finish, or set metadata). */
37
37
  type ControlRecordPayload = StartControlRecord | FinishControlRecord | SetMetadataControlRecord;
38
+ /** An entry definition, from its Start control record and any later SetMetadata control records. */
39
+ type CatalogEntry = {
40
+ entryId: number;
41
+ name: string;
42
+ type: string;
43
+ metadata: string;
44
+ };
38
45
  /** A raw (undecoded) data log record from the binary format. */
39
46
  type RawRecord = {
40
47
  entryId: number;
41
48
  /** Timestamp in microseconds. */
42
- timestamp: bigint;
49
+ timestamp: number;
43
50
  payload: Uint8Array;
44
51
  };
45
52
  /** Discriminated union tag for decoded record types. */
@@ -62,7 +69,7 @@ export declare const RecordType: {
62
69
  export type RecordType = (typeof RecordType)[keyof typeof RecordType];
63
70
  /** A decoded data record (excludes control records). */
64
71
  type DataRecord = Extract<DecodedRecord, {
65
- name: string;
72
+ entry: CatalogEntry;
66
73
  }>;
67
74
  /** A decoded control record. */
68
75
  type ControlRecord = Extract<DecodedRecord, {
@@ -72,15 +79,18 @@ type ControlRecord = Extract<DecodedRecord, {
72
79
  export declare function isDataRecord(record: DecodedRecord): record is DataRecord;
73
80
  /** A decoded data log record. */
74
81
  type DecodedRecord = {
75
- entryId: number;
76
82
  /** Timestamp in microseconds. */
77
- timestamp: bigint;
83
+ timestamp: number;
78
84
  } & ({
85
+ entryId: number;
79
86
  type: typeof RecordType.Control;
80
87
  payload: ControlRecordPayload;
81
88
  } | ({
82
- name: string;
83
- metadata: string;
89
+ /**
90
+ * The entry this record belongs to.
91
+ * Records from the same entry share one object until a SetMetadata control record replaces it.
92
+ */
93
+ entry: CatalogEntry;
84
94
  } & ({
85
95
  type: typeof RecordType.Raw;
86
96
  payload: Uint8Array;
@@ -130,7 +140,7 @@ type ReadRecord = {
130
140
  } | {
131
141
  kind: 'control';
132
142
  entryId: number;
133
- timestamp: bigint;
143
+ timestamp: number;
134
144
  payload: ControlRecordPayload;
135
145
  } | {
136
146
  kind: 'data';
@@ -173,13 +183,6 @@ export declare function decodeRecords(records: Iterable<ReadRecord>, options?: D
173
183
  * {@link decodeRecords} while preserving the same output and strict-mode behavior.
174
184
  */
175
185
  export declare function parseDataLog(input: DataLogInput, options?: DecodeRecordsOptions): Generator<DecodedRecord>;
176
- /** An entry definition from the WPILOG catalog. */
177
- type CatalogEntry = {
178
- entryId: number;
179
- name: string;
180
- type: string;
181
- metadata: string;
182
- };
183
186
  /**
184
187
  * Collect all entry definitions from a WPILOG record stream.
185
188
  *
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as readRecords, c as isDataRecord, i as withStructDiagnostics, n as decodeRecords, o as ControlRecordType, r as parseDataLog, s as RecordType, t as catalogEntries } from "./catalog-hof8DZhi.mjs";
1
+ import { a as readRecords, c as isDataRecord, i as withStructDiagnostics, n as decodeRecords, o as ControlRecordType, r as parseDataLog, s as RecordType, t as catalogEntries } from "./catalog-BPg-SswK.mjs";
2
2
  import { KnownStructTypeName, parseStructSpecification as parseStructSpecification$1 } from "wpilib-struct";
3
3
  // src/struct/parse-struct.ts
4
4
  /** Parse a WPILib struct specification string into declarations. */
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.60.0"
8
+ "packageVersion": "7.60.1"
9
9
  }
10
10
  ]
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wpilog-parser",
3
- "version": "3.2.1",
3
+ "version": "4.0.0",
4
4
  "description": "Read WPILib wpilog data log files in TypeScript & JavaScript",
5
5
  "homepage": "https://github.com/jonahsnider/wpilog-parser#readme",
6
6
  "license": "MIT",
@@ -35,12 +35,12 @@
35
35
  "@toon-format/toon": "^4.1.1",
36
36
  "nostics": "^1.3.0",
37
37
  "osc-status": "^1.0.0",
38
- "wpilib-struct": "^1.0.1"
38
+ "wpilib-struct": "^1.0.2"
39
39
  },
40
40
  "devDependencies": {
41
- "@microsoft/api-extractor": "7.60.0",
42
- "vite-plus": "1.4.0",
43
- "vitest": "5.0.5"
41
+ "@microsoft/api-extractor": "7.60.1",
42
+ "vite-plus": "1.6.0",
43
+ "vitest": "5.1.0"
44
44
  },
45
45
  "tsdocMetadata": "./dist/tsdoc-metadata.json",
46
46
  "scripts": {
@@ -22,7 +22,7 @@ WPILOG is the binary log format used by logging libraries in the FRC ecosystem.
22
22
 
23
23
  ## Analyzing logs
24
24
 
25
- Use `parseDataLog` to parse DataLog bytes. Filter by `name` and narrow on `type`:
25
+ Use `parseDataLog` to parse DataLog bytes. Filter by `entry.name` and narrow on `type`:
26
26
 
27
27
  ```ts
28
28
  import { readFile } from 'node:fs/promises';
@@ -33,7 +33,7 @@ const bytes = await readFile('./example.wpilog');
33
33
  for (const record of parseDataLog(bytes)) {
34
34
  if (!isDataRecord(record)) continue;
35
35
 
36
- if (record.name === '/Robot/Intake/Voltage' && record.type === RecordType.Double) {
36
+ if (record.entry.name === '/Robot/Intake/Voltage' && record.type === RecordType.Double) {
37
37
  console.log(record.timestamp, record.payload);
38
38
  }
39
39
  }
@@ -45,9 +45,9 @@ for (const record of parseDataLog(bytes)) {
45
45
  import { parseDataLog, RecordType } from 'wpilog-parser';
46
46
 
47
47
  for (const record of parseDataLog(bytes)) {
48
- if (record.type === RecordType.Struct && record.name === '/Robot/Localization/EstimatedPose') {
48
+ if (record.type === RecordType.Struct && record.entry.name === '/Robot/Localization/EstimatedPose') {
49
49
  console.log(record.timestamp, record.payload);
50
- // 18688018n {
50
+ // 18688018 {
51
51
  // translation: { x: 10.289, y: 0.47 },
52
52
  // rotation: { value: 1.5707961072652017 },
53
53
  // }
@@ -74,7 +74,7 @@ When DriverStation logging is on, every WPILOG has these `boolean` entries:
74
74
  | `/DS:test` | `true` during test mode. |
75
75
  | `/DS:estop` | `true` if e-stopped. |
76
76
 
77
- The mode flags (`autonomous`, `test`) reflect what the DS _would_ run if enabled, so check `/DS:enabled` together with them. Timestamps are microseconds (`bigint`).
77
+ The mode flags (`autonomous`, `test`) reflect what the DS _would_ run if enabled, so check `/DS:enabled` together with them. Timestamps are microseconds (`number`).
78
78
 
79
79
  ### Tracking enable/mode durations
80
80
 
@@ -91,8 +91,8 @@ function modeOf(auto: boolean, test: boolean): Mode {
91
91
  let enabled = false;
92
92
  let auto = false;
93
93
  let test = false;
94
- let enabledSince: bigint | null = null;
95
- const totals = { auto: 0n, teleop: 0n, test: 0n };
94
+ let enabledSince: number | null = null;
95
+ const totals = { auto: 0, teleop: 0, test: 0 };
96
96
 
97
97
  for (const r of parseDataLog(bytes)) {
98
98
  if (!isDataRecord(r) || r.type !== RecordType.Boolean) continue;
@@ -100,9 +100,9 @@ for (const r of parseDataLog(bytes)) {
100
100
  const wasEnabled = enabled;
101
101
  const prevMode = modeOf(auto, test);
102
102
 
103
- if (r.name === '/DS:enabled') enabled = r.payload;
104
- else if (r.name === '/DS:autonomous') auto = r.payload;
105
- else if (r.name === '/DS:test') test = r.payload;
103
+ if (r.entry.name === '/DS:enabled') enabled = r.payload;
104
+ else if (r.entry.name === '/DS:autonomous') auto = r.payload;
105
+ else if (r.entry.name === '/DS:test') test = r.payload;
106
106
  else continue;
107
107
 
108
108
  if (wasEnabled && (!enabled || modeOf(auto, test) !== prevMode)) {
@@ -113,6 +113,6 @@ for (const r of parseDataLog(bytes)) {
113
113
  }
114
114
  }
115
115
 
116
- // Durations in microseconds; divide by 1_000_000n for seconds.
116
+ // Durations in microseconds; divide by 1e6 for seconds.
117
117
  console.log(totals);
118
118
  ```