馃攽 Permission management made easy

Overview

stars license supportServer forks issues

Logo

Perman.JS

馃攽 Permission management made easy
Get support 禄

Report BugRequest FeatureWebpage

馃攽 Perman

Permission management made easy

馃摝 Installation

  • Using yarn: yarn add perman
  • Using npm: npm i perman

馃 Usage

See API for all methods

import { Perman } from "perman";

const perman = Perman.from(["user", "verified", "admin"]);

const user = perman.serialize(["user"]);
const verified = perman.serialize(["user", "verified"]);
const admin = perman.serialize(["user", "admin"]);

perman.has(user, "user"); // true
perman.has(user, "admin"); // false;
perman.has(verified, "verified"); // true;
perman.has(verified, "admin"); // false;
perman.has(admin, "admin"); // true;

// add permissions
perman.has(user, "verified"); // false;
user = perman.add(user, "verified");
perman.has(user, "verified"); // true;

// remove permissions
perman.has(verified, "verified"); // true;
verified = perman.remove(verified, "verified");
perman.has(verified, "verified"); // false;

馃搫 License

Copyright 漏 2022 Bar谋艧 DEM陌RC陌.

Distributed under the GPL-3.0 License. See LICENSE for more information.

馃Е Contributing

Fell free to use GitHub's features.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/my-feature)
  3. Run prettier (npm run format)
  4. Commit your Changes (git commit -m 'my awesome feature my-feature')
  5. Push to the Branch (git push origin feature/my-feature)
  6. Open a Pull Request

馃敟 Show your support

Give a 猸愶笍 if this project helped you!

馃摓 Contact

馃摐 API

Method Description Usage Output
from (static) Creates a new Perman instance <Perman>.from(flags: string[]) Perman
keys Returns all flag names perman.keys() string[]
values Returns all flag values perman.values() number[]
get Returns the numeric value of flag perman.get(flag: string) number
serialize Serializes the flags perman.serialize(flags: string[]) number
deserialize Deserializes the permission perman.deserialize(permissions: number) string[]
match Matches permissions with flags, if permissions has all flags, returns true perman.match(permissions: number, flags: string[]) boolean
matchAll (alias of match) Matches permissions with flags, if permissions has all flags, returns true perman.matchAll(permissions: number, flags: string[]) boolean
hasAll (alias of match) Matches permissions with flags, if permissions has all flags, returns true perman.hasAll(permissions: number, flags: string[]) boolean
some Matches permissions with flags, if permissions has at least one flag, returns true perman.some(permissions: number, flags: string[]) boolean
hasSome (alias of some) Matches permissions with flags, if permissions has at least one flag, returns true perman.hasSome(permissions: number, flags: string[]) boolean
hasNone Matches permissions with flags, if permissions has at least one flag, returns false perman.hasNone(permissions: number, flags: string[]) boolean
none (alias of hasNone) Matches permissions with flags, if permissions has at least one flag, returns false perman.hasNone(permissions: number, flags: string[]) boolean
has Checks if the given permission is granted perman.has(permission: number, flag: (number or string)) boolean
test (alias of has) Checks if the given permission is granted perman.test(permission: number, flag: (number or string)) boolean
add Adds a new flag to given permission perman.add(permission: number, flag: string) number
remove Removes a flag from given permission perman.remove(permission: number, flag: string) number
full Creates a permission with all flags perman.full() number
You might also like...

Mercure Provider - Real-time Made Easy

Mercure Provider - Real-time Made Easy

@setten/mercure is a Mercure client for AdonisJS. Mercure allows you to use Server Sent Events to push data to your clients using Http. Note You must

Nov 29, 2022

End-to-end typesafe APIs in Astro wesbites made easy

End-to-end typesafe APIs in Astro wesbites made easy

Astro x tRPC 馃殌 End-to-end typesafe APIs in Astro wesbites made easy View Demo 路 Report Bug 路 Request Feature 馃憢 Introducing astro-trpc astro-trpc is

Dec 30, 2022

jQuery based scrolling Bar, for PC and Smartphones (touch events). It is modern slim, easy to integrate, easy to use. Tested on Firefox/Chrome/Maxthon/iPhone/Android. Very light 7ko min.js and 1Ko min.css.

Nice-Scrollbar Responsive jQuery based scrolling Bar, for PC and Smartphones (touch events). It is modern slim, easy to integrate, easy to use. Tested

