
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
fixed-len-array
Advanced tools
A tiny and type-safe TypeScript utility to create and work with fixed-length arrays (tuples).
A tiny and type-safe TypeScript utility to create and work with fixed-length arrays (tuples). Automatically trims or pads input arrays at runtime, while offering compile-time safety using TypeScript's type system.
null if not providednpm install fixed-len-array
import { toFixedLengthArray, FixedLengthArray } from "fixed-len-array";
// Pads to a fixed length of 3 with custom default
const vec3 = toFixedLengthArray([1], 3, 0);
// Result: [1, 0, 0]
// If no default is provided, pads with `null`
const paddedWithNull = toFixedLengthArray([1], 3);
// Result: [1, null, null]
// Trims if input is longer
const trimmed = toFixedLengthArray([1, 2, 3, 4, 5], 3, 0);
// Result: [1, 2, 3]
// Full type support
type Vec3 = FixedLengthArray<3, number>;
toFixedLengthArray<T, N>(input: T[], fixedLength: N, defaultValue?: T): FixedLengthArray<N, T>Creates a fixed-length array by trimming or padding the input. If defaultValue
is omitted, null will be used for padding.
type FixedLengthArray<N, T>A recursive type that represents a tuple of length N, with all elements of
type T.
We welcome contributions! Please see our Contributing Guide for details.
# Clone repository
git clone https://github.com/ptprashanttripathi/fixed-len-array.git
cd fixed-len-array
# Install dependencies
npm install
# Build TypeScript
npm run build
# Run tests
npm test
This project is MIT licensed.
Made with ❤️ by Pt. Prashant Tripathi
⭐ Star this repo if you find it helpful!
FAQs
A tiny and type-safe TypeScript utility to create and work with fixed-length arrays (tuples).
The npm package fixed-len-array receives a total of 697 weekly downloads. As such, fixed-len-array popularity was classified as not popular.
We found that fixed-len-array demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.