Created
May 26, 2017 00:14
-
-
Save SuddenDevelopment/09718b4b60838b0c696fef00f5a6c7d1 to your computer and use it in GitHub Desktop.
javascript bitmask permissions
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
fnMayI=function(intPerms,strPerm){ | |
//intPerms is an dec number that conatins all of the permissions | |
//set these to your permissions map these are the binary positions of intPerms | |
var objPerms={ | |
"read":1 | |
,"update":2 | |
,"create":4 | |
,"props":16 | |
,"delete":64 | |
,"perms":65536 | |
}; | |
//return truthy falsey | |
return intPerms&objPerms[strPerm]; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment