js-seq
[![Licence](https://img.shields.io/badge/licence-LGPLv3-blue.svg?style=flat)](https://github.com/js-works/js-spec/blob/master/LICENSE) [![npm version](https://img.shields.io/npm/v/js-seq.svg?style=flat)](https://www.npmjs.com/package/js-seq) [![Build st
Last updated 2 years ago by mcjazzyfunky .
LGPL-3.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install js-seq 
SYNC missed versions from official npm registry.

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.

Current Tags

  • 0.0.9                                ...           latest (2 years ago)

8 Versions

  • 0.0.9                                ...           2 years ago
  • 0.0.8                                ...           2 years ago
  • 0.0.7                                ...           2 years ago
  • 0.0.6                                ...           2 years ago
  • 0.0.5                                ...           2 years ago
  • 0.0.4                                ...           2 years ago
  • 0.0.2                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 1
Dependencies (0)
None
Dev Dependencies (23)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |