This package has been deprecated

Author message:

see @kingjs/mutate.copy

@kingjs/copy

1.0.3 • Public • Published

@kingjs/copy

Copies own and inherited enumerable property values optionally skipping those already defined.

Usage

Copy properties from source to target like this:

var copy = require('@kingjs/copy');

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

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

copy(target, source); 

result:

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

API

declare function copy(
  target, 
  source?, 
  skipIfDefined?: boolean | (name) => boolean,
): any

Parameters

  • target: An object to which properties are copied.
  • source: An object whose properties are copied to target.
  • skipIfDefined: Prevent overwriting:
    • If true.
    • If a function that returns true given:
      • name: The name of the existing property.

Returns

Returns the target with properties copied from source.

Remarks

Inherited and own properties are copied.

Non-enumerable properties are not copied.

Install

With npm installed, run

$ npm install @kingjs/copy

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @kingjs/copy

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

2.95 kB

Total Files

4

Last publish

Collaborators

  • kingces95