whispervis/web/js/shitty_hacks.js
2018-07-04 18:56:18 +02:00

19 lines
316 B
JavaScript

// accessorFn
function accessorFn(p) {
if (p instanceof Function) {
return p // fn
}
if (typeof p === 'string') {
return function(obj) {
return obj[p]; // property name
}
}
return function (obj){
return p; // constant
}
}
module.exports = accessorFn;