Sequency is a type-safe functional programming library for processing iterable data such as arrays, sets and maps. It's written in TypeScript, compiles to ES5-compatible JavaScript and works in all current browsers and Node applications.
Download the latest release from GitHub or install Sequency from NPM:
npm install sequency
or
yarn add sequency
Sequency is centered around the interface Sequence to process any kind of iterable data such as arrays, maps and sets.
The interface Sequence
provides a fluent functional API consisting of intermediate and terminal operations. Intermediate functions return a new sequence, thus enabling method chaining while terminal functions return an arbitrary result. You can explore all available Sequence
operations by navigating to the Sequence interface.
Sequences can be created with one of the following functions:
import {sequenceOf, asSequence, emptySequence, generateSequence} from "sequency";
sequenceOf
accepts one or many values and returns a new sequence.asSequence
accepts an iterable (e.g. an array, set or map) and returns a new sequence.emptySequence
returns a new empty sequence.generateSequence
creates a sequence from the results of the given generator function.
import {asSequence} from "sequency";
const numbers = [1, 2, 3, 4, 5];
const result = asSequence(numbers)
.filter(num => num > 2)
.reverse()
.toArray()
// result: [5, 4, 3]
MIT © winterbe