Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork848
✨ Standard library for JavaScript and Node.js. ✨
License
stdlib-js/stdlib
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib.
stdlib (/ˈstændərd lɪb/ "standard lib") is a standard library with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js. The library provides a collection of robust, high performance libraries for mathematics, statistics, data processing, streams, and more and includes many of the utilities you would expect from a standard library.
What sets stdlib apart is its fully decomposable architecture, which allows you to swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.
When you use stdlib, you can be confident that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code available.
Want to join us in bringing numerical computing to the web?Start by starring the project. 🌟
Explore this GitHub repository for stdlib's source code and documentation. For guidance on developing stdlib, refer to thedevelopment guide.
Thank you for being a part of our community! Your support is invaluable to us!
- Google Calendar: calendar of public events, includingopen office hours.
- Open Collective: financially support the project.
- Twitter: follow us on social media.
- Gitter: chat with project maintainers and other community members.
35+probability distributions, with support for evaluating probability density functions (PDFs), cumulative distribution functions (CDFs), quantiles, moments, and more.
40+seedable pseudorandom number generators (PRNGs).
200+ generalutilities for data transformation, functional programming, and asynchronous control flow.
200+assertion utilities for data validation and feature detection.
50+sample datasets for testing and development.
Aplot API for data visualization and exploratory data analysis.
Native add-ons for interfacing with BLAS libraries, with pure JavaScript fallbacks.
Abenchmark framework supporting TAP.
REPL environment with integrated help and examples.
Can be bundled usingBrowserify,Webpack, and other bundlers for use in web browsers.
Every function is accompanied byTypeScript declaration files, ensuring type safety and facilitating intelligent code completion in IDEs.
To accommodate various use cases, stdlib can be used in multiple ways. The preferred method of use depends on your individual use case. We've provided some user stories to help you identify the best approach. 😃
While this project's installation instructions default to usingnpm for package management, installation via other package managers, such asyarn, should be a matter of simply swapping outnpm commands with those of the relevant package manager.
I want to performdata analysis anddata science tasks in JavaScript and Node.js, similar to how I might use Python, Julia, R, and MATLAB.
- Install the entire project as acommand-line utility.
I am building aweb application.
I plan on usingBrowserify,Webpack, and other bundlers for use in web browsers.
- Installindividual packages. Installing the entire project is likely unnecessary and will lead to slower installation times.
I would like tovendor a custom bundle containing various stdlib functionality.
- Follow the steps for creatingcustom bundles.
I would like to include stdlib functionality by just using a
script
tag.I would like to use ES Modules.
- Use an individual package's ES Modulebuild.
I would like to use a pre-built bundle (possibly via a CDN, such asunpkg orjsDelivr).
- Install (or consume via a CDN) an individual package's pre-built UMDbrowser bundle.
I am interested in using a substantial amount of functionality found in a top-level stdlib namespace and don't want to separately install hundreds of individual packages (e.g., if building an on-line calculator application and wanting all of stdlib's math functionality).
Install one or more top-levelnamespaces. Installing the entire project is likely unnecessary and will lead to slower installation times. Installing a top-level namespace is likely to mean installing functionality which will never be used; however, installing a top-level namespace is likely to be easier and less time-consuming than installing many individual packages separately.
When bundling, installing a top-level namespace should not be a concern, as individual functionality can still be independently required/imported. Project installation times may, however, be somewhat slower.
I am building aNode.jsserver application.
I am interested in using various functionality found in stdlib.
- Installindividual packages. Installing the entire project is likely unnecessary and will lead to slower installation times.
I would like tovendor stdlib functionality and avoid dependency trees.
- Install individual package UMDbundles.
I am interested in using asubstantial amount of functionality found in a top-level stdlib namespace and don't want to separately install hundreds of individual packages.
- Install one or more top-levelnamespaces. Installing the entire project is likely unnecessary and will lead to slower installation times. Installing a top-level namespace is likely to mean installing functionality which will never be used; however, installing a top-level namespace is likely to be easier and less time-consuming than installing many individual packages separately.
I am usingDeno.
- Importindividual packages using pre-built Deno builds.
I would like to use stdlib functionality in anObservable notebook.
- Consume a pre-builtbrowser bundles via a CDN, such asunpkg orjsDelivr.
I want to hack at stdlib, possibly even creatingcustomized builds to link to platform-specific native libraries (such as Intel's MKL or some other numerical library).
- Install the project as asystem library by cloning this repository and following theinstallation instructions as described in thedevelopment guide.
To install the entire project as a library or application dependency,
$ npm install @stdlib/stdlib
Once installed, stdlib packages can be individually required/imported to minimize load times and decrease bundle sizes. For example, to userequire
varndarray=require('@stdlib/ndarray/array');vararr=ndarray([[1,2],[3,4]]);// returns <ndarray>
and to useimport
importndarrayfrom'@stdlib/ndarray/array';vararr=ndarray([[1,2],[3,4]]);// returns <ndarray>
stdlib is designed to allow decomposition of the main project into individual packages which can be independently consumed. Accordingly, users of the project can avoid installing all project functionality and only install the exact functionality they need.
To install individual packages, replace forward slashes/
after@stdlib/
with hyphens-
. For example,
$ npm install @stdlib/ndarray-array
Once installed, individual packages can be required/imported. For example, to userequire
varndarray=require('@stdlib/ndarray-array');vararr=ndarray([[1,2],[3,4]]);// returns <ndarray>
and to useimport
importndarrayfrom'@stdlib/ndarray-array';vararr=ndarray([[1,2],[3,4]]);// returns <ndarray>
stdlib is comprised of various top-level namespaces (i.e., collections of related functionality united by common themes). For example, to install all math functionality found in the top-levelmath
namespace,
$ npm install @stdlib/math
Once installed, packages within a top-level namespace can be individually required/imported to minimize load times and decrease bundle sizes. For example, to userequire
varsin=require('@stdlib/math/base/special/sin');varv=sin(3.14);// returns <number>
and to useimport
importsinfrom'@stdlib/math/base/special/sin';varv=sin(3.14);// returns <number>
Note: installing nested namespaces found within top-level namespaces (e.g.,math/base
) isnot supported. Consider installing individual packages or the relevant top-level namespace.
To install globally for use as a command-line utility and/or use theREPL,
$ npm install -g @stdlib/stdlib
which will expose thestdlib
command. For example, to see available sub-commands
$ stdlibhelp
and to run theREPL
$ stdlib repl
To use ES Modules via a<script>
tag, useES Module builds available in each package's repository via a dedicatedesm
branch (e.g., see theesm
branch for@stdlib/math-base-special-erf
). For example,
<scripttype="module">importlinspacefrom'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-linspace@esm/index.mjs';importerffrom'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-erf@esm/index.mjs';constx=linspace(-10.0,10.0,100);for(leti=0;i<x.length;i++){console.log('x: %d, erf(x): %d',x[i],erf(x[i]));}</script>
To use individual packages in Deno, useDeno builds available in each package's repository via a dedicateddeno
branch (e.g., see thedeno
branch for@stdlib/ndarray-array
). For example,
importndarrayfrom'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-array@deno/mod.js';vararr=ndarray([[1,2],[3,4]]);// returns <ndarray>
For those wanting a jQuery-like bundle, one can use pre-built distributable UMD bundles for use in browser environments or as shared ("vendored") libraries in server environments available in each package's repository via a dedicatedumd
branch. See sectionsUMD andNode.js for more details.
To use UMD bundles either via a<script>
tag or inObservable, use UMDbrowser builds available in each package's repository via a dedicatedumd
branch (e.g., see theumd
branch for@stdlib/math-base-special-erf
). For example,
<scripttype="text/javascript"src="https://cdn.jsdelivr.net/gh/stdlib-js/array-base-linspace@umd/browser.js"></script><scripttype="text/javascript"src="https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-erf@umd/browser.js"></script><scripttype="text/javascript">(function(){varx=linspace(-10.0,10.0,100);for(vari=0;i<x.length;i++){console.log('x: %d, erf(x): %d',x[i],erf(x[i]));}})();</script>
Tovendor stdlib functionality and avoid installing dependency trees, use UMDserver builds available in each package's repository via a dedicatedumd
branch (e.g., see theumd
branch for@stdlib/math-base-special-erf
). For example,
varlinspace=require('/path/to/vendor/umd/@stdlib/array-base-linspace');varerf=require('/path/to/vendor/umd/@stdlib/math-base-special-erf');varx=linspace(-10.0,10.0,100);for(vari=0;i<x.length;i++){console.log('x: %d, erf(x): %d',x[i],erf(x[i]));}
To create a custom bundle based on project needs,
follow thedownload,configuration, andinstallation instructions as described in thedevelopment guide.
navigate to the local installation directory.
run the following command to print help documentation for providing a list of stdlib package names to bundle
$ NODE_PATH=./lib/node_modules node ./bin/cli bundle-pkg-list -- -h
modify and run the above command with the list of packages to bundle
$ NODE_PATH=./lib/node_modules node ./bin/cli bundle-pkg-list --<pkg><pkg><pkg> ...
Upon generating a bundle, the bundle can be loaded via a<script>
tag as described above for pre-built distributable UMD bundles.
To install as a system library (e.g., for the purposes of creating custom builds), follow thedownload,configuration, andinstallation instructions as described in thedevelopment guide.
Installing and running stdlib for use inNode.jsrequires the following prerequisites:
- Node.js: JavaScript runtime (version
>= 0.10
) - npm: package manager (version
> 2.7.0
; if Node< 1.0.0
, version> 2.7.0
and< 4.0.0
; if Node<= 10.x.x
, version> 2.7.0
and< 6.0.0
)
Most functionality in stdlib is implemented in JavaScript and no further prerequisites are required to use stdlib (i.e., you can safely avoid installing any additional prerequisites); however, some implementations try to capture performance benefits by usingnative bindings and/orWebAssembly. Whilenot required to run stdlib, asevery stdlib implementation has a JavaScript fallback, the following dependencies arerequired for building native add-ons, including linking to BLAS and LAPACK libraries:
- GNU make: development utility and task runner
- GNU bash: an sh-compatible shell
- gcc & g++ orClang: C/C++ compilation and linking (g++ version
>= 4.8
; clang version>= 3.5
, Xcode version>=8.3.1
on OS X) - gfortran: Fortran compilation and linking (version
>= 4.8
)
Whilenot required to run stdlib, the following dependencies arerequired for automatically downloading external libraries:
The following external libraries can be automatically downloaded and compiled from source usingmake
:
First time contributor?
- See thecontributing guidelines.
Already an expert?
Fork the repository.
Clone the forked repository
$ git clone --depth=1 https://github.com/<username>/stdlib.git
where
<username>
is your GitHub username.Navigate to the
stdlib
directory$cd stdlib
Install dependencies
$ make install-node-modules
Initialize your stdlib development environment
$ make init
stdlib development is generously supported by the following sponsors:
Are you interested in supporting stdlib? If so, join ourOpen Collective!
The following organizations and key stakeholders trust and rely on stdlib:
Does your organization use stdlib? If so, we'd love to hear from you!
For information about the governance of the stdlib project, seeGOVERNANCE.md.
SeeLICENSE.
Copyright © 2016-2025. The StdlibAuthors.
Have something you want to discuss? In addition to the community chat, we hold regularoffice hours over video conferencing, which is a great opportunity to ask questions, share ideas, and engage directly with the stdlib team.
You can also subscribe to ourproject calendar to stay informed about the latest public community events.
About
✨ Standard library for JavaScript and Node.js. ✨
Topics
Resources
License
Code of conduct
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.