permission-nodes

    1.0.2 • Public • Published

    Build Status PRs Welcome js-standard-style

    Node based permissions for JavaScript.

    Setup

    Install with npm

    npm i --save permission-nodes

    Require permission-nodes, create a new PermissionNodes and pass in a permission object (optional). You can import an existing, exported, permissions object here. (see below for .export()).

    const PermissionNodes = require('permission-nodes');
    const perm = new PermissionNodes({
      permissionObject: {
        matt: {},
      },
    });

    Usage

    .give()

    give permission node...

    perm.give('matt').node('javascript');

    ...or give a bunch of nodes

    perm.give('matt')
      .node('javascript')
      .node('github.fork')
      .node('github.pr')
      .node('github.issue');

    .have()

    check for a permission node...

    perm.does('matt').have().node('javascript'); // true

    ...or check for a bunch of nodes

    perm.does('matt').have().nodes([
      'javascript',
      'github.fork',
      'github.pr',
      'github.pr',
    ]); // true

    .take()

    take a permission node away...

    perm.take('matt').node('javascript.ninja.sword');

    ...or take away a bunch of nodes...

    perm.take('matt')
      .node('github.fork')
      .node('github.pr')
      .node('github.pr');

    ...or a whole group

    perm.take('matt').node('github');

    .import()

    hotload a new permissions object

    perm.import({your: 'permissions'});

    .export()

    export the current permissions object

    perm.export(); // [object Object]

    Install

    npm i permission-nodes

    DownloadsWeekly Downloads

    2

    Version

    1.0.2

    License

    ISC

    Last publish

    Collaborators

    • mdwisniewski