UNPKG

@fluentui/styles

Version:
36 lines (33 loc) 1.17 kB
var isObject = function isObject(o) { return o !== null && typeof o === 'object' && !Array.isArray(o); }; var isValid = function isValid(k) { return k !== '__proto__' && k !== 'prototype' && k !== 'constructor'; }; // Heads Up! // Changes here need to consider breaking all object references. // Merging should result in a themes that are non-mutated and have broken references. export var deepmerge = function deepmerge() { var inner = function inner(target, source) { Object.keys(source).forEach(function (k) { if (isValid(k)) { if (isObject(source[k])) { if (!isObject(target[k])) { target[k] = {}; } inner(target[k], source[k]); } else { target[k] = source[k]; // TODO: do deep clone for arrays? We currently do not have any deep arrays in variables } } }); return target; }; for (var _len = arguments.length, sources = new Array(_len), _key = 0; _key < _len; _key++) { sources[_key] = arguments[_key]; } return sources.filter(Boolean).reduce(function (acc, src) { return inner(acc, src); }, {}); }; //# sourceMappingURL=deepmerge.js.map