From 3dd96d9544edf0e0ed7dd85a87bba68743ea49cf Mon Sep 17 00:00:00 2001 From: Daniele Ricci Date: Wed, 29 Apr 2020 11:04:12 +0200 Subject: [PATCH] minor minor minor optimization --- index.ts | 2 +- test/05options.ts | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/index.ts b/index.ts index 4879c49..8411937 100644 --- a/index.ts +++ b/index.ts @@ -190,7 +190,7 @@ export class RotatingFileStream extends Writable { done(); }); - if(this.options.teeToStdout) process.stdout.write(chunk.chunk, chunk.encoding, () => {}); + if(this.options.teeToStdout) process.stdout.write(chunk.chunk, chunk.encoding); }; if(this.stream) { diff --git a/test/05options.ts b/test/05options.ts index f5ac2ba..3a4e91d 100644 --- a/test/05options.ts +++ b/test/05options.ts @@ -141,12 +141,7 @@ describe("options", () => { const events = test({ options: { size: "10B", teeToStdout: true } }, rfs => { const write = process.stdout.write; - process.stdout.write = (str: string | Uint8Array, encoding?: string | ((err?: Error) => void), cb?: (err?: Error) => void): boolean => { - content.push({ str, encoding }); - cb(); - - return false; - }; + process.stdout.write = (str: string | Uint8Array, encoding?: string | ((err?: Error) => void), cb?: (err?: Error) => void): boolean => content.push({ str, encoding, cb }) === 0; rfs.write("test\n"); rfs.write("test\n"); @@ -156,9 +151,9 @@ describe("options", () => { it("events", () => deq(events, { finish: 1, open: ["test.log", "test.log"], rotated: ["1-test.log"], rotation: 1, write: 1, writev: 1 })); it("stdout", () => deq(content, [ - { encoding: "buffer", str: Buffer.from("test\n") }, - { encoding: "buffer", str: Buffer.from("test\n") }, - { encoding: "buffer", str: Buffer.from("test\n") }, + { str: Buffer.from("test\n"), encoding: "buffer", cb: undefined }, + { str: Buffer.from("test\n"), encoding: "buffer", cb: undefined }, + { str: Buffer.from("test\n"), encoding: "buffer", cb: undefined } ])); it("file content", () => eq(readFileSync("test.log", "utf8"), "test\n")); it("rotated file content", () => eq(readFileSync("1-test.log", "utf8"), "test\ntest\n"));