-
-
Save joepie91/b8c8c7374b73f15ca15d3bfff0867503 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] == null || (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