diff --git a/packages/neovim/.mocharc.js b/packages/neovim/.mocharc.js index c0193d41..cc091fa3 100644 --- a/packages/neovim/.mocharc.js +++ b/packages/neovim/.mocharc.js @@ -5,4 +5,4 @@ module.exports = { extension: ['ts'], spec: ['src/**/*.test.ts'], exit: true -} \ No newline at end of file +} diff --git a/packages/neovim/src/testSetup.ts b/packages/neovim/src/testSetup.ts index 5679d9e3..e91efbfb 100644 --- a/packages/neovim/src/testSetup.ts +++ b/packages/neovim/src/testSetup.ts @@ -2,10 +2,10 @@ import { startNvim, stopNvim } from './testUtil'; export const mochaHooks = { - beforeAll: async () => { + beforeAll() { startNvim(); }, - afterAll: () => { + afterAll() { stopNvim(); }, }; diff --git a/packages/neovim/src/utils/buffered.ts b/packages/neovim/src/utils/buffered.ts deleted file mode 100644 index b3a9362d..00000000 --- a/packages/neovim/src/utils/buffered.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { Transform } from 'node:stream'; - -const MIN_SIZE = 8 * 1024; - -export default class Buffered extends Transform { - private chunks: Buffer[] | null; - - private timer: NodeJS.Timer | null; - - constructor() { - super({ - readableHighWaterMark: 10 * 1024 * 1024, - writableHighWaterMark: 10 * 1024 * 1024, - } as any); - this.chunks = null; - this.timer = null; - } - - sendData() { - const { chunks } = this; - if (chunks) { - this.chunks = null; - const buf = Buffer.concat(chunks); - this.push(buf); - } - } - - // eslint-disable-next-line consistent-return - override _transform(chunk: Buffer, _encoding: any, callback: any): void { - const { chunks, timer } = this; - - if (timer) clearTimeout(timer); - - if (chunk.length < MIN_SIZE) { - if (!chunks) return callback(null, chunk); - chunks.push(chunk); - this.sendData(); - callback(); - } else { - if (!chunks) { - this.chunks = [chunk]; - } else { - chunks.push(chunk); - } - - this.timer = setTimeout(this.sendData.bind(this), 20); - callback(); - } - } - - override _flush(callback: any) { - const { chunks } = this; - if (chunks) { - this.chunks = null; - const buf = Buffer.concat(chunks); - callback(null, buf); - } else { - callback(); - } - } -}