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.

Coverage by category

CategoryFunctionsStatus
NDArray Class & Methods47/47100%
Array Creation35/35100%
Arithmetic29/29100%
Exponential & Logarithmic9/9100%
Trigonometric16/16100%
Hyperbolic9/9100%
Rounding7/7100%
Other Math15/15100%
Array Manipulation46/46100%
Reductions36/36100%
Statistics11/11100%
Linear Algebra38/38100%
Logic & Comparison34/34100%
Sorting & Searching13/13100%
Set Operations12/12100%
Bitwise13/13100%
Indexing27/27100%
Gradient & Differences3/3100%
Polynomials10/10100%
Random53/53100%
FFT18/18100%
I/O8/8100%
Utilities26/26100%
Unplanned0/31

How to read this reference

Each function page follows a consistent format: Signature — The full TypeScript signature with generics and overloads where applicable.
function functionName(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
Parameter table — Every parameter listed with its type, default value, and description.
ParameterTypeDefaultDescription
aNDArrayInput array.
axisnumberundefinedAxis along which to operate. When undefined, operates on the flattened array.
keepdimsbooleanfalseIf true, reduced axes are kept as dimensions with size 1.
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.