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

BREAKING: KeyedCollection.toArray() returns array of tuples. #1340

Merged
merged 1 commit into from
Oct 5, 2017

Conversation

leebyron
Copy link
Collaborator

@leebyron leebyron commented Oct 4, 2017

This fixes a long standing API quirk where x.toArray() had different behavior from [...x] or Array.from(x).

This is breaking since previously Map, and other keyed collections would provide an array of only values from .toArray(), to fix code that relies on this behavior, convert x.toArray() to x.valueSeq().toArray().

Likewise, for code that was working around this behavior before, x.entrySeq().toArray() can typically be replaced with x.toArray().

Fixes #333

This fixes a long standing API quirk where `x.toArray()` had different behavior from `[...x]` or `Array.from(x)`.

This is breaking since previously Map, and other keyed collections would provide an array of only values from `.toArray()`, to fix code that relies on this behavior, convert `x.toArray()` to `x.valueSeq().toArray()`.

Likewise, for code that was working around this behavior before, `x.entrySeq().toArray()` can typically be replaced with `x.toArray()`.

Fixes #333
@leebyron leebyron merged commit 5d9fd21 into master Oct 5, 2017
@leebyron leebyron deleted the fix-333 branch October 5, 2017 01:23
acusti added a commit to brandcast/draft-js that referenced this pull request Oct 14, 2017
Immutable v4 Introduces a number of breaking changes, but the only one
that seems to affect draft is that calling toArray on Keyed
collections, like Map, now returns [key, value] tuples instead of just
an array of values:
immutable-js/immutable-js#1340
@msageryd
Copy link

msageryd commented Nov 8, 2017

Thank you for your great efforts on a great library. I'm trying out version 4 and it's great.

Just wanted to give you a heads-up on the new toArray() behaviour. I bit me in several places in my code base. I think this one needs to be shout out properly in the documentation. A common place for my use of toArray() is in ReduxSaga when I'm forking tasks based on data in Immutable.Map.

spkjp pushed a commit to ArkEcosystem/core that referenced this pull request Nov 9, 2018
*     chore: update dependencies

*          fix(core-test-utils): adjust blockchain entry helper to xstate v4

* fix(core-blockchain): replace toArray calls with valueSeq.toArray on OrderedMaps

See immutable-js/immutable-js#1340 and https://github.com/facebook/immutable-js/releases/tag/v4.0.0-rc.5 for more details

* chore: update yarn.lock
acusti added a commit to acusti/draft-js that referenced this pull request May 21, 2021
one of the breaking changes in immutable 4.x.x is that KeyedCollection.toArray() now returns an array of [k, v] tuples, instead of just an array of the values: immutable-js/immutable-js#1340
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

toArray behavior on Maps
3 participants