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

objects.merge #126

Closed
3 tasks done
jkvyff opened this issue Dec 29, 2019 · 1 comment
Closed
3 tasks done

objects.merge #126

jkvyff opened this issue Dec 29, 2019 · 1 comment
Labels
enhancement New feature or request operator

Comments

@jkvyff
Copy link
Collaborator

jkvyff commented Dec 29, 2019

Merges objects to return a single object like assign. However, array and object property values are merged recursively while other values are overwritten if the have the same key.

Checklist

  • implementation
  • tests
  • jsdoc

Details

var object = {
  'a': [{ 'b': 2 }, { 'd': 4 }]
};
 
var other = {
  'a': [{ 'c': 3 }, { 'e': 5 }]
};
 
const res = objects.merge(object, other);
console.log(res)
> { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }

References

@evanplaice
Copy link
Member

evanplaice commented Dec 30, 2019

Added in v0.56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request operator
Projects
None yet
Development

No branches or pull requests

2 participants