Skip to content

Instantly share code, notes, and snippets.

@rubeniskov
Created May 19, 2015 16:23
Show Gist options
  • Save rubeniskov/657f80112f2ace0edc51 to your computer and use it in GitHub Desktop.
Save rubeniskov/657f80112f2ace0edc51 to your computer and use it in GitHub Desktop.
var flags = (function(masks, flags){
return function(flag, active){
(active == 1 && (flags|=masks[flag])) || (active == 0 && (flags&=~masks[flag]));
return !!(flags & masks[flag]);
}
})({
'state_1' : 0x1,
'state_2' : 0x2,
'state_3' : 0x4,
},0x0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment