# FlatGeobuf for JavaScript / TypeScript ## Building ### Prerequisites You must have [`pnpm`](https://pnpm.io) installed. ### Install FlatGeobuf dependencies pnpm install ### Build To compile the typescript into a javascript bundle pnpm build See the `scripts` section in [package.json](../../package.json) for other actions. ## Seekable Zstandard The GeoJSON API can read an externally produced, standard seekable-Zstandard wrapper from bytes or a range-enabled URL. The wrapper leaves the FlatGeobuf bytes unchanged. Create wrapped files with external seekable-Zstandard tooling. ```ts import { geojson } from 'flatgeobuf'; const features = geojson.deserialize('https://example.com/data.fgb.zst', { rect: { minX: -106.88, minY: 36.75, maxX: -101.11, maxY: 41.24 }, seekableZstd: true, }); ``` Indexed reads fetch only the seek-table, FlatGeobuf index, and frames needed for the requested features. URL sources must support HTTP byte ranges and expose the `Content-Range` response header for cross-origin requests. When using a prebuilt browser bundle, serve the generated `zstd.wasm` file next to the bundle. ### Testing the examples locally. The examples are hard coded to pull in the publicly released artifact. If you'd like to test against your local changes, after running `pnpm build`, update the ` - + ``` Serve the repo root with a static server that supports HTTP range requests, e.g. `npx http-server -p 8000 .` Then, open the example in your browser. For example: `open http://localhost:8000/examples/leaflet/filtered.html`.