Skip to content

Commit

Permalink
Update sanctuary-scripts to version 1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
greenkeeper[bot] authored and Avaq committed May 1, 2018
1 parent a468380 commit 3aecd39
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
16 changes: 15 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,19 @@
"extends": ["./node_modules/sanctuary-style/eslint-es3.json"],
"env": {
"node": true
}
},
"overrides": [
{
"files": ["*.md"],
"plugins": ["markdown"],
"env": {"es6": true},
"globals": {"checkPermission": false, "findRoles": false},
"rules": {
"strict": ["off"],
"no-extra-semi": ["off"],
"semi-style": ["off"],
"semi": ["off"]
}
}
]
}
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![Dependencies](https://david-dm.org/Avaq/permissionary.svg)](https://david-dm.org/Avaq/permissionary)
[![Build Status](https://travis-ci.org/Avaq/permissionary.svg?branch=master)](https://travis-ci.org/Avaq/permissionary)
[![Code Coverage](https://codecov.io/gh/Avaq/permissionary/branch/master/graph/badge.svg)](https://codecov.io/gh/Avaq/permissionary)
[![Greenkeeper badge](https://badges.greenkeeper.io/Avaq/permissionary.svg)](https://greenkeeper.io/)

Tiny and framework-agnostic role-based permission management using
a model of *composition* over inheritance.
Expand Down Expand Up @@ -40,7 +41,7 @@ assign both roles to that user.

## API

<h4 name="checkPermission"><code><a href="https://github.com/Avaq/permissionary/blob/v0.1.0/index.js#L49">checkPermission :: StrMap (Array String) -⁠> Array String -⁠> String -⁠> Boolean</a></code></h4>
#### <a name="checkPermission" href="https://github.com/Avaq/permissionary/blob/v0.0.0/index.js#L50">`checkPermission :: StrMap (Array String) -⁠> Array String -⁠> String -⁠> Boolean`</a>

A [curried][5] function that takes three arguments and returns a Boolean:

Expand Down Expand Up @@ -85,7 +86,7 @@ canAlice('users.create');
true
```

<h4 name="findRoles"><code><a href="https://github.com/Avaq/permissionary/blob/v0.1.0/index.js#L112">findRoles :: StrMap (Array String) -⁠> String -⁠> Array String</a></code></h4>
#### <a name="findRoles" href="https://github.com/Avaq/permissionary/blob/v0.0.0/index.js#L113">`findRoles :: StrMap (Array String) -⁠> String -⁠> Array String`</a>

A [curried][5] function that takes two arguments and returns an Array
of role names:
Expand Down
19 changes: 10 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
//.
//. ## Usage
//.
//. <!-- eslint-disable no-unused-vars -->
//. ```js
//. var {checkPermission, findRoles} = require('permissionary');
//. ```
Expand Down Expand Up @@ -69,26 +70,26 @@ var hasProp = Object.prototype.hasOwnProperty;
//. > var createVerifier = checkPermission({
//. . 'content-reader': ['content.read', 'images.read'],
//. . 'content-writer': ['content.write', 'images.upload'],
//. . 'superadmin': ['*']
//. . });
//. . 'superadmin': ['*']
//. . })
//.
//. // Let's say our user Bob is a content-reader, and also a content-writer.
//. > var canBob = createVerifier(['content-reader', 'content-writer']);
//. > var canBob = createVerifier(['content-reader', 'content-writer'])
//.
//. // And Alice is an administrator.
//. > var canAlice = createVerifier(['superadmin']);
//. > var canAlice = createVerifier(['superadmin'])
//.
//. // Bob has this permission through his content-reader role.
//. > canBob('content.read');
//. > canBob('content.read')
//. true
//.
//. // Bob does not have this permission.
//. > canBob('users.create');
//. > canBob('users.create')
//. false
//.
//. // Alice, however, does. She has all permissions (even the ones
//. // we haven't thought of yet).
//. canAlice('users.create');
//. canAlice('users.create')
//. true
//. ```
function checkPermission(grants, roles, permission) {
Expand Down Expand Up @@ -126,8 +127,8 @@ function checkPermission(grants, roles, permission) {
//. > var getRequiredRoles = findRoles({
//. . 'content-reader': ['content.read', 'images.read'],
//. . 'content-writer': ['content.write', 'images.upload'],
//. . 'superadmin': ['*']
//. . });
//. . 'superadmin': ['*']
//. . })
//.
//. > getRequiredRoles('content.read')
//. ['content-reader', 'superadmin']
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
},
"devDependencies": {
"codecov": "^3.0.0",
"sanctuary-scripts": "^1.0.1"
"sanctuary-scripts": "^1.5.0"
}
}

0 comments on commit 3aecd39

Please sign in to comment.