10000 Deep clone map with nested maps. · Issue #2137 · lodash/lodash · GitHub
[go: up one dir, main page]

Skip to content

Deep clone map with nested maps. #2137

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

Closed
sergej-s opened this issue Mar 21, 2016 · 5 comments
Closed

Deep clone map with nested maps. #2137

sergej-s opened this issue Mar 21, 2016 · 5 comments
Labels

Comments

@sergej-s
Copy link

Hello,

I'm stuck with issue of deep cloning map which contains other maps. It seems that values of nested map are not cloned. Please look at the next code:

let m1 = new Map([
  [1, {a: '1'}],
  [2, {b: '2'}]
])

let m2 = new Map([
  [3, {c: '3'}],
  [4, {d: '4'}]
])

let m3 = new Map([
  ['m1', m1],
  ['m2', m2]
])

let m4 = _.cloneDeep(m3);

console.log(m4===m3); // log false - Ok
console.log(m4.get('m1')===m3.get('m1')); // log true - but should be false also`

Is this bug or am I doing something wrong?

Tested with lodash 4.6.1 http://jsbin.com/jubiwaquma/1/edit?html,js,output

@jdalton
Copy link
Member
jdalton commented Mar 21, 2016

Deep cloning maps/sets/symbols isn't currently supported. It can be though. I'll dig into it.

@jdalton jdalton closed this as completed Mar 21, 2016
@sergej-s
Copy link
Author

Thank you for reply! I think we will switch to plain objects b 8000 y now.

@jdalton
Copy link
Member
jdalton commented Mar 22, 2016

Added support at 24cef1a.

@Xplouder
Copy link

+1, would be a cool feature.

@lock
Copy link
lock bot commented Jan 19, 2019

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 Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

3 participants
0