define-binding

1.0.2 • Public • Published

define-binding

Define a property which looks normal but is a binding to another object's field

import defineBinding from "define-binding"
var propertyBag= {a: 1, b: 42}
var o= {}
defineBinding( o, "bByO", propertyBag, "b")

// this binding is enumerable, so it iterates
Object.keys(o).next().value //=> "bByO"

// this binding is configurable, so it can be overwritten
o.bByO //=> 42
o.bByO= 6*9
// o has a new property, original property is intact
propertyBag.b //=> 42

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.2
    2
  • 1.0.1
    2
  • 1.0.0
    3

Package Sidebar

Install

npm i define-binding

Weekly Downloads

7

Version

1.0.2

License

X11

Last publish

Collaborators

  • rektide