-
-
Save Be1zebub/5ccef6207decd7565d29ac07dfe842d6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const PERMISSIONS = { | |
READ: 1, | |
WRITE: 2, | |
EXECUTE: 4, | |
DELETE: 8, | |
ADMIN: 16, | |
} | |
const permissions = new BitMask() | |
permissions | |
.add(PERMISSIONS.READ) | |
.add(PERMISSIONS.WRITE) | |
.add(PERMISSIONS.EXECUTE) | |
console.log("Permissions value:", permissions.getValue()) | |
console.log("Has READ:", permissions.has(PERMISSIONS.READ)) | |
console.log("Has DELETE:", permissions.has(PERMISSIONS.DELETE)) | |
console.log("Binary:", permissions.toBinary()) | |
console.log("Active permissions:", permissions.toArray()) | |
const features = BitMask.fromArray([1, 4, 16]) | |
console.log("Features:", features.getValue()) | |
const bigMask = new BitMask(0, true) | |
bigMask.add(2n ** 50n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment