bitwise-operation
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -6,2 +6,3 @@ declare type BitwiseValue = number | string | Array<0 | 1> | Bitwise; | ||
constructor(value?: BitwiseValue); | ||
static chain(value?: BitwiseValue): Bitwise; | ||
static not(value: number): number; | ||
@@ -8,0 +9,0 @@ static and(value: BitwiseValue, ...values: BitwiseValue[]): number; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Bitwise = void 0; | ||
class Bitwise { | ||
@@ -27,2 +26,5 @@ constructor(value = 0) { | ||
} | ||
static chain(value = 0) { | ||
return new Bitwise(value); | ||
} | ||
static not(value) { | ||
@@ -150,3 +152,6 @@ return ~value; | ||
xor(value) { | ||
this.value = this.copy().or(value).and(this.copy().and(value).not()).valueOf(); | ||
this.value = this.copy() | ||
.or(value) | ||
.and(this.copy().and(value).not()) | ||
.valueOf(); | ||
return this; | ||
@@ -195,3 +200,3 @@ } | ||
return this; | ||
this.value |= Bitwise.xor((1 << from) - 1, (1 << to << 1) - 1); | ||
this.value |= Bitwise.xor((1 << from) - 1, ((1 << to) << 1) - 1); | ||
return this; | ||
@@ -202,3 +207,3 @@ } | ||
return this; | ||
this.value &= ~Bitwise.xor((1 << from) - 1, (1 << to << 1) - 1); | ||
this.value &= ~Bitwise.xor((1 << from) - 1, ((1 << to) << 1) - 1); | ||
return this; | ||
@@ -210,3 +215,7 @@ } | ||
const mask = Bitwise.mask(from, to); | ||
this.value = this.copy().not().and(mask).or(this.copy().and(Bitwise.not(mask))).valueOf(); | ||
this.value = this.copy() | ||
.not() | ||
.and(mask) | ||
.or(this.copy().and(Bitwise.not(mask))) | ||
.valueOf(); | ||
return this; | ||
@@ -272,3 +281,3 @@ } | ||
} | ||
Bitwise.VERSION = "2.0.1"; | ||
exports.Bitwise = Bitwise; | ||
Bitwise.VERSION = "2.0.0"; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./Bitwise"), exports); | ||
__export(require("./Bitwise")); |
100
package.json
{ | ||
"author": { | ||
"name": "Gwenael Walet", | ||
"email": "gwenael.walet@yahoo.fr" | ||
}, | ||
"devDependencies": { | ||
"eslint": "1.10.x", | ||
"qunit-cli": "~0.2.0", | ||
"qunitjs": "^1.18.0" | ||
}, | ||
"scripts": { | ||
"tsc": "tsc", | ||
"test": "npm run test-node && npm run lint", | ||
"coverage": "nyc npm run test-node && nyc report", | ||
"coveralls": "nyc npm run test-node && nyc report --reporter=text-lcov | coveralls", | ||
"lint": "eslint bitwise.js", | ||
"test-node": "qunit-cli test/tests.js", | ||
"minify": "uglifyjs bitwise.js -c \"evaluate=false\" --comments \"/ .*/\" -m", | ||
"build": "npm run minify -- --source-map bitwise-min.map --source-map-url \" \" -o bitwise-min.js" | ||
}, | ||
"dependencies": {}, | ||
"description": "JavaScript's bitwise operation helper library.", | ||
"directories": {}, | ||
"files": [ | ||
"lib/**/*", | ||
"index.js", | ||
"LICENSE" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Relik77/bitwise-operation.git" | ||
}, | ||
"keywords": [ | ||
"util", | ||
"functional", | ||
"server", | ||
"client", | ||
"browser" | ||
], | ||
"license": "MIT", | ||
"main": "index.js", | ||
"maintainers": [ | ||
{ | ||
"name": "Gwenael Walet", | ||
"email": "gwenael.walet@yahoo.fr" | ||
} | ||
], | ||
"name": "bitwise-operation", | ||
"optionalDependencies": {}, | ||
"readme": "ERROR: No README data found!", | ||
"version": "2.0.0" | ||
"author": { | ||
"name": "Gwenael Walet", | ||
"email": "gwenael.walet@yahoo.fr" | ||
}, | ||
"devDependencies": { | ||
"eslint": "1.10.x", | ||
"qunit-cli": "~0.2.0", | ||
"qunitjs": "^1.18.0" | ||
}, | ||
"scripts": { | ||
"tsc": "tsc", | ||
"test": "npm run test-node && npm run lint", | ||
"coverage": "nyc npm run test-node && nyc report", | ||
"coveralls": "nyc npm run test-node && nyc report --reporter=text-lcov | coveralls", | ||
"lint": "eslint bitwise.js", | ||
"test-node": "qunit-cli test/tests.js", | ||
"minify": "uglifyjs bitwise.js -c \"evaluate=false\" --comments \"/ .*/\" -m", | ||
"build": "npm run minify -- --source-map bitwise-min.map --source-map-url \" \" -o bitwise-min.js" | ||
}, | ||
"dependencies": {}, | ||
"description": "JavaScript's bitwise operation helper library.", | ||
"directories": {}, | ||
"files": [ | ||
"lib/**/*", | ||
"LICENSE" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Relik77/bitwise-operation.git" | ||
}, | ||
"keywords": [ | ||
"util", | ||
"functional", | ||
"server", | ||
"client", | ||
"browser" | ||
], | ||
"license": "MIT", | ||
"main": "./lib/index.js", | ||
"typings": "./lib/index.d.ts", | ||
"maintainers": [ | ||
{ | ||
"name": "Gwenael Walet", | ||
"email": "gwenael.walet@yahoo.fr" | ||
} | ||
], | ||
"name": "bitwise-operation", | ||
"optionalDependencies": {}, | ||
"readme": "README.md", | ||
"version": "2.0.1" | ||
} |
418
README.md
@@ -1,11 +0,7 @@ | ||
Node.js: bitwise-operation | ||
================= | ||
# Node.js: bitwise-operation | ||
`bitwise-operation` is a JavaScript library that provides useful bitwise operation helpers without converting integer to an array. | ||
## Installation | ||
Installation | ||
------------ | ||
**Node.js** `npm install --save bitwise-operation` | ||
@@ -15,10 +11,11 @@ | ||
**Require in Node** `var Bitwise = require('bitwise-operation');` | ||
**Require in Node** `var Bitwise = require('bitwise-operation');` | ||
**Import in Node** `import { Bitwise } from "bitwise-operation";` | ||
**Broser** `<script src="/node_modules/bitwise-operation/bitwise.js"></script>` | ||
## Methods | ||
Methods | ||
------- | ||
- [Bitwise](#bitwise) | ||
- [chain](#chain) | ||
- [not](#not) | ||
@@ -50,32 +47,34 @@ - [and](#and) | ||
### Bitwise() | ||
**new Bitwise(value)** | ||
**Bitwise(value)** | ||
**new Bitwise(value)** | ||
Create a bitwise object to chain operations. | ||
Example: | ||
```js | ||
var Bitwise = require('bitwise-operation') | ||
```ts | ||
import { Bitwise } from "bitwise-operation"; | ||
Bitwise(0b0100) | ||
.and(0b1100) | ||
.or(0b0010) | ||
.valueOf(); | ||
new Bitwise(0b1011); | ||
=> 0b0110 | ||
var value = new Bitwise([1, 1, 0, 1]); | ||
value.valueOf(); // 0b1011 | ||
Bitwise([0, 0, 1, 0]) | ||
.valueOf(); | ||
new Bitwise("1011"); | ||
``` | ||
=> 0b0100 | ||
### chain() | ||
Bitwise("1011") | ||
.valueOf(); | ||
**Bitwise.chain(value)** | ||
=> 0b1011 | ||
Create a bitwise object to chain operations. | ||
Example: | ||
```ts | ||
import { Bitwise } from "bitwise-operation"; | ||
Bitwise.chain(0b0100).and(0b1100).or(0b0010).valueOf(); | ||
// => 0b0110 | ||
``` | ||
@@ -85,4 +84,4 @@ | ||
**Bitwise.not(value)** | ||
**Bitwise(value).not()** | ||
**Bitwise.not(value)** | ||
**Bitwise.chain(value).not()** | ||
@@ -94,17 +93,14 @@ Performs a logical **NOT** of this target bit set. | ||
| --|-------| | ||
| 0 | 1 | | ||
| 1 | 0 | | ||
| 0 | 1 | | ||
| 1 | 0 | | ||
Example: | ||
```js | ||
var Bitwise = require('bitwise-operation') | ||
```ts | ||
import { Bitwise } from "bitwise-operation"; | ||
Bitwise.not(0b1010); | ||
Bitwise.chain(0b1010).not().valueOf(); | ||
Bitwise(0b1010) | ||
.not() | ||
.valueOf(); | ||
=> 0b0101 | ||
// => 0b0101 | ||
``` | ||
@@ -115,3 +111,3 @@ | ||
**Bitwise.and(...values)** | ||
**Bitwise(value).and(value)** | ||
**Bitwise.chain(value).and(value)** | ||
@@ -123,20 +119,17 @@ Performs a logical **AND** of this target bit set with the argument bit set. | ||
|---|---|---------| | ||
| 0 | 0 | 0 | | ||
| 0 | 1 | 0 | | ||
| 1 | 0 | 0 | | ||
| 1 | 1 | 1 | | ||
| 0 | 0 | 0 | | ||
| 0 | 1 | 0 | | ||
| 1 | 0 | 0 | | ||
| 1 | 1 | 1 | | ||
Example: | ||
```js | ||
var Bitwise = require('bitwise-operation') | ||
```ts | ||
import { Bitwise } from "bitwise-operation"; | ||
Bitwise.and(0b0111, Bitwise(0b0101), 0b1100); | ||
Bitwise(0b0111) | ||
.and(Bitwise(0b0101)) | ||
.and(0b1100) | ||
.valueOf(); | ||
Bitwise.chain(0b0111).and(Bitwise(0b0101)).and(0b1100).valueOf(); | ||
=> 0b0100 | ||
// => 0b0100 | ||
``` | ||
@@ -146,4 +139,4 @@ | ||
**Bitwise.nand(...values)** | ||
**Bitwise(value).nand(value)** | ||
**Bitwise.nand(...values)** | ||
**Bitwise.chain(value).nand(value)** | ||
@@ -155,20 +148,19 @@ Clears all of the bits in this BitSet whose corresponding bit is set in the specified BitSet. | ||
|---|---|----------| | ||
| 0 | 0 | 1 | | ||
| 0 | 1 | 1 | | ||
| 1 | 0 | 1 | | ||
| 1 | 1 | 0 | | ||
| 0 | 0 | 1 | | ||
| 0 | 1 | 1 | | ||
| 1 | 0 | 1 | | ||
| 1 | 1 | 0 | | ||
Example: | ||
```js | ||
var Bitwise = require('bitwise-operation') | ||
```ts | ||
import { Bitwise } from "bitwise-operation"; | ||
Bitwise.nand(0b0010, 0b0110); | ||
Bitwise(0b0010) | ||
.nand(0b0110) | ||
.valueOf(); | ||
Bitwise.chain(0b0010).nand(0b0110).valueOf(); | ||
=> 0b1101 | ||
// => 0b1101 | ||
``` | ||
Alias: **andNot()** | ||
@@ -179,3 +171,3 @@ | ||
**Bitwise.or(...values)** | ||
**Bitwise(value).or(value)** | ||
**Bitwise.chain(value).or(value)** | ||
@@ -187,19 +179,17 @@ Performs a logical **OR** of this bit set with the bit set argument. | ||
|---|---|--------| | ||
| 0 | 0 | 0 | | ||
| 0 | 1 | 1 | | ||
| 1 | 0 | 1 | | ||
| 1 | 1 | 1 | | ||
| 0 | 0 | 0 | | ||
| 0 | 1 | 1 | | ||
| 1 | 0 | 1 | | ||
| 1 | 1 | 1 | | ||
Example: | ||
```js | ||
var Bitwise = require('bitwise-operation') | ||
```ts | ||
import { Bitwise } from "bitwise-operation"; | ||
Bitwise.or(0b0010, 0b0110); | ||
Bitwise(0b0010) | ||
.or(0b0110) | ||
.valueOf(); | ||
Bitwise.chain(0b0010).or(0b0110).valueOf(); | ||
=> 0b0110 | ||
// => 0b0110 | ||
``` | ||
@@ -209,4 +199,4 @@ | ||
**Bitwise.nor(...values)** | ||
**Bitwise(value).nor(value)** | ||
**Bitwise.nor(...values)** | ||
**Bitwise.chain(value).nor(value)** | ||
@@ -218,19 +208,17 @@ Performs a logical **NOR** of this bit set with the bit set argument. | ||
|---|---|---------| | ||
| 0 | 0 | 1 | | ||
| 0 | 1 | 0 | | ||
| 1 | 0 | 0 | | ||
| 1 | 1 | 0 | | ||
| 0 | 0 | 1 | | ||
| 0 | 1 | 0 | | ||
| 1 | 0 | 0 | | ||
| 1 | 1 | 0 | | ||
Example: | ||
```js | ||
var Bitwise = require('bitwise-operation') | ||
```ts | ||
import { Bitwise } from "bitwise-operation"; | ||
Bitwise.nor(0b0010, 0b0110); | ||
Bitwise(0b0010) | ||
.nor(0b0110) | ||
.valueOf(); | ||
Bitwise.chain(0b0010).nor(0b0110).valueOf(); | ||
=> 0b1001 | ||
// => 0b1001 | ||
``` | ||
@@ -241,3 +229,3 @@ | ||
**Bitwise.xor(...values)** | ||
**Bitwise(value).xor(value)** | ||
**Bitwise.chain(value).xor(value)** | ||
@@ -249,19 +237,17 @@ Performs a logical **XOR** of this bit set with the bit set argument. | ||
|---|---|---------| | ||
| 0 | 0 | 0 | | ||
| 0 | 1 | 1 | | ||
| 1 | 0 | 1 | | ||
| 1 | 1 | 0 | | ||
| 0 | 0 | 0 | | ||
| 0 | 1 | 1 | | ||
| 1 | 0 | 1 | | ||
| 1 | 1 | 0 | | ||
Example: | ||
```js | ||
var Bitwise = require('bitwise-operation') | ||
```ts | ||
import { Bitwise } from "bitwise-operation"; | ||
Bitwise.xor(0b0010, 0b0110); | ||
Bitwise(0b0010) | ||
.xor(0b0110) | ||
.valueOf(); | ||
Bitwise.chain(0b0010).xor(0b0110).valueOf(); | ||
=> 0b0100 | ||
// => 0b0100 | ||
``` | ||
@@ -271,4 +257,4 @@ | ||
**Bitwise.xnor(...values)** | ||
**Bitwise(value).xnor(value)** | ||
**Bitwise.xnor(...values)** | ||
**Bitwise.chain(value).xnor(value)** | ||
@@ -280,20 +266,19 @@ Performs a logical **XNOR** of this bit set with the bit set argument. | ||
|---|---|----------| | ||
| 0 | 0 | 1 | | ||
| 0 | 1 | 0 | | ||
| 1 | 0 | 0 | | ||
| 1 | 1 | 1 | | ||
| 0 | 0 | 1 | | ||
| 0 | 1 | 0 | | ||
| 1 | 0 | 0 | | ||
| 1 | 1 | 1 | | ||
Example: | ||
```js | ||
var Bitwise = require('bitwise-operation') | ||
```ts | ||
import { Bitwise } from "bitwise-operation"; | ||
Bitwise.xor(0b0010, 0b0110); | ||
Bitwise(0b0010) | ||
.xor(0b0110) | ||
.valueOf(); | ||
Bitwise.chain(0b0010).xor(0b0110).valueOf(); | ||
=> 0b1011 | ||
// => 0b1011 | ||
``` | ||
Alias: **nxor()** | ||
@@ -304,3 +289,3 @@ | ||
**Bitwise.mask([fromIndex= 0,] toIndex)** | ||
**Bitwise(value).mask([fromIndex= 0,] toIndex)** | ||
**Bitwise.chain(value).mask([fromIndex= 0,] toIndex)** | ||
@@ -311,13 +296,13 @@ Sets the bits not in the specified fromIndex (inclusive) to the specified toIndex (inclusive) to false. | ||
```js | ||
var Bitwise = require('bitwise-operation') | ||
```ts | ||
import { Bitwise } from "bitwise-operation"; | ||
Bitwise.mask(1, 5); // => 0b00011110 | ||
Bitwise(0b1011011) | ||
Bitwise.chain(0b1011011) | ||
.mask(1, 5) // => 0b00011110 | ||
.valueOf(); | ||
// Equal to: Bitwise(0b1011011).and(Bitwise.mask(1, 5)).valueOf() | ||
// Equal to: Bitwise.chain(0b1011011).and(Bitwise.mask(1, 5)).valueOf() | ||
=> 0b00011010 | ||
// => 0b00011010 | ||
``` | ||
@@ -327,3 +312,3 @@ | ||
**Bitwise(value).clear([fromIndex= 0,] toIndex)** | ||
**Bitwise.chain(value).clear([fromIndex= 0,] toIndex)** | ||
@@ -334,10 +319,8 @@ Sets the bits from the specified fromIndex (inclusive) to the specified toIndex (inclusive) to false. | ||
```js | ||
var Bitwise = require('bitwise-operation') | ||
```ts | ||
import { Bitwise } from "bitwise-operation"; | ||
Bitwise(0b1011011) | ||
.clear(1, 5) | ||
.valueOf(); | ||
Bitwise.chain(0b1011011).clear(1, 5).valueOf(); | ||
=> 0b1000001 | ||
// => 0b1000001 | ||
``` | ||
@@ -347,3 +330,3 @@ | ||
**Bitwise(value).length()** | ||
**Bitwise.chain(value).length()** | ||
@@ -354,10 +337,10 @@ Returns the "logical size" of this Bitwise: the index of the highest set bit in the Bitwise plus one. | ||
```js | ||
var Bitwise = require('bitwise-operation') | ||
```ts | ||
import { Bitwise } from "bitwise-operation"; | ||
Bitwise(0b1011011) | ||
.length(); | ||
Bitwise.chain(0b1011011).length(); | ||
=> 7 | ||
// => 7 | ||
``` | ||
Alias: **size()** | ||
@@ -367,3 +350,3 @@ | ||
**Bitwise(value).set(idx [, value = true])** | ||
**Bitwise.chain(value).set(idx [, value = true])** | ||
@@ -374,10 +357,8 @@ Sets the bit at the specified index to the specified value (default `true`) | ||
```js | ||
var Bitwise = require('bitwise-operation') | ||
```ts | ||
import { Bitwise } from "bitwise-operation"; | ||
Bitwise(0b0001) | ||
.set(2) | ||
.valueOf(); | ||
Bitwise.chain(0b0001).set(2).valueOf(); | ||
=> 0b0101 | ||
// => 0b0101 | ||
``` | ||
@@ -387,3 +368,3 @@ | ||
**Bitwise(value).set(idx)** | ||
**Bitwise.chain(value).set(idx)** | ||
@@ -394,10 +375,8 @@ Sets the bit at the specified index to `false` | ||
```js | ||
var Bitwise = require('bitwise-operation') | ||
```ts | ||
import { Bitwise } from "bitwise-operation"; | ||
Bitwise(0b0101) | ||
.unset(0) | ||
.valueOf(); | ||
Bitwise.chain(0b0101).unset(0).valueOf(); | ||
=> 0b0100 | ||
// => 0b0100 | ||
``` | ||
@@ -407,3 +386,3 @@ | ||
**Bitwise(value).get(idx)** | ||
**Bitwise.chain(value).get(idx)** | ||
@@ -414,10 +393,8 @@ Returns the value of the bit with the specified index | ||
```js | ||
var Bitwise = require('bitwise-operation') | ||
```ts | ||
import { Bitwise } from "bitwise-operation"; | ||
Bitwise(0b0001) | ||
.get(0) | ||
.valueOf(); | ||
Bitwise.chain(0b0001).get(0); | ||
=> true | ||
// => true | ||
``` | ||
@@ -427,4 +404,4 @@ | ||
**Bitwise.toggle(value, ...idx)** | ||
**Bitwise(value).toggle(idx)** | ||
**Bitwise.toggle(value, ...idx)** | ||
**Bitwise.chain(value).toggle(idx)** | ||
@@ -435,12 +412,10 @@ Sets the bit at the specified index to the complement of its current value. | ||
```js | ||
var Bitwise = require('bitwise-operation') | ||
```ts | ||
import { Bitwise } from "bitwise-operation"; | ||
Bitwise.toggle(0b0001, 1); | ||
Bitwise(0b0001) | ||
.toggle(1) | ||
.valueOf(); | ||
Bitwise.chain(0b0001).toggle(1).valueOf(); | ||
=> 0b0011 | ||
// => 0b0011 | ||
``` | ||
@@ -450,4 +425,4 @@ | ||
**Bitwise.toggle(value, ...[idx1, idx2])** | ||
**Bitwise(value).swap(idx1, idx2)** | ||
**Bitwise.toggle(value, ...[idx1, idx2])** | ||
**Bitwise.chain(value).swap(idx1, idx2)** | ||
@@ -458,12 +433,10 @@ Swap bits to index `idx1` and `idx2` | ||
```js | ||
var Bitwise = require('bitwise-operation') | ||
```ts | ||
import { Bitwise } from "bitwise-operation"; | ||
Bitwise.swap(0b0101, [1, 2]); | ||
Bitwise(0b0101) | ||
.swap(1, 2) | ||
.valueOf(); | ||
Bitwise.chain(0b0101).swap(1, 2).valueOf(); | ||
=> 0b0011 | ||
// => 0b0011 | ||
``` | ||
@@ -473,3 +446,3 @@ | ||
**Bitwise(value).equals(value)** | ||
**Bitwise.chain(value).equals(value)** | ||
@@ -480,9 +453,8 @@ Compares this object against the specified object | ||
```js | ||
var Bitwise = require('bitwise-operation') | ||
```ts | ||
import { Bitwise } from "bitwise-operation"; | ||
Bitwise(0b0101) | ||
.equals(0b0111); | ||
Bitwise.chain(0b0101).equals(0b0111); | ||
=> false | ||
// => false | ||
``` | ||
@@ -492,3 +464,3 @@ | ||
**Bitwise(value).setValue(value)** | ||
**Bitwise.chain(value).setValue(value)** | ||
@@ -499,10 +471,8 @@ Replaces the current value of the object with the new value | ||
```js | ||
var Bitwise = require('bitwise-operation') | ||
```ts | ||
import { Bitwise } from "bitwise-operation"; | ||
Bitwise(0b0101) | ||
.setValue(0b0111) | ||
.valueOf(); | ||
Bitwise.chain(0b0101).setValue(0b0111).valueOf(); | ||
=> 0b0111 | ||
// => 0b0111 | ||
``` | ||
@@ -512,3 +482,3 @@ | ||
**Bitwise(value).setRange(fromIndex, toIndex )** | ||
**Bitwise.chain(value).setRange(fromIndex, toIndex )** | ||
@@ -519,10 +489,8 @@ Sets the bits from the specified `fromIndex` (inclusive) to the specified `toIndex` (inclusive) to `true`. | ||
```js | ||
var Bitwise = require('bitwise-operation') | ||
```ts | ||
import { Bitwise } from "bitwise-operation"; | ||
Bitwise(0b0101) | ||
.setRange(1, 2) | ||
.valueOf(); | ||
Bitwise.chain(0b0101).setRange(1, 2).valueOf(); | ||
=> 0b0111 | ||
// => 0b0111 | ||
``` | ||
@@ -532,3 +500,3 @@ | ||
**Bitwise(value).unsetRange(fromIndex, toIndex )** | ||
**Bitwise.chain(value).unsetRange(fromIndex, toIndex )** | ||
@@ -540,9 +508,7 @@ Sets the bits from the specified `fromIndex` (inclusive) to the specified `toIndex` (inclusive) to `false`. | ||
```js | ||
var Bitwise = require('bitwise-operation') | ||
import { Bitwise } from "bitwise-operation"; | ||
Bitwise(0b0101) | ||
.unsetRange(1, 2) | ||
.valueOf(); | ||
Bitwise.chain(0b0101).unsetRange(1, 2).valueOf(); | ||
=> 0b0001 | ||
// => 0b0001 | ||
``` | ||
@@ -552,3 +518,3 @@ | ||
**Bitwise(value).toggleRange(fromIndex, toIndex )** | ||
**Bitwise.chain(value).toggleRange(fromIndex, toIndex )** | ||
@@ -559,10 +525,8 @@ Sets each bit from the specified fromIndex (inclusive) to the specified toIndex (inclusive) to the complement of its current value. | ||
```js | ||
var Bitwise = require('bitwise-operation') | ||
```ts | ||
import { Bitwise } from "bitwise-operation"; | ||
Bitwise(0b0101) | ||
.toggleRange(1, 2) | ||
.valueOf(); | ||
Bitwise.chain(0b0101).toggleRange(1, 2).valueOf(); | ||
=> 0b0011 | ||
// => 0b0011 | ||
``` | ||
@@ -572,3 +536,3 @@ | ||
**Bitwise(value).copy()** | ||
**Bitwise.chain(value).copy()** | ||
@@ -579,4 +543,4 @@ Cloning this Bitwise produces a new Bitwise that is equal to it. | ||
```js | ||
var Bitwise = require('bitwise-operation') | ||
```ts | ||
import { Bitwise } from "bitwise-operation"; | ||
@@ -593,2 +557,3 @@ var a = Bitwise(0b0001); | ||
``` | ||
Alias: **clone()** | ||
@@ -598,3 +563,3 @@ | ||
**Bitwise(value).valueOf()** | ||
**Bitwise.chain(value).valueOf()** | ||
@@ -605,9 +570,8 @@ Return the current value of this Bitwise. | ||
```js | ||
var Bitwise = require('bitwise-operation') | ||
```ts | ||
import { Bitwise } from "bitwise-operation"; | ||
Bitwise(0b0101) | ||
.valueOf(); | ||
Bitwise.chain(0b0101).valueOf(); | ||
=> 0b0101 | ||
// => 0b0101 | ||
``` | ||
@@ -617,4 +581,4 @@ | ||
**Bitwise(value).toString()** | ||
**Bitwise(value).toString(length, separator)** | ||
**Bitwise.chain(value).toString()** | ||
**Bitwise.chain(value).toString(length, separator)** | ||
@@ -625,14 +589,12 @@ Returns a string representation of this Bitwise. | ||
```js | ||
var Bitwise = require('bitwise-operation') | ||
```ts | ||
import { Bitwise } from "bitwise-operation"; | ||
Bitwise(0b0101) | ||
.toString(); | ||
Bitwise.chain(0b0101).toString(); | ||
=> "0101" | ||
// => "0101" | ||
Bitwise(571) | ||
.toString(4, " "); | ||
Bitwise.chain(571).toString(4, " "); | ||
=> "10 0011 1011" | ||
// => "10 0011 1011" | ||
``` | ||
@@ -642,3 +604,3 @@ | ||
**Bitwise(value).toArray()** | ||
**Bitwise.chain(value).toArray()** | ||
@@ -649,4 +611,4 @@ Returns a array representation of this Bitwise. | ||
```js | ||
var Bitwise = require('bitwise-operation') | ||
```ts | ||
import { Bitwise } from "bitwise-operation"; | ||
@@ -656,9 +618,6 @@ var bitwise = Bitwise(571); | ||
bitwise.toString(4, " "); | ||
// => "10 0011 1011" | ||
=> "10 0011 1011" | ||
bitwise.toArray(); | ||
=> [ 1, 1, 0, 1, 1, 1, 0, 0, 0, 1 ] | ||
// => [ 1, 1, 0, 1, 1, 1, 0, 0, 0, 1 ] | ||
``` | ||
@@ -668,3 +627,3 @@ | ||
**Bitwise(value).cardinality()** | ||
**Bitwise.chain(value).cardinality()** | ||
@@ -675,4 +634,4 @@ Returns the number of bits set to true in this Bitwise. | ||
```js | ||
var Bitwise = require('bitwise-operation') | ||
```ts | ||
import { Bitwise } from "bitwise-operation"; | ||
@@ -682,9 +641,6 @@ var bitwise = Bitwise(571); | ||
bitwise.toString(4, " "); | ||
// => "10 0011 1011" | ||
=> "10 0011 1011" | ||
bitwise.cardinality(); | ||
=> 6 | ||
// => 6 | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
22972
7
334
592