@hookun/bitbybit
Advanced tools
Comparing version 0.0.12 to 0.0.13
@@ -7,7 +7,9 @@ export declare class Wrapper { | ||
get buffer(): ArrayBuffer; | ||
protected get byteLength(): number; | ||
protected get byte(): number; | ||
protected get bitOffsetFromStart(): number; | ||
get byteLength(): number; | ||
get bitLength(): number; | ||
get byte(): number; | ||
get bitOffsetFromStart(): number; | ||
get done(): boolean; | ||
residualBitLength(): number; | ||
protected step(bitLength: number): boolean; | ||
} |
@@ -16,2 +16,5 @@ "use strict"; | ||
} | ||
get bitLength() { | ||
return this.byteLength * constants_1.WordSize; | ||
} | ||
get byte() { | ||
@@ -26,6 +29,13 @@ return this.view.getUint8(this.byteOffset); | ||
} | ||
residualBitLength() { | ||
return this.bitLength - this.bitOffsetFromStart; | ||
} | ||
step(bitLength) { | ||
const bitOffset = this.bitOffset + bitLength; | ||
this.bitOffset = bitOffset % constants_1.WordSize; | ||
this.byteOffset += Math.floor(bitOffset / constants_1.WordSize); | ||
this.bitOffset = bitOffset % constants_1.WordSize; | ||
const { byteLength, byteOffset } = this; | ||
if ((byteLength === byteOffset && 0 < this.bitOffset) || byteLength < byteOffset) { | ||
throw new RangeError('Cannot step out of buffer'); | ||
} | ||
return constants_1.WordSize <= bitOffset; | ||
@@ -32,0 +42,0 @@ } |
@@ -11,3 +11,3 @@ { | ||
}, | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"license": "Apache-2.0", | ||
@@ -14,0 +14,0 @@ "author": { |
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
26775
321