3 ms·
I like goofy projects like this one but I think that if you insist on having calls there, then might as well make it more explicit with something like this:
by Tade0 3y ago
I like goofy projects like this one but I think that if you insist on having calls there, then might as well make it more explicit with something like this:
pipe((p) => ([
"hello",
p.concat("!"),
send,
p.status,
console.log
]));
Where `p` stands for Proxy to the previous result. Under the hood it would just return an object describing the name of the called method and arguments passed.
The pipe function would then iterate over the array, calling methods as described.
It's not immediately clear what should happen when a method's return type is a function, but I suppose this can be handled via convention.
- Tade0 3y agoHere's a very basic implementation: https://github.com/Tade0/pipe/blob/master/pipe-sync.js https://github.com/Tade0/pipe/blob/master/pipe-sync.js
- xigoi 3y agoNice idea, but something as simple as this doesn't work: pipeSync(p => [ "hello", p + " world", console.log ]);
- deleted 3y ago[deleted]
- pineconewarrior 3y agoGulp[1] and node streams sortof do this gulp.src(config.src) .pipe(uglify()) .pipe(gulp.dest(config.dest)) .pipe(size()); [1] https://www.npmjs.com/package/gulp https://www.npmjs.com/package/gulp