Skip to content

Commit 3bed8f7

Browse files
committed
fix broken types
1 parent 9209779 commit 3bed8f7

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ describe('index', () => {
114114
// it('should check for an error when cannot read database on update', async () => {
115115
// var counter = 0;
116116
// var cb = function(err, reader) {
117-
// // Indeed couter is kinda gross.
117+
// // Indeed counter is kinda gross.
118118
// switch (counter++) {
119119
// case 0:
120120
// assert.strictEqual(err, null);

src/index.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,15 @@ const readLargeFile = async (filepath: string, size: number): Promise<Buffer> =>
4141
highWaterMark: STREAM_WATERMARK,
4242
});
4343

44-
stream.on('data', (chunk: Buffer) => {
45-
chunk.copy(buffer, offset);
46-
offset += chunk.length;
44+
stream.on('data', (chunk: string | Buffer) => {
45+
if (Buffer.isBuffer(chunk)) {
46+
chunk.copy(buffer, offset);
47+
offset += chunk.length;
48+
} else {
49+
const bufferChunk = Buffer.from(chunk);
50+
bufferChunk.copy(buffer, offset);
51+
offset += bufferChunk.length;
52+
}
4753
});
4854

4955
stream.on('end', () => {

0 commit comments

Comments
 (0)