Skip to content

Commit 378549a

Browse files
authored
Merge pull request #812 from microsoft/tyriar/buffer
Support Buffer in write API
2 parents 44b155d + 74ee292 commit 378549a

File tree

6 files changed

+8
-8
lines changed

6 files changed

+8
-8
lines changed

src/interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export interface ITerminal {
2222
* Writes data to the socket.
2323
* @param data The data to write.
2424
*/
25-
write(data: string): void;
25+
write(data: string | Buffer): void;
2626

2727
/**
2828
* Resize the pty.

src/terminal.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class TestTerminal extends Terminal {
2323
public checkType<T>(name: string, value: T, type: string, allowArray: boolean = false): void {
2424
this._checkType(name, value, type, allowArray);
2525
}
26-
protected _write(data: string): void {
26+
protected _write(data: string | Buffer): void {
2727
throw new Error('Method not implemented.');
2828
}
2929
public resize(cols: number, rows: number): void {

src/terminal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ export abstract class Terminal implements ITerminal {
7474
this._checkType('encoding', opt.encoding ? opt.encoding : undefined, 'string');
7575
}
7676

77-
protected abstract _write(data: string): void;
77+
protected abstract _write(data: string | Buffer): void;
7878

79-
public write(data: string): void {
79+
public write(data: string | Buffer): void {
8080
if (this.handleFlowControl) {
8181
// PAUSE/RESUME messages are not forwarded to the pty
8282
if (data === this._flowControlPause) {

src/unixTerminal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export class UnixTerminal extends Terminal {
161161
this._forwardEvents();
162162
}
163163

164-
protected _write(data: string): void {
164+
protected _write(data: string | Buffer): void {
165165
this._socket.write(data);
166166
}
167167

src/windowsTerminal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ export class WindowsTerminal extends Terminal {
123123
this._forwardEvents();
124124
}
125125

126-
protected _write(data: string): void {
126+
protected _write(data: string | Buffer): void {
127127
this._defer(this._doWrite, data);
128128
}
129129

130-
private _doWrite(data: string): void {
130+
private _doWrite(data: string | Buffer): void {
131131
this._agent.inSocket.write(data);
132132
}
133133

typings/node-pty.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ declare module 'node-pty' {
173173
* Writes data to the pty.
174174
* @param data The data to write.
175175
*/
176-
write(data: string): void;
176+
write(data: string | Buffer): void;
177177

178178
/**
179179
* Kills the pty.

0 commit comments

Comments
 (0)