@kingjs/descriptor.inherit

1.0.5 • Public • Published

@kingjs/descriptor.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/descriptor.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/descriptor.inherit

License

MIT

Analytics

/@kingjs/descriptor.inherit/

    Package Sidebar

    Install

    npm i @kingjs/descriptor.inherit

    Weekly Downloads

    8

    Version

    1.0.5

    License

    MIT

    Unpacked Size

    4.05 kB

    Total Files

    4

    Last publish

    Collaborators

    • kingces95