@kingjs/mutate.inherit

Copy properties from set of objects which are not present on this.

Stats

StarsIssuesVersionUpdatedCreatedSize
@kingjs/mutate.inherit
1.0.63 years ago3 years agoMinified + gzip package size for @kingjs/mutate.inherit in KB

Readme

@kingjs/mutate.inherit

Copy properties from set of objects which are not present on this.

Usage

Assign default student teacher properties for Alice like this:

var inherit = require('@kingjs/mutate.inherit');

var student = { name: '', ssn: '000-00-0000', credits: 0 };
var teacher = { name: '', ssn: '000-00-0000', pay: 0 };
var alice = { name: 'Alice' };

inherit.call(alice, student, teacher);

result:

{
  name: 'Alice',
  ssn: '00-000-0000',
  credits: 0,
  pay: 0,
}

API

declare function inherit(
  this: any,
  bases: any[]
): any

Parameters

  • this: Object onto which inherited properties are copied.
  • bases: An array of objects whose properties will be copied to this.

    Returns

    Returns this after copying properties from bases.

    Remarks

    Throws if inherited properties that share the same name do not also have the same value.

    Install

    With npm installed, run
    $ npm install @kingjs/mutate.inherit
    

    License

    MIT

Analytics

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.