@undercut/push
Lazy data processing and pipelines built around native JS Generators and Observers. The code is universal and works in Node/browser/microwave.
- Based on existing JS protocols and language features
- Balanced API: not too imperative, not too functional
- Composability and extensibility by design
- Custom operations in a couple of lines
- Pure ES Modules with Node 14 loader compliance
- Lazy evaluation when possible
- Tree shaking friendliness
- No external dependencies
- TypeScript in JSDoc
- RMS 0.3.0
Please visit undercut.js.org for broader overview and documentation.
Usage
import { pushLine, filter, map, skip, toConsumer } from "@undercut/push";
const pipeline = [skip(2), filter(x => x % 3), map(x => x * 2)];
const observer = pushLine(pipeline, toConsumer(x => console.log(x)));
console.log(`before`);
observer.next(1);
observer.next(2);
observer.next(3);
observer.next(4);
console.log(`in the middle`);
observer.next(5);
observer.next(6);
observer.next(7);
console.log(`after`);
observer.return();
Prerequisites
The package is compliant with the Raw Module Specification 0.3.0 and provides original modern JavaScript code in the ESM
format.
You may need to compile the code and/or load polyfills depending on your environment. Look for exact minimum versions of @babel/preset-env
and core-js
in the package.json
.
Most modern apps already have such infrastructure or use similar tools. So most likely you don't have to do anything. If not, just add Babel to your build step.
Installation
npm install @undercut/push
# or
yarn add @undercut/push
Updating
As descibed in RMS: in case of upgrading the package to a newer version, please do so for @babel/preset-env
and core-js
too.
License
Licensed under the MIT License, see LICENSE for more information.