@freelance_projects/permission-parser
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Permission parser

Usage

  1. First install the package using npm i
  2. Go to main.ts
  3. import definePermissions
  4. definePermissions takes an array of permission (found in types folder) as argument.
  5. Use getPermission() to parse number to string & string to number etc.

Example

main.ts

import { definePermissions, getPermissions } from 'permission-parser';

definePermissions([
  { access: 1, name: "Read" },
  { access: 2, name: "Write" },
  { access: 4, name: "Delete" },
  { access: 8, name: "Modify" },
]);
getPermissions(15); // Returns [1, 2, 4, 8]
getPermissions([1, 2, 4, 8]); // Returns ["Read", "Write", "Delete", "Modify"]
getPermissions(["Read", "Write", "Delete", "Modify"]); // Returns [1, 2, 4, 8]

Readme

Keywords

none

Package Sidebar

Install

npm i @freelance_projects/permission-parser

Weekly Downloads

0

Version

1.0.2

License

ISC

Unpacked Size

12.5 kB

Total Files

8

Last publish

Collaborators

  • matiasgrimm