-
-
Save lkmill/ef8b81e05014ef48d7d9341ec979733c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const _ = require('lodash'); | |
module.exports = (permissions, requiredPermissions) => { | |
if (!_.isPlainObject(requiredPermissions)) { | |
throw new TypeError('`requiredPermissions` is not an object'); | |
} else if (!_.isPlainObject(permissions)) { | |
throw new TypeError('`permissions` is not an object'); | |
} else { | |
for (const key in requiredPermissions) { | |
if (!permissions[key] || permissions[key] & requiredPermissions[key] !== requiredPermissions[key]) { | |
return false; | |
} | |
} | |
return true; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment