Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit bb85321

Browse files
committed
update
1 parent 90f40a4 commit bb85321

File tree

4 files changed

+13
-54
lines changed

4 files changed

+13
-54
lines changed

package-lock.json

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"dependencies": {
3939
"@types/node": "^17.0.8",
4040
"nodeliketty": "^1.0.2",
41+
"nodeliketty-testimpl": "^1.0.0",
4142
"strip-ansi": "^7.0.1",
4243
"utty": "^1.0.0"
4344
},

src/index.test.ts

Lines changed: 3 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,7 @@
1-
import UNodeTty, { NodeLikeTty } from "./index";
2-
class FakeNodeTty implements NodeLikeTty {
3-
lines: string[] = [""];
4-
y = 0;
5-
x = 0;
6-
resizeListeners: (() => void)[] = [];
7-
_columns: number = 100;
8-
set columns(col: number) {
9-
this._columns = col;
10-
this.resizeListeners.forEach((value) => value());
11-
}
12-
_rows: number = 100;
13-
set rows(row: number) {
14-
this._rows = row;
15-
this.resizeListeners.forEach((value) => value());
16-
}
17-
on(_event: "resize", listener: () => void): this {
18-
this.resizeListeners.push(listener);
19-
return this;
20-
}
21-
getColorDepth(): number {
22-
return 24;
23-
}
24-
write(buffer: Uint8Array | string, cb?: (err?: Error) => void): boolean {
25-
for (let c of buffer) {
26-
if (c === "\n") {
27-
this.y++;
28-
this.x = 0;
29-
this.lines.push("");
30-
} else {
31-
this.x++;
32-
this.lines[this.y] += c;
33-
}
34-
}
35-
return true;
36-
}
37-
clearLine(dir: -1 | 0 | 1): boolean {
38-
this.lines[this.y] = "";
39-
this.x = 0;
40-
return true;
41-
}
42-
moveCursor(dx: number, dy: number): boolean {
43-
this.x += dx;
44-
this.y += dy;
45-
return true;
46-
}
47-
cursorTo(x: number, y?: number): boolean {
48-
this.x = x;
49-
if (y !== null) this.y = y;
50-
return true;
51-
}
52-
}
1+
import UNodeTty from "./index";
2+
import TestImpl from "nodeliketty-testimpl";
533

54-
const fake = new FakeNodeTty();
4+
const fake = new TestImpl();
555
const t = new UNodeTty(fake);
566
let lines: string[] = [];
577

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import UTty from "utty";
22
import stripAnsi from "strip-ansi";
3-
import NodeLikeTty ,{ Direction } from "nodeliketty";
3+
import NodeLikeTty from "nodeliketty";
44

55
export default class UNodeTty implements UTty {
66
constructor(tty: NodeLikeTty) {

0 commit comments

Comments
 (0)