Skip to content

Instantly share code, notes, and snippets.

@lohfu
Last active April 28, 2017 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lohfu/ef8b81e05014ef48d7d9341ec979733c to your computer and use it in GitHub Desktop.
Save lohfu/ef8b81e05014ef48d7d9341ec979733c to your computer and use it in GitHub Desktop.
'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