diff --git a/package.json b/package.json index 95703c8d..eb431991 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "@types/ip6addr": "0.2.6", "@types/jest": "29.5.14", "@types/netmask": "2.0.5", - "@types/node": "22.10.3", + "@types/node": "22.14.0", "@types/sinon": "17.0.4", "ip-address": "10.0.1", "ip6addr": "0.2.5", diff --git a/src/index.test.ts b/src/index.test.ts index d871b004..95069c95 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -114,7 +114,7 @@ describe('index', () => { // it('should check for an error when cannot read database on update', async () => { // var counter = 0; // var cb = function(err, reader) { - // // Indeed couter is kinda gross. + // // Indeed counter is kinda gross. // switch (counter++) { // case 0: // assert.strictEqual(err, null); diff --git a/src/index.ts b/src/index.ts index cbccf9e2..7f3e185e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -41,9 +41,15 @@ const readLargeFile = async (filepath: string, size: number): Promise => highWaterMark: STREAM_WATERMARK, }); - stream.on('data', (chunk: Buffer) => { - chunk.copy(buffer, offset); - offset += chunk.length; + stream.on('data', (chunk: string | Buffer) => { + if (Buffer.isBuffer(chunk)) { + chunk.copy(buffer, offset); + offset += chunk.length; + } else { + const bufferChunk = Buffer.from(chunk); + bufferChunk.copy(buffer, offset); + offset += bufferChunk.length; + } }); stream.on('end', () => {