Skip to content

Releases: mapbox/pbf

v5.1.0

29 May 09:27

Choose a tag to compare

  • Added a new PbfReader nextField(end) method that allows writing more compact, readable and bulletproof decoding code while preserving performance. #144
  • Updated pbf/compile to take advantage of nextField.

v5.0.0

26 May 15:55

Choose a tag to compare

Breaking changes

  • The Pbf class is split into separate PbfReader and PbfWriter classes, so bundlers can tree-shake the half you don't use.
  • Removed the legacy readVarint64 method — use readVarint(true) for signed 64-bit reads.

Performance

On the Mapbox vector-tile benchmark (439 tiles, 37.5 MB), v5 is ~25% faster to decode and ~27% faster to encode than v4. Highlights:

  • Generated reader code was rewritten from a callback-based style into inlined while loops with direct field-number dispatch, letting V8 fully inline each reader (biggest decode win).
  • writeVarint / readVarint got single-byte fast paths for the common case (tags, small ints).
  • Buffer growth in makeRoomForExtraLength now uses Uint8Array.copyWithin instead of a manual byte-shift loop (biggest encode win).
  • writeBytes uses typedArray.set instead of a manual copy loop.

Other improvements

  • The schema compiler (compile.js) was significantly simplified — generated code is cleaner and easier to read.
  • Fixed a bug in compiled packed sfixed64 fields.

v4.0.2

22 May 11:37

Choose a tag to compare

  • Add sanitization of field names in pbf/compile to protect against injection via malicious proto schema.
  • Modernize dev dependencies.

v4.0.1

08 Jul 15:00

Choose a tag to compare

  • Avoid creating redundant zero-byte buffer when writing Pbf.
  • Fix Pbf constructor typings (mark buf as optional).

v4.0.0

08 Jul 08:47

Choose a tag to compare

  • ⚠️ Expose the library as a ES module, dropping CommonJS support.
  • ⚠️ Rewrite the codebase to use modern ES syntax (you can still transpile on your end to keep IE11 support).
  • ⚠️ Make code generation generate ESM modules by default, with CommonJS available through --legacy mode.
  • ⚠️ Overhaul code generation to write simpler code that's more compact and more susceptible to efficient minimization — instead of nested objects, the generated code has flat exports of read and write functions (see readme and test fixtures).
  • Add TypeScript type check & first-class typings via JSDoc comments.
  • Remove dependency on ieee754 package and use native DataView instead, which is faster and universally supported.
  • Modernize dev tools (use Rollup instead of Browserify for UMD builds, ESLint 9+; in addition to an earlier switch from Tap to native Node test runner and coverage and to GitHub Actions from Travis).
  • Fix writing of default oneof fields. #103 by @farwayer

v3.3.0

03 Jul 15:52

Choose a tag to compare

  • Fix incorrect code generation for enums. 2e0dfa7
  • Use undefined instead of null as the default value for generated code (by @Timmmm in #112)
  • Add support for js_type annotations for generated code (by @UlysseM in #121)
  • Fix an error with TextDecoder in certain environments (by @evertbouw in #113)

Changelog for previous versions