Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/super3/pipeline
A modular pipeline architecture.
https://github.com/super3/pipeline
Last synced: 27 days ago
JSON representation
A modular pipeline architecture.
- Host: GitHub
- URL: https://github.com/super3/pipeline
- Owner: super3
- Created: 2018-10-02T13:17:10.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-04-28T21:40:41.000Z (over 3 years ago)
- Last Synced: 2024-11-06T15:57:42.682Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pipeline
A modular pipeline architecture
## [Module](lib/Module.js)
A superclass for all modules. Inherents `EventEmitter`.
### [SourceModule](lib/SourceModule.js)
A superclass for modules that emit output and receive no inputs.
``` javascript
const Greeter = SourceModule.create(async function(name) {
setInterval(() => {
this.emit('output', `Hello, ${name}!`);
}, 1000);
});const greeter = new Greeter('Monty');
// Hello, Monty!
```### [TransformModule](lib/TransformModule.js)
A superclass for all modules that transform an input to produce a single output.
``` javascript
const LessThan = TransformModule.create(async (x, y) => x < y);const lessThan = new LessThan(10);
// 9 => true
// 11 => false
```## [Pipeline](lib/Pipeline.js)
``` javascript
const Generator = SourceModule.create(async function(max) {
setInterval(() => {
this.emit('output', Math.floor(Math.random() * max))
}, 100);
});const Multiplier = TransformModule.create(async (number, multiplier) => {
return number * multiplier;
});const Logger = TransformModule.create(async number => {
console.log(number);
});new Pipeline([
new Generator(100),
new Multiplier(0.5),
new Logger()
]);
``````
2
41
26
25
47
39.5
27.5
34.5
0.5
39
15.5
3
39.5
2.5
22
```