numpy-parser is a JavaScript library specifically designed for parsing binary `.npy` files, the standard format for storing NumPy arrays. It supports various TypedArray subclasses including `float32`, `float64`, `int8`, `int16`, `int32`, `uint8`, `uint16`, and `uint32`. The current stable version is 1.2.3; however, the package was last published in January 2019, indicating it is in maintenance mode rather than active development. Its primary utility lies in enabling direct data exchange with Python's scientific computing ecosystem by allowing JavaScript applications to read these highly optimized binary array files. The README mentions future work for 16-bit float support, but this remains an unimplemented feature.
npm install numpy-parserVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to parse an ArrayBuffer using `fromArrayBuffer`, with examples for obtaining the buffer in both Node.js and browser environments.
Consider testing with newer NumPy files, or evaluate alternative parsing libraries if active maintenance and latest format compatibility are critical.
Ensure that `.npy` files containing `float16` data are converted to a supported float type (e.g., `float32` or `float64`) using NumPy before being processed by `numpy-parser`.
For very large datasets, consider pre-processing the data into smaller chunks or alternative streaming formats in Python, or use Node.js with sufficient memory allocation. Implement client-side memory management if parsing large files in a browser.
Decompress `.npz` archives beforehand (e.g., using a JS zip library or Python) to extract individual `.npy` files. Convert Python pickled objects to primitive types before saving to `.npy`.
Verify the integrity of the .npy file and ensure it was generated correctly by NumPy. Check for partial downloads or file corruption. This parser might also not support very new .npy format versions.
Ensure `fs.readFileSync` successfully reads the file and returns a `Buffer` object before attempting to access its `.buffer` property. Check the file path for correctness and read permissions.
If running in Node.js, either install a `node-fetch` polyfill (e.g., `npm install node-fetch` and `import fetch from 'node-fetch';`) or use Node.js's native `node:fs` module to read local files, as shown in the quickstart comments.
No dependency data recorded yet.