npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

arrayloader

v5.1.0

Published

Data reading utility (including TypedArray), Browserify aware

Downloads

30

Readme

arrayloader

TypedArray reading utility, Browserify aware.

Uses fs.readFile in node, and XHR when browserified.

Installation

npm install arrayloader

Example

var loader = require('arrayloader');
loader.load('/path/to/array.f32', function (err, arr) {
	// arr is a Float32Array
	console.log(arr);
});

write compatible arrays from numpy like this,

# given array 'a'
with open('/path/to/array.f32', 'wb') as f:
	f.write(a.astype(np.float32).tostring())

choose an extension for your file like this,

extension | TypedArray | numpy dtype | mime type ---------|------------|--------------|----- i8 | Int8Array | int8 | application/x-int8 u8 | Uint8Array | uint8 | application/x-uint8 i16 | Int16Array | int16 | application/x-int16 u16 | Uint16Array| uint16 | application/x-uint16 i32 | Int32Array | int32 | application/x-int32 u32 | Uint32Array | uint32 | application/x-uint32 f32 | Float32Array| float32 | application/x-float32 f64 | Float64Array | float64 | application/x-float64

or (for non-binary types) like this,

extension | type | mime type ---------|-------|----- json | json | application/json key | json | application/json txt | str | text/plain csv | str | text/plain tsv | str | text/plain

Extensions mapped to json will be parsed (with JSON.parse) before returning.

Details

This module can read text and binary files. It will attempt to infer type from the extension of the file. If the extension isn't recognized, the type defaults to Uint8Array.

Type inference can be overridden by supplying a second argument. If this argument is supplied but not recognized, the function returns immediately with an error. If supplied, this argument should be a string containing any of the values listed in the "numpy dtype" column from the first table or the "type" column from the second.

Extras

Files in this format can be read into python/numpy like this,

with open(doc_dir + 'array.f32', 'rb') as f:
    a = np.fromstring(f.read(), dtype="float32")

Notes

Extensions for binary types differ from the numpy dtype short form in one way. The numpy short dtype specifies number of bytes, this module uses the number of bits (just as in the long form).

Credits

based on the simple, but fantastic floader