node-fence
Version:
Flexible and Fluent way to manage ACL in Node.js.
28 lines (21 loc) • 596 B
JavaScript
const co = require('co')
class Helpers {
/**
* @static
* @method formatResourceName
* @param {function|object} resource
* @return {string}
*/
static formatResourceName (resource) {
if (typeof resource === 'function') {
return resource.name
} else if (typeof resource === 'object' && resource.constructor.name !== 'Object') {
return resource.constructor.name
} else if (typeof resource === 'object' && resource.constructor.name === 'Object') {
return resource._className
}
return resource
}
}
module.exports = Helpers