Repository navigation
Releases
v3.0.0
Breaking changes
- ESM only. The CommonJS build has been removed and the package is now
"type": "module". Useimport { Parser } from "binary-parser". Node.js >= 22.12 can stillrequire()it viarequire(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"orlengthInBytesarrays, which previously looped forever (#319) stringtypes inchoice()andwrapped()whenvarNameis omitted (#325)- Non-string or unsupported
encodingvalues; encodings are validated withTextDecoderat compile time (#345)
- Behavior changes:
New features
skipBits()to skip bits without storing them (#331)- Length
0is allowed forstring,buffer,wrappedandarray(#320)
Bug fixes
- Greedy strings no longer leave the offset one past the end of the buffer (#315)
- Strings with both
lengthandzeroTerminatedare parsed correctly (#318) bitN()andstring()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
choiceerror 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
v2.3.1
Security fix
Fixes a code injection vulnerability (GHSA-xmxc-6c22-m377) where string-typed options were interpolated verbatim into the generated parser code. Applications that build parser definitions from untrusted input should upgrade.
Affected options: length of string, buffer, array, wrapped and seek; lengthInBytes and key of array; tag of choice; offset of pointer; and the alias passed to namely().
Breaking change
These options now only accept identifier paths (e.g. "len", "$parent.len"). Expressions such as "len - 1" are rejected at compile time; use a function instead (e.g. function () { return this.len - 1; }).
Full Changelog: v2.3.0...v2.3.1
v2.3.0
What's Changed
- Fix typos by @mohd-akram in #224
- Don't assume nest contains a bit field by @nick-hunter in #241
- Add CodeQL workflow for GitHub code scanning by @lgtm-com[bot] in #225
- Bump node.js version requirement by @keichi in #242
- Use DataView instead of Buffer in hand-written benchmark by @screeny05 in #249
- Bugfix: Make
pointeraccept offset=0 by @DominicChm in #255 - Update classfile.ts for better parser by @Kreijstal in #260
- build(deps-dev): bump pbkdf2 from 3.1.2 to 3.1.3 by @dependabot[bot] in #275
- build(deps): bump tmp from 0.2.1 to 0.2.4 by @dependabot[bot] in #276
- Fix code injection vulnerability via field names and encoding names by @keichi in #283
New Contributors
- @nick-hunter made their first contribution in #241
- @screeny05 made their first contribution in #249
- @DominicChm made their first contribution in #255
- @Kreijstal made their first contribution in #260
Full Changelog: v2.2.1...v2.3.0
v2.2.1
v2.2.0
v2.1.0
What's Changed
- Allow long bit field sequences by @mohd-akram in #203
Full Changelog: v2.0.3...v2.1.0
v2.0.3
What's Changed
- Bump follow-redirects from 1.14.4 to 1.14.8 by @dependabot in #195
- Bump karma from 6.3.4 to 6.3.14 by @dependabot in #194
- Bump log4js from 6.3.0 to 6.4.1 by @dependabot in #196
- Bump minimist from 1.2.5 to 1.2.6 by @dependabot in #199
- Bump async from 3.2.1 to 3.2.3 by @dependabot in #200
- Escape assert strings by @vexcat in #198
- Fix typo (endianess -> endianness) by @keichi in #202
New Contributors
Full Changelog: v2.0.2...v2.0.3
v2.0.2
What's Changed
- Enable strict type checking by @keichi in #186
- Improve error messages by @keichi in #187
- Translate tests and examples to TypeScript by @keichi in #188
- Run unit test on headless Chrome using Karma by @keichi in #189
- Add documentation for
sizeOf()in README by @keichi in #192 - Fix assert as method definition by @mohd-akram in #193
Full Changelog: v2.0.1...v2.0.2
v2.0.1
v2.0.0
This release contains two backward incompatible changes:
- Internet Explorer 11 and Node.js 10 or lower are unsupported. You might be able to make it work by using polyfills for
TextDecoderandBigInt, but it is untested and unsupported. - Context variables are disabled by default due to their performance penalty and need to be explicitly enabled by calling
.useContextVars()on the parser object.
Changelog: