Skip to content

hoshixlily/ts-collections

Repository files navigation

A simple TypeScript library for basic data structures.

Installation

npm i @mirei/ts-collections

Available Collections

  • List
    • List
    • LinkedList
  • Set
    • EnumerableSet
    • SortedSet
  • Dictionary
    • Dictionary
    • SortedDictionary
  • Queue
  • Stack

To be updated with details...

Enumerable Support

Example Usage

const list = new List([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
const list2 = list.select(n => n * n).takeWhile(n <= 25).skipWhile(n < 10).orderByDescending(n => n).toList();
const array = list.takeLast(5).toArray();

You can also use Enumerable with plain arrays.

const array = Enumerable.from([1, 2, 3, 4, 5]).where(n => n % 2 !== 0).toArray();