Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

lodash combine permissions

const roles = [
  { name: 'role1', permissions: { a: true, b: true, c: true } },
  { name: 'role2', permissions: { a: true, b: true, c: false } },
  { name: 'role3', permissions: { a: true } },
];

const _ = require('lodash');
const rolePermissions = _.map(roles, role => _.pickBy(role.permissions));
const permissions = _.assign({}, ...rolePermissions);

console.log(permissions);
 
PREVIOUS NEXT
Tagged: #lodash #combine #permissions
ADD COMMENT
Topic
Name
5+9 =