
Security News
AI Agent Lands PRs in Major OSS Projects, Targets Maintainers via Cold Outreach
An AI agent is merging PRs into major OSS projects and cold-emailing maintainers to drum up more work.
generic-bitmask
Advanced tools
This module enables easy manipulation and usage of bitmasking technique in JavaScript.
A bit mask is a binary number or a bitmap where the desired bit(s) are one and the remaining 0. By performing a bitwise AND operation of a value with a bitmask, one can test for certain bits being on.
Using a bitmask, it is very easy to store the boolean status of multiple flags in a single variable (of higher base.) A very common use case is to store "permission" value for an object. For example, whether an entity has read or write permission to an object can be determined easily by storing two flags "read" and "write" within a single variable.
More details on this detailed Wikipedia article on Bitmasking.
Installation can be done using npm for using in NodeJS applications.
npm install generic-bitmask --save-dev;
var Bitmask = require('generic-bitmask').Mask;
// create a new instance of bitmask
var mask = new Bitmask();
// Set the mask flags for the mask
mask.add(3); // sets 3rd bit to positive
mask.add(5); // sets 5th bit to positive
// check which bit is set to true
console.log(mask.test(3)); // logs true;
console.log(mask.test(4)); // logs false;
// remove a bit that has been set as true
mask.remove(5);
console.log(mask.test(5)); // logs false;
// Get the raw state of the mask in decimal value
console.log(mask.get()); // logs 8;
// Set the raw state of the mask. Useful to load saved mask state
mask.set(40); // sets 3 and 5 to true;
console.log(mask.test(3)); // logs true;
console.log(mask.test(4)); // logs false;
console.log(mask.test(5)); // logs true;
console.log(mask.test([3, 5])); // logs true;
var Bitmask = require('generic-bitmask').Mask,
Descriptor = require('generic-bitmask').Descriptor;
// create a new instance of bitmask
var mask = new Bitmask(),
descriptors = new Descriptor({
read: 1,
write: 2
});
// Set the mask flags for the mask
descriptor.add('read', mask);
descriptor.validate('read', mask);
descriptor.remove('read', mask);
FAQs
Module to compute and manipulate bitmasks in JavaScript
The npm package generic-bitmask receives a total of 800 weekly downloads. As such, generic-bitmask popularity was classified as not popular.
We found that generic-bitmask demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
An AI agent is merging PRs into major OSS projects and cold-emailing maintainers to drum up more work.

Research
/Security News
Chrome extension CL Suite by @CLMasters neutralizes 2FA for Facebook and Meta Business accounts while exfiltrating Business Manager contact and analytics data.

Security News
After Matplotlib rejected an AI-written PR, the agent fired back with a blog post, igniting debate over AI contributions and maintainer burden.