@kingjs/descriptor.merge

1.0.10 • Public • Published

@kingjs/descriptor.merge

Merges descriptor property values into this from delta using a callback to resolve conflicts.

Usage

Copy properties from source to target overwriting any existing values like this:

var merge = require('@kingjs/descriptor.merge');

var target = { 
  a: 0,
  b: 1, 
};

var source = { 
  b: 2,
  c: 3
};

function resolve(right, left) { 
  return right; 
}

merge.call(target, source, resolve); 

target;

result:

{
  a: 0,
  b: 2,
  c: 3
}

API

declare function merge(
  this: Descriptor, 
  delta?: Descriptor, 
  resolve?: (this, left, right, name: string) => any,
  thisArg?
): any

Interfaces

Parameters

  • this: An object into which properties are merged.
  • delta: An object whose properties are merged into this.
  • resolve: Invoked when merging into an existing value. Returns the merged value. If not supplied, then the existing value is taken.
    • left: The existing value.
    • right: The new value.
    • name: The name of the conflicting property.
  • thisArg: The this argument to pass to callback.write and returned instead of this.

Returns

Returns this after merging properties from delta.

Install

With npm installed, run

$ npm install @kingjs/descriptor.merge

License

MIT

Analytics

Readme

Keywords

none

Package Sidebar

Install

npm i @kingjs/descriptor.merge

Weekly Downloads

0

Version

1.0.10

License

MIT

Unpacked Size

4.17 kB

Total Files

4

Last publish

Collaborators

  • kingces95