0.0.9 • Published 6 years ago

js-seq v0.0.9

Weekly downloads
2
License
LGPL-3.0
Repository
github
Last release
6 years ago

js-seq

Licence npm version Build status Coverage status Dependencies

Lazy sequences in JavaScript. Allows to use sequence methods like "map", "filter", "reduce" etc. in a non-strict/lazy way.

Installation

npm install --save js-seq

Example usages

Printing out the first 50 fibonacci numbers (1, 1, 2, 3, 5, 8, 13 ...)

import { Seq } from 'js-seq'

Seq.iterate([1, 1], (a, b) => a + b)
  .take(50)
  .forEach(console.log)

Creating a seq of some values

Seq.of(1, 2, 3)
// Result: <1, 2, 3>

Creating a seq from an array

Seq.from([1, 2, 3])
// Result: <1, 2, 3>

Mapping the values of a seq

Seq.of(1, 2, 3)
  .map(n => n * n)
// Result: <1, 4, 9>

Filtering values of a seq

Seq.of(1, 2, 3, 4, 5, 6)
  .filter(n => n % 2 === 0)
// Result <2, 4, 6>

Reducing a seq to a single value

Seq.of(1, 2, 3)
  .reduce((a, b) => a + b)
// Result: 6

For the full API of class Seq see the API docs.

License

"js-seq" is licensed under LGPLv3.

Project status

"js-seq" is currently in alpha status.

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago