Skip to content

Instantly share code, notes, and snippets.

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