Package Exports
- bind-property-descriptor
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 (bind-property-descriptor) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
bind-property-descriptor 
Bind a property descriptor (value, getter and setter).
Install
Installation of the npm package:
> npm install --save bind-property-descriptorUsage
This test data will be used for the examples:
const emma = {
firstName: 'Emma',
lastName: 'Russel',
get fullName () {
return `${this.firstName} ${this.lastName}`
}
}bindPropertyDescriptor(descriptor, thisArg) → boundDescriptor
Creates a new property descriptor bound to an object.
The value (if a function), getter and/or setter will be called with the bound object.
import { bindPropertyDescriptor } from 'bind-property-descriptor'
const obj = {}
const descriptor = Object.getOwnPropertyDescriptor(emma, 'fullName')
const boundDescriptor = bindPropertyDescriptor(descriptor, emma)
Object.defineProperty(obj, 'fullName', boundDescriptor)
obj.fullName
// → Emma RusselgetBoundPropertyDescriptor(obj, prop, thisArg = obj) → boundDescriptor
Because it's a common case to first get the descriptor and then bind it, this helper is provided.
import { getBoundPropertyDescriptor } from 'bind-property-descriptor'
const obj = {}
const boundDescriptor = getBoundPropertyDescriptor(emma, 'fullName')
Object.defineProperty(obj, 'fullName', boundDescriptor)
obj.fullName
// → Emma RusselContributions
Contributions are very welcomed, either on the documentation or on the code.
You may:
- report any issue you've encountered;
- fork and create a pull request.
License
ISC © Julien Fontanet