项目作者: WimJongeneel

项目描述 :
Lazy collections with iterators for TypeScript
高级语言: TypeScript
项目地址: git://github.com/WimJongeneel/ts-lazy-collections.git
创建时间: 2020-01-25T12:15:47Z
项目社区:https://github.com/WimJongeneel/ts-lazy-collections

开源协议:

下载


Lazy collections with iterators for TypeScript

Read the article here for more context

Interface

Constructors

fromArray

Convers an array to a lazy collection.

fromFunction

Creates a sequence based of a function. The function will get the index and the previous value as a param and should return the next value. The last value is undefiend on the first call.

fromRange

Creates a sequence of numbers based on a min and max.

Collection methods

toArray

converts the collection to an array. Causes a full iteration of the complete data pipeline. Don’t use this unless needed.

filter

Filter a collection based on a predicate. This is a lazy operation, no iteration will be caused.

map

Convert all items in the collection by applying a function. This is a lazy operation, no iteration will be caused.

first

Get the first item from the collection. This will only cause the pipeline to proccess the first item. No full iteration will occure. Collections are a stream, so you can only recieve every item once.

skip

Skips a given amount of items of the collection. This will only cause the pipeline to proccess the skipped items. No full iteration will occure.

take

Limit the size of the collection to a given number. This is a lazy operation, no iteration will be caused.