# bit-mask

> A utility for manipulating bit masks

Latest version **1.0.2** (published 2018-04-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install bit-mask
pnpm add bit-mask
yarn add bit-mask
bun add bit-mask
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2018-04-18 |
| First published | 2012-12-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | * |
| Dependencies | 1 |
| Unpacked size | 8.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Abbey Hawk Sparrow |
| Maintainers | khrome |
| Keywords | bitmask, file mask, permissions |

## Links

- npm: https://www.npmjs.com/package/bit-mask
- Repository: https://github.com/khrome/bit-mask
- Issues: https://github.com/khrome/bit-mask/issues
- npm.io page: https://npm.io/package/bit-mask

## Dependencies (1)

- [array-events](https://npm.io/package/array-events.md) ^0.2.0

## Recent versions

- 1.0.2 (latest) — 2018-04-18
- 1.0.1 — 2016-12-20
- 1.0.0 — 2016-11-25
- 0.0.2-alpha — 2013-02-05
- 0.0.1-alpha — 2012-12-18

## README

bit-mask.js
==============

[![NPM version](https://img.shields.io/npm/v/bit-mask.svg)]()
[![npm](https://img.shields.io/npm/dt/bit-mask.svg)]()
[![Travis](https://img.shields.io/travis/khrome/bit-mask.svg)]()

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

---
_Source: https://npm.io/package/bit-mask · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
