JSPM

extract-chain

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 9
  • Score
    100M100P100Q25046F
  • License MIT

extract object's prototype chain properties

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-chain

Usage

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')//true

NOTE 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 test

Author

Tahir Genç

License

Copyright © 2021, Tahir Genç. Released under the MIT License.