Hacker News new | ask | show | jobs
by Tade0 994 days 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.

2 comments

Gulp[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
Nice idea, but something as simple as this doesn't work:

    pipeSync(p => [
      "hello",
      p + " world",
      console.log
    ]);