Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bit-mask

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bit-mask

A utility for manipulating bit masks

  • 0.0.2-alpha
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

bit-mask.js

An NPM for manipulating bit masks

Just a convenient abstraction for computing bitmasks, such as file permissions.

var BitMask = require('bit-mask');

Bit Masks

Declare a new BitMask with an initial value

var mask = new BitMask(value, [base]);

Set a particular bit with a boolean

mask.setBit(position, value)

get the boolean value of a particular bit

mask.getBit(position)

get the bits as a string of binary digits

maks.bits()

Ownership Mask

Declare a new Ownership Mask with an initial value

var mask = new BitMask.OwnershipMask(value);

Then you have all the functions from the BitMask plus you can get the permissions in a more readable way with:

mask.hasPermission(context, permission)

where context is 'user', 'group' or 'world' and permission is 'read', 'write', 'execute' and a corresponding set:

mask.setPermission(context, permission, value)

as well as a modify function which allows you to pass chmod style modifier strings as well as integer values.

mask.modify('ugo+rwx')
mask.modify(755);

Testing

Run the tests at the project root with:

mocha

Enjoy,

-Abbey Hawk Sparrow

Keywords

FAQs

Package last updated on 05 Feb 2013

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc