First release
This commit is contained in:
commit
fa6c85266e
2339 changed files with 761050 additions and 0 deletions
27
node_modules/mpd-parser/src/utils/object.js
generated
vendored
Normal file
27
node_modules/mpd-parser/src/utils/object.js
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
const isObject = (obj) => {
|
||||
return !!obj && typeof obj === 'object';
|
||||
};
|
||||
|
||||
export const merge = (...objects) => {
|
||||
|
||||
return objects.reduce((result, source) => {
|
||||
|
||||
if (typeof source !== 'object') {
|
||||
return result;
|
||||
}
|
||||
|
||||
Object.keys(source).forEach(key => {
|
||||
|
||||
if (Array.isArray(result[key]) && Array.isArray(source[key])) {
|
||||
result[key] = result[key].concat(source[key]);
|
||||
} else if (isObject(result[key]) && isObject(source[key])) {
|
||||
result[key] = merge(result[key], source[key]);
|
||||
} else {
|
||||
result[key] = source[key];
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}, {});
|
||||
};
|
||||
|
||||
export const values = o => Object.keys(o).map(k => o[k]);
|
Loading…
Add table
Add a link
Reference in a new issue