Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

numpy-parser

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

numpy-parser - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

.editorconfig

19

package.json
{
"name": "numpy-parser",
"version": "1.0.1",
"version": "1.0.2",
"description": "A JS parser for binary .npy files.",

@@ -11,3 +11,3 @@ "main": "src/main.js",

"type": "git",
"url": "git+https://github.com/distillpub/numpy-parser.git"
"url": "git+https://github.com/ludwigschubert/js-numpy-parser.git"
},

@@ -18,18 +18,13 @@ "keywords": [

"npy",
"parser",
"reader",
"loader"
"parser"
],
"author": "Ludwig Schubert",
"license": "UNLICENSED",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/distillpub/numpy-parser/issues"
"url": "https://github.com/ludwigschubert/js-numpy-parser/issues"
},
"homepage": "https://github.com/distillpub/numpy-parser#readme",
"homepage": "https://github.com/ludwigschubert/js-numpy-parser#readme",
"devDependencies": {
"mocha": "^3.4.2"
},
"dependencies": {
"filereader": "^0.10.3"
"mocha": "^5.2.0"
}
}
# numpy-parser
A JS parser for binary .npy files.
A JS parser for (binary) `.npy` files, supporting all TypedArray subclasses:
Only supports UInt, Int and Floats at the moment.
* float32 & float64
* int8, int16, int32
* uint8, uint16, uint32
This is a loosely cleaned up version of a gist by nvictus:
https://gist.github.com/nvictus/88b3b5bfe587d32ac1ab519fd0009607
## Acknowledgements
This implementation was inspired by [this gist by nvictus](https://gist.github.com/nvictus/88b3b5bfe587d32ac1ab519fd0009607).
## Future Work
`.npy` files can encode floats as 16 bit long, too. While JS runtimes may not support this as a native data type, we could still consider supporting it and parsing into 32 bit floats to at least get the bandwidth savings in transit.

@@ -1,2 +0,1 @@

function asciiDecode(buffer) {

@@ -16,2 +15,3 @@ const castBuffer = new Uint8Array(buffer);

switch (dtype) {
// Unsigned Integer

@@ -21,5 +21,6 @@ case '|u1':

case '<u2':
return new UInt16Array(buffer, offset);
return new Uint16Array(buffer, offset);
case '<u4':
return new UInt32Array(buffer, offset);
return new Uint32Array(buffer, offset);
// Integer

@@ -29,5 +30,6 @@ case '|i1':

case '<i2':
return new Int16rray(buffer, offset);
return new Int16Array(buffer, offset);
case '<i4':
return new Int32Array(buffer, offset);
// Floating Point

@@ -63,3 +65,2 @@ case '<f4':

if (header.fortran_order) {
// TODO: figure out if/how to handle this
throw new Error('file is in Fortran byte order; giving up')

@@ -66,0 +67,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc