1.0.2 • Published 5 months ago

@freelance_projects/permission-parser v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago
  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.

main.ts

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]
1.0.2

5 months ago

1.0.1

5 months ago