mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-01-06 02:49:06 +08:00
* feat: pnpm new * Refactor build and release workflows, update dependencies Switch build scripts and workflows from npm to pnpm, update build and artifact paths, and simplify release workflow by removing version detection and changelog steps. Add new dependencies (silk-wasm, express, ws, node-pty-prebuilt-multiarch), update exports in package.json files, and add vite config for napcat-framework. Also, rename manifest.json for framework package and fix static asset copying in shell build config.
40 lines
786 B
TypeScript
40 lines
786 B
TypeScript
class QRBitBuffer {
|
|
buffer: number[];
|
|
length: number;
|
|
|
|
constructor () {
|
|
this.buffer = [];
|
|
this.length = 0;
|
|
}
|
|
|
|
get (index: number): boolean {
|
|
const bufIndex = Math.floor(index / 8);
|
|
return ((this.buffer[bufIndex]! >>> (7 - index % 8)) & 1) === 1;
|
|
}
|
|
|
|
put (num: number, length: number): void {
|
|
for (let i = 0; i < length; i++) {
|
|
this.putBit(((num >>> (length - i - 1)) & 1) === 1);
|
|
}
|
|
}
|
|
|
|
getLengthInBits (): number {
|
|
return this.length;
|
|
}
|
|
|
|
putBit (bit: boolean): void {
|
|
const bufIndex = Math.floor(this.length / 8);
|
|
if (this.buffer.length <= bufIndex) {
|
|
this.buffer.push(0);
|
|
}
|
|
|
|
if (bit) {
|
|
this.buffer[bufIndex]! |= (0x80 >>> (this.length % 8));
|
|
}
|
|
|
|
this.length++;
|
|
}
|
|
}
|
|
|
|
export default QRBitBuffer;
|