@betafcc/suss
v0.1.2
Published
Micro Library for JS Iterables
Downloads
2
Maintainers
Readme
TODO
- [x] Make a working starting point
- [X] Convert to bundled entry point
- [ ] Add Tests
- [X] Convert to TypeScript
- [X] Release
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)),
);