Generate setter functions from string paths.
$ component install timoxley/setter
var setter = require('setter')
var widget = {
enabled: false
}
var setEnabled = setter(widget, 'enabled')
console.log(widget.enabled) // => false
setEnabled(true)
console.log(widget.enabled) // => true
var user = {
name: {
first: 'Tim',
last: 'Oxley'
}
}
var setFirstName = setter(user, 'name.first')
setFirstName('Timothy')
console.log(user.name.first) // => 'Timothy')
var user = {}
var setFirstName = setter(user, 'name.first')
setFirstName('Timothy')
console.log(user.name.first) // => 'Timothy'
var user = {}
var setFirstName = setter('name.first')
setFirstName(user, 'Timothy')
console.log(user.name.first) // => 'Timothy'
var user = {}
user.setFirstName = setter('name.first')
user.setFirstName('Timothy')
console.log(user.name.first) // => 'Timothy'
MIT