Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(jsii-runtime): Use buffer factory methods instead of constructor. #246

Merged
merged 1 commit into from
Sep 26, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/jsii-runtime/lib/sync-stdio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ const INPUT_BUFFER_SIZE = 1024 * 1024; // not related to max line length

export class SyncStdio {
private inputQueue = new Array<string>();
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 {
if (this.inputQueue.length > 0) {
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) {
Expand Down