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 _.of and _.fromError #520

Merged
merged 1 commit into from
Aug 6, 2016
Merged

add _.of and _.fromError #520

merged 1 commit into from
Aug 6, 2016

Conversation

svozza
Copy link
Collaborator

@svozza svozza commented Aug 6, 2016

As discussed in #519.

_.fromError = function (error) {
return _(function (push) {
push(error);
push(_.nil);
Copy link
Collaborator

Choose a reason for hiding this comment

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

push(null, _.nil)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Doh!

@vqvu
Copy link
Collaborator

vqvu commented Aug 6, 2016

LGTM.

@vqvu
Copy link
Collaborator

vqvu commented Aug 6, 2016

Can you add a short entry to the CHANGELOG.md referencing this change?

@svozza
Copy link
Collaborator Author

svozza commented Aug 6, 2016

Oh yes, of course.

@svozza
Copy link
Collaborator Author

svozza commented Aug 6, 2016

Done.

@vqvu vqvu merged commit 6405e6e into caolan:master Aug 6, 2016
@svozza svozza deleted the fromError-of branch August 6, 2016 20:51
@svozza
Copy link
Collaborator Author

svozza commented Aug 9, 2016

I've just realised, have I made this function too dumb, i.e., should I check to see if what I've got is a Promise or an Iterable and not wrap those objects in [] before passing them to the Highland constructor?

@vqvu
Copy link
Collaborator

vqvu commented Aug 9, 2016

I don't think so, for three reasons

  1. Arrays are Iterables, and it seems weird to have to say _.of([[1, 2, 3]]) to get a stream of arrays. It's not very intuitive.
  2. You could argue for promises, but that functionality may be better off
    implemented as part of asyncify instead. People already have _ if they
    know for sure that they have a promise.
  3. Special cases would permanently break compatibility with fantasy land's
    definition of of.

On Tue, Aug 9, 2016 at 10:59 AM, Stefano Vozza notifications@github.com
wrote:

I've just realised, have I made this function too dumb, i.e., should I
check to see if what I've got is a Promise or an Iterable and not wrap
those objects in [] before passing them to the Highland constructor?


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
#520 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AGIyZd7zwtG7T6dRUXN-qWa_rSN-ZIFfks5qeKPmgaJpZM4JeV9g
.

@svozza
Copy link
Collaborator Author

svozza commented Aug 10, 2016

Yep, makes sense. Looking at the Fantasy Land spec though it looks like of needs to be on the object's prototype so we'll have to revisit this later anyway:

https://github.com/fantasyland/fantasy-land#of-method

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.

2 participants