JS library for merging objects like Object.assign but it takes the most frequent value instead of the last value
how to install?
yarn add merge-most-frequent or
npm i --save merge-most-frequent
how to use?
const mergeMostFrequent = default;/** or:* import mergeMostFrequent from 'merge-most-frequent';*/const objects =foo: 'foo1'bar: 'bar1'baz: 'baz1'foo: 'foo1'bar: 'bar2'baz: 'baz2'foo: 'foo2'bar: 'bar2'baz: 'baz1';todeep;
how does it work?
- for each field, it returns the most frequent value
- if many values occur for the same number of times, the most recently used value wins
- a field has to occur in at least one of the objects, to be included in the result