Skip to content

v3.0.0

Latest

Choose a tag to compare

@keichi keichi released this 22 Nov 07:54
· 10 commits to master since this release

Breaking changes

  • ESM only. The CommonJS build has been removed and the package is now "type": "module". Use import { Parser } from "binary-parser". Node.js >= 22.12 can still require() it via require(esm). (#308)
  • Node.js 22.12 or later is required (was 14). Output now targets ES2022. (#303, #346)
  • Stricter validation. The following now throw instead of silently misbehaving:
    • __proto__ as an associative array key (#322, #328)
    • An array element that consumes no bytes in readUntil: "eof" or lengthInBytes arrays, which previously looped forever (#319)
    • string types in choice() and wrapped() when varName is omitted (#325)
    • Non-string or unsupported encoding values; encodings are validated with TextDecoder at compile time (#345)
  • Behavior changes:
    • binary, base64 and base64url strings are decoded the same way as Node.js Buffer (#324)
    • assert honors falsy values such as 0 and "" (#335)
    • Wrapper functions and deferred bit field formatters are called with the current context as this (#339, #343)

New features

  • skipBits() to skip bits without storing them (#331)
  • Length 0 is allowed for string, buffer, wrapped and array (#320)

Bug fixes

  • Greedy strings no longer leave the offset one past the end of the buffer (#315)
  • Strings with both length and zeroTerminated are parsed correctly (#318)
  • bitN() and string() no longer mutate the caller's options object (#317)
  • sizeOf() and parser compilation no longer overflow the stack on long chains (#333, #340)
  • Assertions on deferred bit fields inside nested parsers work (#341)
  • Buffer and Node.js built-ins are detected by feature instead of window (#304)
  • Fixed typos in choice error messages (#316)
  • Fixed the bundled examples (#309, #310, #311, #312, #313)

Other

  • Tests migrated to Vitest and run on Node.js, Bun, Deno and browsers (#302, #304, #307)
  • Switched to TypeScript 7, oxlint and oxfmt (#305, #337, #342, #344)
  • npm packages are published with provenance (#314)

Thanks to @Lezvix, @hippi345, @Aschenbath and @imsurya26 for contributing!

Full Changelog: v2.3.1...v3.0.0