Jan 18, 2022

An easy to implement marquee JQuery plugin with pause on hover support. I know its easy because even I can use it.

Simple-Marquee Copyright (C) 2016 Fabian Valle An easy to implement marquee plugin. I know its easy because even I can use it. Forked from: https://gi

Aug 29, 2022

A knowledge management garden for https://obsidian.md, in which to grow your ideas

A knowledge management garden for https://obsidian.md, in which to grow your ideas

馃 馃尡 The Obsidian Garden Welcome to your Knowledge Garden The Obsidian Garden is both guide in helping you create your own knowledge system, and a kn

Dec 27, 2022

Volunteer management web application built for Sistering.

Sistering A volunteer management web application built for Sistering. Made with starter-code-v2, brought to you by the UW Blueprint Internal Tools tea

Oct 17, 2022

A form management library for SolidJS that is very lightweight and simple!

solform A form management library for SolidJS that is very lightweight and simple! Why solform Very easy, fast, lightweight and powerful! It has built

Nov 15, 2022

Firebase Angular Skeleton - Quickly create an application with a fully functional authentication, authorization and user management system.

Firebase Angular Skeleton - Quickly create an application with a fully functional authentication, authorization and user management system.

FAngS - Firebase Angular Skeleton FAngS lets you quickly create an application with a fully functional authentication, authorization and user manageme

Sep 21, 2022

A thin wrapper around arweave-js for versioned permaweb document management.

馃巵 ar-wrapper A thin wrapper around arweave-js for versioned permaweb document management. Helps to abstract away complexity for document storage for

May 12, 2022
Owner
Bar谋艧 DEM陌RC陌
Self-taught back-end developer with over 10 years experience. More interested in TypeScript, Go and Postgres. Loves to play Metroid games.
Bar谋艧 DEM陌RC陌
The Frontend of Escobar's Inventory Management System, Employee Management System, Ordering System, and Income & Expense System

Usage Create an App # with npx $ npx create-nextron-app my-app --example with-javascript # with yarn $ yarn create nextron-app my-app --example with-

Viver Bungag 4 Jan 2, 2023
An abstraction layer on top of @replit/crosis that makes Repl connection management and operations so easy, a Furret could do it! 馃帀

Crosis4Furrets An abstraction layer on top of @replit/crosis that makes Repl connection management and operations so easy, a Furret could do it! ?? In

Ray 18 Dec 29, 2022
Website to present projects made by me and that are part of my personal portfolio. It was made using React, HTML y Scss (CSS).

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

Portfolio Jes煤s Leal 0 Dec 23, 2021
A showcase of problems once hard or impossible to solve with CSS alone, now made trivially easy with Flexbox.

Solved by Flexbox A showcase of problems once hard or impossible to solve with CSS alone, now made trivially easy with Flexbox. View Site Viewing the

Philip Walton 13k Jan 2, 2023
Installing husky made easy as woof!

auto-husky Installing husky made easy as woof! ?? ?? Table of contents ?? Installation ?? Usage ?? Versioning ?? Installation You can install the pack

G.Script 24 Jun 28, 2022
Multiple users using the same leetcode account made easy!

LeetcodeSessionManager About This extension helps is multiple people using the same LeetCode account. It gets tiring when you create sessions(sub-acco

PAWAN JENU 34 Dec 20, 2022
Want to preserve your loved one's voices for eternity? Narrate anything using the a voice imprint that can be made in as little as 10 minutes of audio samples. Easy as pie.

Want to preserve your loved one's voices for eternity? Narrate anything using the a voice imprint that can be made in as little as 10 minutes of audio samples. Easy as pie.

Ari 15 Nov 29, 2022
馃捀 getting sponsored made easy with widgets !

Ponsor getting sponsored made easy through widgets Tech Stack A lot of different tech and soft wares were used to create Ponsor, here is a list of the

ashish 13 Jan 4, 2023
A mutex/semaphore implementation made easy to use.

A mutex/semaphore implementation made easy to use. Why superlock aims to be: Simple: Designed for usage with async and await Powerful: Mutex & Semapho

Kiko Beats 7 Dec 12, 2022
quASAR: ASAR manipulation made easy

quASAR quASAR: ASAR manipulation made easy This project is a proof-of-concept for manipulating ASAR files for code injection in Electron apps. This ca

Michael Taggart 19 Sep 25, 2022