MCPcopy
hub / github.com/chartjs/Chart.js / merge

Function merge

src/helpers/helpers.core.ts:260–285  ·  view source on GitHub ↗
(target: T, source: AnyObject[], options?: MergeOptions)

Source from the content-addressed store, hash-verified

258): T & S1 & S2 & S3 & S4;
259export function merge<T>(target: T, source: AnyObject[], options?: MergeOptions): AnyObject;
260export function merge<T>(target: T, source: AnyObject[], options?: MergeOptions): AnyObject {
261 const sources = isArray(source) ? source : [source];
262 const ilen = sources.length;
263
264 if (!isObject(target)) {
265 return target as AnyObject;
266 }
267
268 options = options || {};
269 const merger = options.merger || _merger;
270 let current: AnyObject;
271
272 for (let i = 0; i < ilen; ++i) {
273 current = sources[i];
274 if (!isObject(current)) {
275 continue;
276 }
277
278 const keys = Object.keys(current);
279 for (let k = 0, klen = keys.length; k < klen; ++k) {
280 merger(keys[k], target, current, options as AnyObject);
281 }
282 }
283
284 return target;
285}
286
287/**
288 * Recursively deep copies `source` properties into `target` *only* if not defined in target.

Callers 6

AppFunction · 0.90
AppAutoFunction · 0.90
registerDefaultsFunction · 0.85
setFunction · 0.85
_mergerFunction · 0.85
mergeIfFunction · 0.85

Calls 2

isArrayFunction · 0.85
isObjectFunction · 0.85

Tested by

no test coverage detected