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

fix(pipeP): first fn should return PromiseLike #363

Merged
merged 1 commit into from
Dec 21, 2017

Conversation

ikatyang
Copy link
Member

Fixes #361

Copy link
Member

@KiaraGrouwstra KiaraGrouwstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. Wasn't R.pipeP(R.inc)(Promise.resolve(1)) valid Ramda as well? It seems this would forbid such usage. I feel that's important in the sense it means it's agnostic toward whether you wanna use it with synchronous or asynchronous functions, which makes it fairly flexible.

@antogyn
Copy link

antogyn commented Dec 21, 2017

One solution to this would be to make both valid, e.g. have both

declare function $<V1, R1>(fn1: (v1: V1) => PromiseLike<R1>): (v1: V1) => PromiseLike<R1>;

and

declare function $<V1, R1>(fn1: (v1: V1) => PromiseLike<R1> | R1): (v1: PromiseLike<V1>) => PromiseLike<R1>;

EDIT :

Actually, R.pipeP(R.inc)(Promise.resolve(1)) is not valid Ramda because the promise is directly passed to the first function, so in this case it returns NaN (and it breaks if you try R.pipeP(R.inc, R.inc)(Promise.resolve(1)) for example).

So I'd say that the typings in this PR are accurate.

@ikatyang
Copy link
Member Author

As @antogyn mentioned, R.pipeP(R.inc)(Promise.resolve(1)) is not a valid Ramda since arguments are passed directly to the first function, which cause the result to be NaN (Promise.resolve(1) + 1), so I think this PR should be fine?

@KiaraGrouwstra
Copy link
Member

Okay, think that worked before, but fair enough!

@ikatyang ikatyang merged commit 3e63e1e into master Dec 21, 2017
@ikatyang ikatyang deleted the fix/pipeP-first-fn-PromiseLike branch December 21, 2017 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants