Today's npm package: merge-anything

I am developer from India currently based in Berlin, Germany.
I am very interested in Design, though I don't design 😉 I take care of it while making my apps.
Photography, videography and having random conversation over beer are my activities of spare time. Timelapses and hyperlapses make me wonder all the time 😊
Today's npm package is merge-anything
Manipulating data is basic need for any kind of application development.
And for manipulation of data, sometimes merging of similar data is needed.
And, merge-anything is going to help us in this direction. Let's see how to use it:
const { merge, mergeAndConcat } = require('merge-anything');
const objA = {
name: 'Pankaj',
lang: ['js', 'css'],
social: { twitter: 'patel_pankaj_' }
};
const objB = {
name: 'Pankaj Patel',
lang: ['html', 'go'],
social: { instagram: 'pankaj_patel' }
};
console.log(
'Merge',
merge(objA, objB)
);
/* {
name: 'Pankaj Patel',
lang: ['html', 'go'],
social: {
instagram: 'pankaj_patel',
twitter: 'patel_pankaj_'
}
} */
console.log(
'MergeAndConcat',
mergeAndConcat(objA, objB)
);
/* {
name: 'Pankaj Patel',
lang: ['js', 'css', 'html', 'go'],
social: {
instagram: 'pankaj_patel',
twitter: 'patel_pankaj_'
}
} */
One thing to note here is that merge by default will overwrite the arrays. To use concatenation for merge, use mergeAndConcatenation
See it in action here: https://runkit.com/pankaj/merge-anything
Stay tuned for tomorrow's package of the Day.




