numpy-ts entry point and work on Node.js, Bun, and Deno. They throw in browser environments.
Browser API
These functions work with strings and can be used in any JavaScript environment.parseTxt
Parse a text string into an NDArray. Each row must have the same number of values.
Returns:
NDArray — 2-D array (or 1-D if a single row/column).
serializeTxt
Serialize an NDArray to a text string.
Returns:
string — Text representation of the array.
genfromtxt
Parse a text string with flexible handling of missing values. Replaces missing values with a fill value instead of throwing. This is a buffer-based function that works with strings in any environment.
Returns:
NDArray — Parsed array with missing values filled in.
fromregex
Extract data from a text string using a regular expression with capture groups. This is a buffer-based function that works with strings in any environment.
Returns:
NDArray — Array with one row per match and one column per capture group.
Options Reference
ParseTxtOptions
LoadTxtOptions
Alias forParseTxtOptions. Used by loadtxt, genfromtxt, and their file-based variants.
SerializeTxtOptions
SaveTxtOptions
Alias forSerializeTxtOptions. Used by savetxt and its file-based variants.
File I/O API
- Async
- Sync
loadtxt
Load data from a text file on disk.Returns:
Promise<NDArray> — The parsed array.savetxt
Save an array to a text file.Returns:
Promise<void>genfromtxtFile
Load and parse a text file from disk with flexible handling of missing values. This is the file-based equivalent ofgenfromtxt.Returns:
Promise<NDArray> — Parsed array with missing values filled in.fromregexFile
Extract data from a text file on disk using a regular expression with capture groups. This is the file-based equivalent offromregex.Returns:
Promise<NDArray>