gensequence
v8.0.8
Published
Small library to simplify working with Generators and Iterators in Javascript / Typescript
Maintainers
Readme
GenSequence
Small library to simplify working with Generators and Iterators in Javascript / Typescript
Javascript Iterators and Generators are very exciting and provide some powerful new ways to solve programming problems.
The purpose of this library is to make using the results of a generator function easier.
It is not intended as a replacement for arrays and the convenient [...genFn()] notation.
GenSequence is useful for cases where you might not want an array of all possible values.
GenSequence deals efficiently with large sequences because only one element at a time is evaluated.
Intermediate arrays are not created, saving memory and cpu cycles.
Installation
npm install -S gensequenceUsage
import { genSequence } from 'gensequence';Examples
Fibonacci
The Fibonacci sequence can be very simply expressed using a generator. Yet using the result of a generator can be a bit convoluted. GenSequence provides a wrapper to add familiar functionality similar to arrays.
