1.0.5 • Published 7 years ago
@kingjs/descriptor.inherit v1.0.5
@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[]
): anyParameters
this: Object onto which inherited properties are copied.bases: An array of objects whose properties will be copied tothis.
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.inheritLicense
MIT