Package Exports
- extract-chain
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (extract-chain) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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)//John
About
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Running Tests
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.