foop
Version:
interfaces that describe their intentions.
20 lines (16 loc) • 422 B
JavaScript
const isUndefined = require('../deps/is/undefined')
function copySetIntoFunction(name, parent) {
const auto = arg => {
if (isUndefined(arg)) {
parent.get(name)
}
else {
parent.set(name, arg)
Object.assign(parent[name], arg)
}
}
// so we know if we defaulted them
auto.getterOnSet = true
return this.onSet(auto).onGet(auto).onCall(auto)
}
module.exports = copySetIntoFunction