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(isArrayLike): reject functions because functions have "length" #3562

Merged
merged 2 commits into from
Apr 13, 2018

Conversation

johnlindquist
Copy link
Contributor

@johnlindquist johnlindquist commented Apr 13, 2018

Description:
Added a typeof x !== "function" check to isArrayLike. isArrayLike was only checking for length and functions have a length property. This prevented functions from properly falling through to this case:

} else if (result && typeof result[Symbol_observable] === 'function') {

// for the purpose of making a nice diagram, spread out the synchronous emissions
.concatMap((x, i) => of(x).delay(i === 0 ? 0 : 20, rxTestScheduler));
const expected = 'x-y-(z|)';
expectObservable(e1).toBe(expected, { x: 10, y: 20, z: 30 });
Copy link
Member

Choose a reason for hiding this comment

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

Can we undo the formatting changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -118,5 +119,26 @@ describe('from', () => {
);
expect(nextInvoked).to.equal(false);
});
it(`should accept a function`, (done) => {
Copy link
Member

Choose a reason for hiding this comment

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

from should not accept a function.

from((...args) => subject.next(...args)) should not work and should error.

The change to isArrayLike I can understand, I'm uncertain about this test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if from accepts a Promise, shouldn't it be able to accept a handler?

Copy link
Member

Choose a reason for hiding this comment

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

I see, the function has Symbol.observable on it. I missed that. Apologies.

@benlesh benlesh merged commit c9570df into ReactiveX:master Apr 13, 2018
@benlesh
Copy link
Member

benlesh commented Apr 13, 2018

Thanks @johnlindquist <3

@lock
Copy link

lock bot commented Jun 5, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants