Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for await inside pipe() #59

Closed
koraa opened this issue Nov 22, 2019 · 1 comment
Closed

Add support for await inside pipe() #59

koraa opened this issue Nov 22, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@koraa
Copy link
Contributor

koraa commented Nov 22, 2019

It would be nice if await could be used within a pipe.

const doAwait = Symbol();

const pipe = (val, ...fns) => {
  while (fns.length > 0) {
    const fn = fns.shift()
    if (fn === doAwait) {
      return Promise.resolve(val).then((val_) => pipe(val_, ...fns));
    } else {
      val = fn(val);
    }
  }
  return val;
};

This could even be generalized and use a special trait and made to work in compose…

Using a new new function doAwait instead of the normal await is not terribly pretty, but can be done.

@koraa koraa added question Further information is requested Ferrum V3 Discussion and removed question Further information is requested labels Nov 22, 2019
@koraa koraa changed the title Add support for Async Sequences Add support for await inside pipe() Jan 16, 2020
@koraa
Copy link
Contributor Author

koraa commented Apr 30, 2021

Superseeded by #138

@koraa koraa closed this as completed Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant