📜  lodash 组合权限 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:38.604000             🧑  作者: Mango

代码示例1
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);