Answers for "lodash combine permissions"

1

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);
Posted by: Guest on October-26-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language