tiny-osmpbf is a lightweight JavaScript library designed for parsing OpenStreetMap PBF (Protocol Buffer Binary) format files. It targets environments including Node.js and web browsers, offering a pure JavaScript implementation. The current development is in a beta phase, with version 1.0.0-beta.2 being the latest as of recent releases, indicating active refinement towards a stable 1.0.0. Unlike many other PBF parsers, tiny-osmpbf prioritizes ease-of-use and a small code footprint (under 16KB minified and gzipped) over raw parsing speed. This is achieved by leveraging smaller, specialized libraries like Mapbox's `pbf` for protocol buffer parsing and `tiny-inflate` for ZLIB decompression. A key differentiating feature is its synchronous API, which simplifies integration into existing synchronous workflows but necessitates loading the entire PBF data into memory before parsing, making it less suitable for extremely large files or memory-constrained environments. The output format adheres to the widely used OSM-JSON standard, compatible with services like Overpass API.
npm install tiny-osmpbfVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to read an OSM PBF file synchronously from disk using Node.js's `fs` module and then parse it with `tiny-osmpbf`, logging basic information and the first two parsed elements.
For very large PBF files, consider using streaming parsers like `osm-pbf-parser-node` or `node-osmium` to process data incrementally and manage memory more efficiently.
Monitor release notes closely for updates and thoroughly test your application with each new beta version to identify and adapt to any breaking changes.
Benchmark `tiny-osmpbf` against performance-focused alternatives like `node-osmium` or `osm-pbf-parser-node` if parsing speed is a critical requirement for your use case.
Ensure you are using a default import for ES Modules (`import tinyosmpbf from 'tiny-osmpbf';`) or a direct `require` assignment for CommonJS (`const tinyosmpbf = require('tiny-osmpbf');`).Verify that your input data is correctly read into a `Buffer` instance, for example, by using `fs.readFileSync(filePath)` in Node.js, which returns a Buffer.
Reduce the size of the PBF file being processed, or switch to a streaming PBF parser if you need to handle extremely large datasets without loading them entirely into memory.
No dependency data recorded yet.