MCPcopy Create free account
hub / github.com/denoland/std / mergeMappings

Method mergeMappings

yaml/_loader_state.ts:430–460  ·  view source on GitHub ↗
(
    destination: Record<string, unknown>,
    source: Record<string, unknown>,
    overridableKeys: Set<string>,
  )

Source from the content-addressed store, hash-verified

428 if (detected) return { tag, anchor, kind: "sequence", result };
429 }
430 mergeMappings(
431 destination: Record<string, unknown>,
432 source: Record<string, unknown>,
433 overridableKeys: Set<string>,
434 ) {
435 if (!isObject(source)) {
436 throw this.#createError(
437 "Cannot merge mappings: the provided source object is unacceptable",
438 );
439 }
440
441 for (const [key, value] of Object.entries(source)) {
442 if (Object.hasOwn(destination, key)) continue;
443 // `Object.defineProperty` is significantly slower than direct
444 // assignment in V8. Direct assignment produces an identical descriptor
445 // (writable/enumerable/configurable) for ordinary keys; the only
446 // sensitive case is `__proto__`, where direct assignment would mutate
447 // the prototype chain instead of creating an own property.
448 if (key === "__proto__") {
449 Object.defineProperty(destination, key, {
450 value,
451 writable: true,
452 enumerable: true,
453 configurable: true,
454 });
455 } else {
456 destination[key] = value;
457 }
458 overridableKeys.add(key);
459 }
460 }
461 storeMappingPair(
462 result: Record<string, unknown>,
463 overridableKeys: Set<string>,

Callers 1

storeMappingPairMethod · 0.95

Calls 4

#createErrorMethod · 0.95
isObjectFunction · 0.90
entriesMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected