Tracking issue — not urgent, just so it isn't lost.
The package was recently onboarded to the CLDMV @v4 workflow flow with a vitest characterization suite (#2). That work deliberately locked current behavior for regression safety — it did not review the underlying sizeofvar.js heuristic for correctness. The module predates recent Node/V8 and hasn't been touched in years, so the actual estimate may be stale or off.
Worth a later pass on:
- The magic-number heuristic — the fixed costs (152 for booleans, per-8-char string buckets, the
2^31 numeric offset, the object entry-count overhead 40 + ceil((c-1)/3)*24). Whether these still reflect real V8 memory layout on current Node majors, or were ever accurate. Consider validating against process.memoryUsage() / v8.serialize sizes or Buffer.byteLength where applicable.
- Edge cases the tests currently lock (not endorse):
sizeofvar(null) throws TypeError (null dispatches to the object branch, then Object.entries(null) throws).
undefined, functions, symbols, and bigints match no switch case and silently return 0.
- Object cost keys on entry count, never key name/length.
These may be bugs rather than intended behavior — decide per case whether to fix or keep.
- Modernization (cosmetic vs. the correctness question): ESM + named export, typed signature, drop the
var/old-style code.
Note: the 91-test characterization suite pins current output, so any behavior change here must update those tests deliberately (they assert what it does today, not what is correct).
Tracking issue — not urgent, just so it isn't lost.
The package was recently onboarded to the CLDMV @v4 workflow flow with a vitest characterization suite (#2). That work deliberately locked current behavior for regression safety — it did not review the underlying
sizeofvar.jsheuristic for correctness. The module predates recent Node/V8 and hasn't been touched in years, so the actual estimate may be stale or off.Worth a later pass on:
2^31numeric offset, the object entry-count overhead40 + ceil((c-1)/3)*24). Whether these still reflect real V8 memory layout on current Node majors, or were ever accurate. Consider validating againstprocess.memoryUsage()/v8.serializesizes orBuffer.byteLengthwhere applicable.sizeofvar(null)throwsTypeError(null dispatches to the object branch, thenObject.entries(null)throws).undefined, functions, symbols, and bigints match noswitchcase and silently return0.These may be bugs rather than intended behavior — decide per case whether to fix or keep.
var/old-style code.Note: the 91-test characterization suite pins current output, so any behavior change here must update those tests deliberately (they assert what it does today, not what is correct).