Skip to content

Latest commit

 

History

History
26 lines (20 loc) · 478 Bytes

README.md

File metadata and controls

26 lines (20 loc) · 478 Bytes

rability

Simple authorization library inspired by cancancan

Installation

npm install rability

Usage

import { can, cannot, define, read, view } from "rability";

const eat = (something) => `eat${something}`;

const permission = define(
  can([read, view], "Book"),
  cannot(eat, "Candies"),
  can(view, ["TV", "YouTube"])
);

permission.readBook() // true
permission.viewTV() // true
permission.viewYouTube() // true
permission.eatCandies() // false