Is this a smart alternative to creating a object of functions? Benefits? Downsides?
var _ = require("underscore")
function functionName(fn){
//http://stackoverflow.com/a/17923727/340688
return /^function\s+([\w\$]+)\s*\(/.exec(fn.toString())[1]
}
function objecfify(arr){
return _.chain(arr)
.map(function(fn){
return [functionName(fn), fn]
})
.object()
.value()
}
var model = objecfify([
function create(){
return "create"
},
function read(){
return "read"
},
function update(){
return "update"
},
function remove(){
return "delete"
}
])
console.log(model)