@hookun/bitbybit
Advanced tools
Comparing version 0.0.14 to 0.0.15
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BitReader = void 0; | ||
const constants_1 = require("./constants"); | ||
@@ -12,3 +13,3 @@ const getValueInBits_1 = require("./getValueInBits"); | ||
const size = Math.min(constants_1.WordSize - bitOffset, bitLength); | ||
value += getValueInBits_1.getValueInBits(this.byte, constants_1.WordSize, bitOffset, bitOffset + size); | ||
value += (0, getValueInBits_1.getValueInBits)(this.byte, constants_1.WordSize, bitOffset, bitOffset + size); | ||
bitLength -= size; | ||
@@ -15,0 +16,0 @@ if (0 < bitLength) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BitWriter = void 0; | ||
const constants_1 = require("./constants"); | ||
@@ -20,3 +21,3 @@ const Wrapper_1 = require("./Wrapper"); | ||
const size = Math.min(constants_1.WordSize - bitOffset, bitLength - consumed); | ||
this.tempByte += getValueInBits_1.getValueInBits(value, bitLength, consumed, consumed + size) * (2 ** (constants_1.WordSize - (bitOffset + size))); | ||
this.tempByte += (0, getValueInBits_1.getValueInBits)(value, bitLength, consumed, consumed + size) * (2 ** (constants_1.WordSize - (bitOffset + size))); | ||
consumed += size; | ||
@@ -23,0 +24,0 @@ if (this.step(size)) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.WordSize = void 0; | ||
exports.WordSize = 8; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createBufferFromBitLength = (bitLength) => new Uint8Array(Math.ceil(bitLength / 8)).buffer; | ||
exports.createBufferFromBytes = (byteLength) => new Uint8Array(byteLength).buffer; | ||
exports.createBufferFromBytes = exports.createBufferFromBitLength = void 0; | ||
const createBufferFromBitLength = (bitLength) => new Uint8Array(Math.ceil(bitLength / 8)).buffer; | ||
exports.createBufferFromBitLength = createBufferFromBitLength; | ||
const createBufferFromBytes = (byteLength) => new Uint8Array(byteLength).buffer; | ||
exports.createBufferFromBytes = createBufferFromBytes; |
@@ -1,1 +0,1 @@ | ||
export declare const createBufferFromString: (...bits: string[]) => ArrayBuffer; | ||
export declare const createBufferFromString: (...bits: Array<string>) => ArrayBuffer; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createBufferFromString = void 0; | ||
const constants_1 = require("./constants"); | ||
exports.createBufferFromString = (...bits) => { | ||
const createBufferFromString = (...bits) => { | ||
const source = bits.join(''); | ||
@@ -14,1 +15,2 @@ const byteLength = Math.ceil(source.length / constants_1.WordSize); | ||
}; | ||
exports.createBufferFromString = createBufferFromString; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getBit = void 0; | ||
const getBitInByte_1 = require("./getBitInByte"); | ||
exports.getBit = (buffer, bitOffset) => { | ||
const getBit = (buffer, bitOffset) => { | ||
const byteOffset = Math.floor(bitOffset / 8); | ||
@@ -9,3 +10,4 @@ if (buffer.byteLength <= byteOffset) { | ||
} | ||
return getBitInByte_1.getBitInByte(new DataView(buffer).getUint8(byteOffset), bitOffset % 8); | ||
return (0, getBitInByte_1.getBitInByte)(new DataView(buffer).getUint8(byteOffset), bitOffset % 8); | ||
}; | ||
exports.getBit = getBit; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getBitInByte = (byte, bitIndex) => Boolean((byte >>> (7 - (bitIndex % 8))) % 2); | ||
exports.getBitInByte = void 0; | ||
const getBitInByte = (byte, bitIndex) => Boolean((byte >>> (7 - (bitIndex % 8))) % 2); | ||
exports.getBitInByte = getBitInByte; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getValueInBits = (byte, WordSize, start, end) => Math.floor((byte % (2 ** (WordSize - start))) / (2 ** (WordSize - end))); | ||
exports.getValueInBits = void 0; | ||
const getValueInBits = (byte, WordSize, start, end) => Math.floor((byte % (2 ** (WordSize - start))) / (2 ** (WordSize - end))); | ||
exports.getValueInBits = getValueInBits; |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
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); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./BitReader")); | ||
__export(require("./BitWriter")); | ||
__export(require("./Wrapper")); | ||
__export(require("./constants")); | ||
__export(require("./createBuffer")); | ||
__export(require("./createBufferFromString")); | ||
__export(require("./getBit")); | ||
__export(require("./getBitInByte")); | ||
__export(require("./getValueInBits")); | ||
__export(require("./listBit")); | ||
__export(require("./listBitHasState")); | ||
__export(require("./runLength")); | ||
__export(require("./setBit")); | ||
__export(require("./setBitInByte")); | ||
__export(require("./toString")); | ||
__exportStar(require("./BitReader"), exports); | ||
__exportStar(require("./BitWriter"), exports); | ||
__exportStar(require("./Wrapper"), exports); | ||
__exportStar(require("./constants"), exports); | ||
__exportStar(require("./createBuffer"), exports); | ||
__exportStar(require("./createBufferFromString"), exports); | ||
__exportStar(require("./getBit"), exports); | ||
__exportStar(require("./getBitInByte"), exports); | ||
__exportStar(require("./getValueInBits"), exports); | ||
__exportStar(require("./listBit"), exports); | ||
__exportStar(require("./listBitHasState"), exports); | ||
__exportStar(require("./runLength"), exports); | ||
__exportStar(require("./setBit"), exports); | ||
__exportStar(require("./setBitInByte"), exports); | ||
__exportStar(require("./toString"), exports); |
@@ -1,1 +0,1 @@ | ||
export declare const listBit: (buffer: ArrayBuffer, startBit?: number, endBit?: number) => Generator<boolean, any, unknown>; | ||
export declare const listBit: (buffer: ArrayBuffer, startBit?: number, endBit?: number) => Generator<boolean>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.listBit = void 0; | ||
const getBitInByte_1 = require("./getBitInByte"); | ||
exports.listBit = function* (buffer, startBit = 0, endBit = buffer.byteLength * 8) { | ||
const listBit = function* (buffer, startBit = 0, endBit = buffer.byteLength * 8) { | ||
const view = new DataView(buffer); | ||
@@ -13,3 +14,3 @@ const endByte = Math.ceil(endBit / 8); | ||
while (bitOffset < limit) { | ||
yield getBitInByte_1.getBitInByte(byte, bitOffset++); | ||
yield (0, getBitInByte_1.getBitInByte)(byte, bitOffset++); | ||
} | ||
@@ -20,1 +21,2 @@ bitOffset = 0; | ||
}; | ||
exports.listBit = listBit; |
@@ -1,1 +0,1 @@ | ||
export declare const listBitHasState: (buffer: ArrayBuffer, state: boolean, startBit?: number, endBit?: number) => Generator<number, any, unknown>; | ||
export declare const listBitHasState: (buffer: ArrayBuffer, state: boolean, startBit?: number, endBit?: number) => Generator<number>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.listBitHasState = void 0; | ||
const getBitInByte_1 = require("./getBitInByte"); | ||
exports.listBitHasState = function* (buffer, state, startBit = 0, endBit = buffer.byteLength * 8) { | ||
const listBitHasState = function* (buffer, state, startBit = 0, endBit = buffer.byteLength * 8) { | ||
const skip = state ? 0x00 : 0xFF; | ||
@@ -15,3 +16,3 @@ const view = new DataView(buffer); | ||
while (bitIndex < Math.min(8, endBit - bitOffset)) { | ||
if (getBitInByte_1.getBitInByte(byte, bitIndex) === state) { | ||
if ((0, getBitInByte_1.getBitInByte)(byte, bitIndex) === state) { | ||
yield bitOffset + bitIndex; | ||
@@ -26,1 +27,2 @@ } | ||
}; | ||
exports.listBitHasState = listBitHasState; |
@@ -1,1 +0,1 @@ | ||
export declare const runLength: (buffer: ArrayBuffer, startBit?: number, endBit?: number, startState?: boolean) => Generator<number, any, unknown>; | ||
export declare const runLength: (buffer: ArrayBuffer, startBit?: number, endBit?: number, startState?: boolean) => Generator<number>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.runLength = void 0; | ||
const listBitHasState_1 = require("./listBitHasState"); | ||
exports.runLength = function* (buffer, startBit = 0, endBit = buffer.byteLength * 8, startState = false) { | ||
const runLength = function* (buffer, startBit = 0, endBit = buffer.byteLength * 8, startState = false) { | ||
let bitOffset = startBit; | ||
@@ -9,3 +10,3 @@ let state = startState; | ||
state = !state; | ||
const result = listBitHasState_1.listBitHasState(buffer, state, bitOffset, endBit).next(); | ||
const result = (0, listBitHasState_1.listBitHasState)(buffer, state, bitOffset, endBit).next(); | ||
if (result.done) { | ||
@@ -23,1 +24,2 @@ const lastLength = endBit - bitOffset; | ||
}; | ||
exports.runLength = runLength; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.setBit = void 0; | ||
const setBitInByte_1 = require("./setBitInByte"); | ||
exports.setBit = (buffer, bitOffset, bitState) => { | ||
const setBit = (buffer, bitOffset, bitState) => { | ||
const byteOffset = Math.floor(bitOffset / 8); | ||
if (0 <= byteOffset && byteOffset < buffer.byteLength) { | ||
const view = new DataView(buffer); | ||
view.setUint8(byteOffset, setBitInByte_1.setBitInByte(view.getUint8(byteOffset), bitOffset % 8, bitState)); | ||
view.setUint8(byteOffset, (0, setBitInByte_1.setBitInByte)(view.getUint8(byteOffset), bitOffset % 8, bitState)); | ||
} | ||
@@ -14,1 +15,2 @@ else { | ||
}; | ||
exports.setBit = setBit; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.setBitInByte = (byte, bitIndex, bitState) => { | ||
exports.setBitInByte = void 0; | ||
const setBitInByte = (byte, bitIndex, bitState) => { | ||
if (0 <= bitIndex && bitIndex < 8) { | ||
@@ -13,1 +14,2 @@ if (0 <= byte && byte <= 0xFF) { | ||
}; | ||
exports.setBitInByte = setBitInByte; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.toString = (buffer, bitsPerLine = 32, maxLineCount = Infinity, delimiter = '') => { | ||
exports.toString = void 0; | ||
const toString = (buffer, bitsPerLine = 32, maxLineCount = Infinity, delimiter = '') => { | ||
const lines = []; | ||
@@ -25,1 +26,2 @@ let line = []; | ||
}; | ||
exports.toString = toString; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Wrapper = void 0; | ||
const constants_1 = require("./constants"); | ||
@@ -4,0 +5,0 @@ class Wrapper { |
@@ -11,3 +11,3 @@ { | ||
}, | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"license": "Apache-2.0", | ||
@@ -32,15 +32,15 @@ "author": { | ||
"preversion": "run-s preversion:*", | ||
"preversion:doc": "typedoc", | ||
"preversion:doc": "typedoc src/index.ts", | ||
"preversion:stage": "git add ." | ||
}, | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^2.31.0", | ||
"@typescript-eslint/parser": "^2.31.0", | ||
"@typescript-eslint/eslint-plugin": "^5.7.0", | ||
"@typescript-eslint/parser": "^5.7.0", | ||
"ava": "^3.8.1", | ||
"eslint": "^6.8.0", | ||
"eslint": "^8.5.0", | ||
"npm-run-all": "^4.1.5", | ||
"ts-node": "^8.10.1", | ||
"typedoc": "^0.17.6", | ||
"typedoc-plugin-markdown": "^2.2.17", | ||
"typescript": "^3.8.3" | ||
"ts-node": "^10.4.0", | ||
"typedoc": "^0.22.10", | ||
"typedoc-plugin-markdown": "^3.11.8", | ||
"typescript": "^4.5.4" | ||
}, | ||
@@ -47,0 +47,0 @@ "ava": { |
@@ -16,3 +16,3 @@ # @hookun/bitbybit | ||
[docs/README.md](docs/README.md) | ||
[docs/modules.md]((https://github.com/hookun/bitbybit/docs/modules.md) | ||
@@ -19,0 +19,0 @@ ## License |
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
28373
355