Skip to content

Latest commit

 

History

History
49 lines (39 loc) · 819 Bytes

README.md

File metadata and controls

49 lines (39 loc) · 819 Bytes

süß/JS

süß   /zyːs/
adj
   sweet, cute
noun
   the sound iteration makes over pure functional pipes

Install

npm install @betafcc/suss

Usage

Get an iterator/generator/iterable:

// Generate all Natural numbers
function* naturals() {
   for (let i = 0; true; i+=1)
       yield i;
}

Use the Fluent API:

import {suss} from '@betafcc/suss';

// Log all even squares
suss(naturals())
    .map(x => x*x)
    .filter(x => x % 2 === 0)
    .forEach(el => console.log(el));

Use the flow/pipe API:

import { flow,
         map, filter, forEach } from '@betafcc/suss';

// Log all even squares
flow(naturals())(
    map(x => x*x),
    filter(x => x % 2 === 0),
    forEach(el => console.log(el)),
);