Skip to main content

API Reference

numpy-ts implements 476 out of 507 NumPy functions (93.9% coverage) in pure TypeScript with zero dependencies. Every function is tested against NumPy for correctness.
On top of full coverage, numpy-ts is 1.25x faster than NumPy on average across 7,159 benchmarks. See the full performance breakdown.

Coverage by category

How to read this reference

Each function page follows a consistent format: Signature — The full TypeScript signature with generics and overloads where applicable.
Parameter table — Every parameter listed with its type, default value, and description. Return type — What the function returns (scalar when reducing all axes, NDArray when reducing along a single axis). Example — A short, runnable code snippet demonstrating typical usage.
All type signatures use the NDArray class from the default numpy-ts entry point. If you use the tree-shakeable numpy-ts/core entry point, return types are NDArrayCore instead. The API is otherwise identical.

Intentionally unplanned features

The following NumPy features are not implemented by design (31 functions):
  • Datetime typesdatetime64 and timedelta64 dtypes. Use native JavaScript Date or libraries like date-fns instead.
  • Fortran-order layoutorder='F' parameter. All arrays use C-contiguous (row-major) layout.
  • Object dtypedtype=object. JavaScript does not have an equivalent concept.
  • String dtypesdtype='U' and dtype='S'. Use native JavaScript strings and typed arrays separately.
These exclusions keep the library focused on numeric computation where TypeScript can match or exceed NumPy’s performance.

NDArray Class

Properties, core methods, and the NDArray / NDArrayCore hierarchy.

NDArray Methods

100+ chainable instance methods on NDArray (arithmetic, reductions, shape, linalg, and more).

Array Creation

array, zeros, ones, arange, linspace, eye, and all *_like variants.

Linear Algebra

linalg.inv, linalg.det, linalg.eig, linalg.svd, linalg.solve, and more.

Random

53 random number generation functions including distributions and sampling.

FFT

Discrete Fourier transforms: fft, ifft, rfft, irfft, fft2, fftfreq, and more.