-
Notifications
You must be signed in to change notification settings - Fork 108
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
Proposal: create a new function instead #284
Comments
I suspect that the way the |
I think they cover their reasoning about not doing this here: https://github.com/tc39/proposal-pipeline-operator#method-chaining-is-limited |
I second @JamesJansson on this. @tinydogio-joshua I don't think this section does a great job at explaining why it would not works. Also, let's not forget that promises already provides some chaining. here is a potential implementation of the sample from the proposal Readme. const chain = (el) => Promise.resolve(el);
chain(Object.keys(envars))
.then(x => x.map(envar => `${envar}=${envars[envar]}`))
.then(x => x.join(' '))
.then(x => `$ ${x}`)
.then(x => chalk.dim(x, 'node', args.join(' ')))
.then(console.log) I do agree that this is more verbose than this proposal, and maybe harder to reason in some cases, such as dealing with other promises, but at least I think this should be documented. |
I'll leave that to those actively working on this. I just watch this repo as I'm excited for the feature. I figured I'd point out where they try to address this. |
You can use syntax straight away with babel; that's not a good reason to ship API over syntax. |
There's a separate proposal to (among some other functions) add const sumCharCodes = R.pipe(
R.split(""),
R.map(s => s.charCodeAt(0)),
R.sum
); |
Given that pipes are a huge syntactical change, even after acceptance the syntax might not be confidently used for many years. On the other hand, creating a new function that accepts an initial value, then allows you call
.next(functionName)
and then (.end()
) allows people to use it straightaway and allows polyfills to be used confidently until acceptance is broad.Example:
I've got working code for
pipe
in this gist here, along with a crazy non-recommended version calledpwhyp
: https://gist.github.com/JamesJansson/923f60d0738a9cae1622947da66d4a0bThe text was updated successfully, but these errors were encountered: