0.1.0 • Published 4 years ago
extract-chain v0.1.0
extract-chain
Extract object's prototype chain properties, make them object's own properties.
Install
Install with npm:
$ npm install --save extract-chainUsage
with es modules
import extractChain from ' extract-chain';or with commonjs
const extractChain = require('extract-chain');var source={
 name:"James Clerk Maxwell",
 born:"June 13 1831",
 field:"Math"
}
var target=Object.create(source)
extractChain(target)
/*{
  name:"James Clerk Maxwell",
  born:"June 13 1831",
  field:"Math"
 }
*/
target.hasOwnProperty('name')//trueNOTE if object already has a property with same name it will be overwritten.If you don't want this specify property name in array.
var source={
 name:"James Clerk Maxwell",
 born:"June 13 1831",
 field:"Math"
}
var target=Object.create(source)
target.name="John"
extractChain(target, ["name"])
console.log(target.name)//JohnAbout
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
You can install dependencies and run tests with the following command:
$ npm install && npm testAuthor
Tahir Genç
License
Copyright © 2021, Tahir Genç. Released under the MIT License.