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
Create Map from Object which has length Property #1026
Comments
@jaganathanb The problem seems to be here: https://github.com/facebook/immutable-js/blob/master/src/Seq.js#L359
You could just write a version that doesn't use function fromJS(x) {
if (Array.isArray(x)) {
return new List(x).map(fromJS)
} else if (typeof x === 'object') {
return Object.keys(x).reduce((acc, key) => (
acc.set(key, fromJS(x[key]))
), new Map().asMutable())
}
return x
} This is of course not optimal, but it should work. |
Because things like
|
@ShirtlessKirk True! I didn't think of those. In that case, I'll open a PR for the extra check. |
In the meantime, |
There is a question in SO which talks about custom
fromJS
fromJS
is taken from the Immutable docs pageThe above code outputs,
But it has to be printed as below.
What is wrong with the above custom
fromJS
function.JSBin is here
Note: If we change the property
length
tomLength
, it works as expected.The text was updated successfully, but these errors were encountered: