mirror of
https://github.com/status-im/whispervis.git
synced 2025-02-19 16:34:34 +00:00
19 lines
316 B
JavaScript
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;
|