From a765a6e6eed315c376c8b8135ef1080a512f6797 Mon Sep 17 00:00:00 2001 From: Aaron Costley Date: Tue, 25 Sep 2018 16:38:25 -0700 Subject: [PATCH] fix(jsii-runtime): Use buffer factory methods instead of constructor. Guidance from https://nodejs.org/en/docs/guides/buffer-constructor-deprecation/ --- packages/jsii-runtime/lib/sync-stdio.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/jsii-runtime/lib/sync-stdio.ts b/packages/jsii-runtime/lib/sync-stdio.ts index 68f0821114..99119baa71 100644 --- a/packages/jsii-runtime/lib/sync-stdio.ts +++ b/packages/jsii-runtime/lib/sync-stdio.ts @@ -7,14 +7,14 @@ const INPUT_BUFFER_SIZE = 1024 * 1024; // not related to max line length export class SyncStdio { private inputQueue = new Array(); - private currentLine = '' + private currentLine = ''; writeErrorLine(line: string) { - this.writeBuffer(new Buffer(`${line}\n`), STDERR_FD); + this.writeBuffer(Buffer.from(`${line}\n`), STDERR_FD); } writeLine(line: string) { - this.writeBuffer(new Buffer(`${line}\n`), STDOUT_FD); + this.writeBuffer(Buffer.from(`${line}\n`), STDOUT_FD); } readLine(): string | undefined { @@ -22,7 +22,7 @@ export class SyncStdio { return this.inputQueue.shift(); } - const buff = new Buffer(INPUT_BUFFER_SIZE); + const buff = Buffer.alloc(INPUT_BUFFER_SIZE); const read = fs.readSync(STDIN_FD, buff, 0, buff.length, null); if (read === 0) {