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

ndarray-bundle

v0.3.1

Published

A single include for various useful ndarray packages

Downloads

7

Readme

ndarray-bundle

This module packages up ndarray and other related modules into a single include. The goal is to be a single-stop ndarray-based module (similar to SciPy).

Generating a cut-down version for Browserify

Browserify scans for every module that is require()d, so Browserify-ing the larger bundle ends up packaging up a bunch of things you don't need.

This module also includes code-generation, so you can generate your own version of the bundle that only includes the modules you need. This means you can work with the comprehensive bundle during dev, but swap it out for a compatible, minimal bundle when you know which modules you need.

Inclusion via Node

When included as a Node module, the result is based on the ndarray package:

var ndarray = require('ndarray-bundle');
var arr1 = ndarray(new Float32Array(100), [10, 10]);

However, other modules are included and added to this bundle, e.g.:

var matrix = ndarray.zeros([4, 4]); // included from the "zeros" module
ndarray.fill(nd1, function (i, j) { // included from "ndarray-fill"
	return i + j;
});

Some of the modules are grouped together by functionality:

assert(ndarray.signals.fft); // included from the "ndarray-fft" module
assert(ndarray.signals.convolve); // included from the "ndarray-convolve" module

The structure of the included modules is defined in module-map.json.

Generating your own code

When bundling up using a tool like Browserify, you don't want to require() modules that you're not using.

As such, you can generate code that just includes the modules you need. You'll probably do this as part of your build script (so ndarray-bundle is only a dev-dependency):

var codeGen = require('ndarray-bundle/generate');

codeGen.generateFile('./ndarray-bundle.js'); // writes to file, including all known modules by default
var jsCode = codeGen.generateString(); // or get as string

Selecting certain packages

To select certain packages, you can specify the packages you need by supplying an object argument:

codeGen.generateFile('./ndarray-bundle.js', {
	ops: true,
	complex: true,
	signal: true
});

The structure of this argument is recursive. If you want to pick and choose from sub-groups, then you can supply an object instead of true:

codeGen.generateFile('./ndarray-bundle.js', {
	ops: true,
	complex: true,
	signal: {
		fft: true
	}
});

You can also enhance this structure with other modules, by providing a string:

codeGen.generateFile('./my-ndarray-bundle.js', {
	ops: true,
	myCustomModule: 'ndarray-my-custom-module'
});

The resulting code only references the modules you want, but it maintains the same data structure. This means that if you only reference my-ndarray-bundle.js, then Browserify will only package up the modules you need.