Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

✨ Standard library for JavaScript and Node.js. ✨

License

NotificationsYou must be signed in to change notification settings

stdlib-js/stdlib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 


stdlib logo




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!

Resources

External Resources

Features


Installation

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.

User Stories

  • I want to performdata analysis anddata science tasks in JavaScript and Node.js, similar to how I might use Python, Julia, R, and MATLAB.

  • 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.

    • I would like to include stdlib functionality by just using ascript 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.

  • I would like to use stdlib functionality in anObservable notebook.

  • 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).

Complete Library

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>

Individual Packages

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>

Namespaces

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.

Command-line Utility

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

Environment Builds

ES Modules

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>

Deno

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>

jQuery-like Bundle

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.

UMD

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>

Node.js

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]));}

Custom Bundles

To create a custom bundle based on project needs,

  1. follow thedownload,configuration, andinstallation instructions as described in thedevelopment guide.

  2. navigate to the local installation directory.

  3. 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
  4. 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.

System Library

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.


Prerequisites

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:

  • curl,wget, orfetch (FreeBSD): utilities for downloading remote resources

The following external libraries can be automatically downloaded and compiled from source usingmake:

  • OpenBLAS: optimized BLAS library
  • Electron: framework for cross-platform desktop applications

Contributing

First time contributor?

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 thestdlib directory

    $cd stdlib
  • Install dependencies

    $ make install-node-modules
  • Initialize your stdlib development environment

    $ make init

Sponsors

stdlib development is generously supported by the following sponsors:


Quansight Labs

Are you interested in supporting stdlib? If so, join ourOpen Collective!


Users

The following organizations and key stakeholders trust and rely on stdlib:


Carnegie Mellon University

Does your organization use stdlib? If so, we'd love to hear from you!


Governance

For information about the governance of the stdlib project, seeGOVERNANCE.md.

License

SeeLICENSE.

Copyright

Copyright © 2016-2025. The StdlibAuthors.


Status

Version

git tagNPM versionNode.js version

Community

Chat

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.

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp