Skip to content

TypeSafeArray is a type-safe utility library for array manipulation in TypeScript.

License

Notifications You must be signed in to change notification settings

anonymousRecords/type-safe-array

Repository files navigation

TypeSafeArray

TypeSafeArray is a type-safe utility library for array manipulation in TypeScript.

Features

  • Full type safety
  • Support for readonly arrays
  • API similar to standard Array methods

Installation

npm install @chapdo/type-safe-array

or

yarn add @chapdo/type-safe-array

Usage

import { TypeSafeArray } from 'type-safe-array';

const numbers = [1, 2, 3, 4, 5] as const;

// map example
const doubled = TypeSafeArray.map(numbers, (x) => x * 2);
console.log(doubled); // [2, 4, 6, 8, 10]

// filter example
const evenNumbers = TypeSafeArray.filter(numbers, (x) => x % 2 === 0);
console.log(evenNumbers); // [2, 4]

// reduce example
const sum = TypeSafeArray.reduce(numbers, (acc, curr) => acc + curr, 0);
console.log(sum); // 15

Official Documentation

Detailed API documentation can be found here.

License

This project is under the MIT License.

About

TypeSafeArray is a type-safe utility library for array manipulation in TypeScript.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published