document-ir 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -13
- package/esm/WhitespaceStretchingTransformer.d.ts +2 -2
- package/esm/WhitespaceStretchingTransformer.js +17 -15
- package/esm/WhitespaceTransformer.js +7 -7
- package/package.json +2 -7
- package/script/WhitespaceStretchingTransformer.d.ts +2 -2
- package/script/WhitespaceStretchingTransformer.js +17 -15
- package/script/WhitespaceTransformer.js +7 -7
- package/esm/ArrayCollapseTransformer_test.d.ts +0 -1
- package/esm/ExampleDocument.d.ts +0 -2
- package/esm/IdentityTransformer_test.d.ts +0 -1
- package/esm/TextCollapseTransformer_test.d.ts +0 -1
- package/esm/TextVisitor_test.d.ts +0 -1
- package/esm/WhitespaceStretchingTransformer_test.d.ts +0 -1
- package/esm/WhitespaceTransformer_test.d.ts +0 -1
- package/esm/_dnt.test_shims.d.ts +0 -5
- package/esm/deps/deno.land/std@0.192.0/fmt/colors.d.ts +0 -270
- package/esm/deps/deno.land/std@0.192.0/testing/_diff.d.ts +0 -26
- package/esm/deps/deno.land/std@0.192.0/testing/_format.d.ts +0 -1
- package/esm/deps/deno.land/std@0.192.0/testing/asserts.d.ts +0 -284
- package/script/ArrayCollapseTransformer_test.d.ts +0 -1
- package/script/ExampleDocument.d.ts +0 -2
- package/script/IdentityTransformer_test.d.ts +0 -1
- package/script/TextCollapseTransformer_test.d.ts +0 -1
- package/script/TextVisitor_test.d.ts +0 -1
- package/script/WhitespaceStretchingTransformer_test.d.ts +0 -1
- package/script/WhitespaceTransformer_test.d.ts +0 -1
- package/script/_dnt.test_shims.d.ts +0 -5
- package/script/deps/deno.land/std@0.192.0/fmt/colors.d.ts +0 -270
- package/script/deps/deno.land/std@0.192.0/testing/_diff.d.ts +0 -26
- package/script/deps/deno.land/std@0.192.0/testing/_format.d.ts +0 -1
- package/script/deps/deno.land/std@0.192.0/testing/asserts.d.ts +0 -284
package/README.md
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
# document-ir
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
bun install
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
To run:
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
bun run index.ts
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
This project was created using `bun init` in bun v0.6.7. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
|
|
3
|
+
This helpful library can help contain and manipulate blog content much like
|
|
4
|
+
multiple passes of a compiler.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { IdentityTransformer } from "./IdentityTransformer.js";
|
|
2
2
|
import { DocumentNode, Node, TextNode } from "./types.js";
|
|
3
3
|
interface BlockInfo {
|
|
4
|
-
type:
|
|
4
|
+
type: "_block";
|
|
5
5
|
content: WhiteSpaceContainer[];
|
|
6
6
|
parent: BlockInfo | InlineInfo | null;
|
|
7
7
|
}
|
|
8
8
|
interface InlineInfo {
|
|
9
|
-
type:
|
|
9
|
+
type: "_inline";
|
|
10
10
|
content: WhiteSpaceContainer[];
|
|
11
11
|
parent: BlockInfo | InlineInfo | null;
|
|
12
12
|
}
|
|
@@ -15,9 +15,9 @@ export class WhitespaceStretchingTransformer extends IdentityTransformer {
|
|
|
15
15
|
value: void 0
|
|
16
16
|
});
|
|
17
17
|
this.root = {
|
|
18
|
-
type:
|
|
18
|
+
type: "_block",
|
|
19
19
|
content: [],
|
|
20
|
-
parent: null
|
|
20
|
+
parent: null,
|
|
21
21
|
};
|
|
22
22
|
this.cursor = this.root;
|
|
23
23
|
}
|
|
@@ -25,9 +25,9 @@ export class WhitespaceStretchingTransformer extends IdentityTransformer {
|
|
|
25
25
|
async beforeBlock() {
|
|
26
26
|
const parent = this.cursor;
|
|
27
27
|
const block = {
|
|
28
|
-
type:
|
|
28
|
+
type: "_block",
|
|
29
29
|
content: [],
|
|
30
|
-
parent
|
|
30
|
+
parent,
|
|
31
31
|
};
|
|
32
32
|
parent.content.push(block);
|
|
33
33
|
this.cursor = block;
|
|
@@ -42,9 +42,9 @@ export class WhitespaceStretchingTransformer extends IdentityTransformer {
|
|
|
42
42
|
async beforeInline() {
|
|
43
43
|
const parent = this.cursor;
|
|
44
44
|
const inline = {
|
|
45
|
-
type:
|
|
45
|
+
type: "_inline",
|
|
46
46
|
content: [],
|
|
47
|
-
parent
|
|
47
|
+
parent,
|
|
48
48
|
};
|
|
49
49
|
parent.content.push(inline);
|
|
50
50
|
this.cursor = inline;
|
|
@@ -58,13 +58,13 @@ export class WhitespaceStretchingTransformer extends IdentityTransformer {
|
|
|
58
58
|
reviewBlock(block) {
|
|
59
59
|
const nodes = [];
|
|
60
60
|
const visit = (r, level) => {
|
|
61
|
-
if (r.type ==
|
|
61
|
+
if (r.type == "text") {
|
|
62
62
|
nodes.push({
|
|
63
63
|
node: r,
|
|
64
|
-
level
|
|
64
|
+
level,
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
|
-
else if (r.type ==
|
|
67
|
+
else if (r.type == "_block") {
|
|
68
68
|
this.reviewBlock(r);
|
|
69
69
|
nodes.push({ node: null, level });
|
|
70
70
|
}
|
|
@@ -79,7 +79,9 @@ export class WhitespaceStretchingTransformer extends IdentityTransformer {
|
|
|
79
79
|
}
|
|
80
80
|
for (let i = 0; i < nodes.length; i++) {
|
|
81
81
|
const first = nodes[i];
|
|
82
|
-
const second = i + 1 < nodes.length
|
|
82
|
+
const second = i + 1 < nodes.length
|
|
83
|
+
? nodes[i + 1]
|
|
84
|
+
: { node: null, level: 0 };
|
|
83
85
|
// No use acting on a dead node
|
|
84
86
|
if (!first.node || !second.node) {
|
|
85
87
|
continue;
|
|
@@ -89,13 +91,13 @@ export class WhitespaceStretchingTransformer extends IdentityTransformer {
|
|
|
89
91
|
continue;
|
|
90
92
|
}
|
|
91
93
|
if (first.level < second.level) {
|
|
92
|
-
if (second.node.text.startsWith(
|
|
94
|
+
if (second.node.text.startsWith(" ")) {
|
|
93
95
|
second.node.text = second.node.text.slice(1);
|
|
94
|
-
first.node.text +=
|
|
96
|
+
first.node.text += " ";
|
|
95
97
|
}
|
|
96
98
|
}
|
|
97
99
|
else if (first.level > second.level) {
|
|
98
|
-
if (first.node.text.endsWith(
|
|
100
|
+
if (first.node.text.endsWith(" ")) {
|
|
99
101
|
first.node.text = first.node.text.slice(0, -1);
|
|
100
102
|
second.node.text = ` ${second.node.text}`;
|
|
101
103
|
}
|
|
@@ -105,8 +107,8 @@ export class WhitespaceStretchingTransformer extends IdentityTransformer {
|
|
|
105
107
|
// deno-lint-ignore require-await
|
|
106
108
|
async text(node) {
|
|
107
109
|
const replacement = {
|
|
108
|
-
type:
|
|
109
|
-
text: `${node.text}
|
|
110
|
+
type: "text",
|
|
111
|
+
text: `${node.text}`,
|
|
110
112
|
};
|
|
111
113
|
this.cursor.content.push(replacement);
|
|
112
114
|
return replacement;
|
|
@@ -2,7 +2,7 @@ import { IdentityTransformer } from "./IdentityTransformer.js";
|
|
|
2
2
|
class RemoveEmptyTextTransformer extends IdentityTransformer {
|
|
3
3
|
// deno-lint-ignore require-await
|
|
4
4
|
async text(node) {
|
|
5
|
-
if (node.text ==
|
|
5
|
+
if (node.text == "") {
|
|
6
6
|
return null;
|
|
7
7
|
}
|
|
8
8
|
return node;
|
|
@@ -28,11 +28,11 @@ export class WhitespaceTransformer extends IdentityTransformer {
|
|
|
28
28
|
}
|
|
29
29
|
// deno-lint-ignore require-await
|
|
30
30
|
async text(node) {
|
|
31
|
-
let result =
|
|
31
|
+
let result = "";
|
|
32
32
|
for (const c of node.text) {
|
|
33
|
-
if (c ==
|
|
33
|
+
if (c == " " || c == "\n" || c == "\t" || c == "\r") {
|
|
34
34
|
if (!this.stripWhitespace) {
|
|
35
|
-
result +=
|
|
35
|
+
result += " ";
|
|
36
36
|
this.stripWhitespace = true;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -45,15 +45,15 @@ export class WhitespaceTransformer extends IdentityTransformer {
|
|
|
45
45
|
return null;
|
|
46
46
|
}
|
|
47
47
|
const text = {
|
|
48
|
-
type:
|
|
49
|
-
text: result
|
|
48
|
+
type: "text",
|
|
49
|
+
text: result,
|
|
50
50
|
};
|
|
51
51
|
this.lastText = text;
|
|
52
52
|
return text;
|
|
53
53
|
}
|
|
54
54
|
stripLastText() {
|
|
55
55
|
if (this.lastText) {
|
|
56
|
-
if (this.lastText.text.endsWith(
|
|
56
|
+
if (this.lastText.text.endsWith(" ")) {
|
|
57
57
|
this.lastText.text = this.lastText.text.slice(0, -1);
|
|
58
58
|
}
|
|
59
59
|
this.lastText = null;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"module": "./esm/index.js",
|
|
3
3
|
"main": "./script/index.js",
|
|
4
4
|
"name": "document-ir",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.8",
|
|
6
6
|
"description": "Intermediate representation and transformers for documents",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": {
|
|
@@ -18,12 +18,7 @@
|
|
|
18
18
|
"require": "./script/index.js"
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
|
-
"scripts": {
|
|
22
|
-
"test": "node test_runner.js"
|
|
23
|
-
},
|
|
24
21
|
"devDependencies": {
|
|
25
|
-
"@types/node": "^18.11.9"
|
|
26
|
-
"picocolors": "^1.0.0",
|
|
27
|
-
"@deno/shim-deno": "~0.16.1"
|
|
22
|
+
"@types/node": "^18.11.9"
|
|
28
23
|
}
|
|
29
24
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { IdentityTransformer } from "./IdentityTransformer.js";
|
|
2
2
|
import { DocumentNode, Node, TextNode } from "./types.js";
|
|
3
3
|
interface BlockInfo {
|
|
4
|
-
type:
|
|
4
|
+
type: "_block";
|
|
5
5
|
content: WhiteSpaceContainer[];
|
|
6
6
|
parent: BlockInfo | InlineInfo | null;
|
|
7
7
|
}
|
|
8
8
|
interface InlineInfo {
|
|
9
|
-
type:
|
|
9
|
+
type: "_inline";
|
|
10
10
|
content: WhiteSpaceContainer[];
|
|
11
11
|
parent: BlockInfo | InlineInfo | null;
|
|
12
12
|
}
|
|
@@ -18,9 +18,9 @@ class WhitespaceStretchingTransformer extends IdentityTransformer_js_1.IdentityT
|
|
|
18
18
|
value: void 0
|
|
19
19
|
});
|
|
20
20
|
this.root = {
|
|
21
|
-
type:
|
|
21
|
+
type: "_block",
|
|
22
22
|
content: [],
|
|
23
|
-
parent: null
|
|
23
|
+
parent: null,
|
|
24
24
|
};
|
|
25
25
|
this.cursor = this.root;
|
|
26
26
|
}
|
|
@@ -28,9 +28,9 @@ class WhitespaceStretchingTransformer extends IdentityTransformer_js_1.IdentityT
|
|
|
28
28
|
async beforeBlock() {
|
|
29
29
|
const parent = this.cursor;
|
|
30
30
|
const block = {
|
|
31
|
-
type:
|
|
31
|
+
type: "_block",
|
|
32
32
|
content: [],
|
|
33
|
-
parent
|
|
33
|
+
parent,
|
|
34
34
|
};
|
|
35
35
|
parent.content.push(block);
|
|
36
36
|
this.cursor = block;
|
|
@@ -45,9 +45,9 @@ class WhitespaceStretchingTransformer extends IdentityTransformer_js_1.IdentityT
|
|
|
45
45
|
async beforeInline() {
|
|
46
46
|
const parent = this.cursor;
|
|
47
47
|
const inline = {
|
|
48
|
-
type:
|
|
48
|
+
type: "_inline",
|
|
49
49
|
content: [],
|
|
50
|
-
parent
|
|
50
|
+
parent,
|
|
51
51
|
};
|
|
52
52
|
parent.content.push(inline);
|
|
53
53
|
this.cursor = inline;
|
|
@@ -61,13 +61,13 @@ class WhitespaceStretchingTransformer extends IdentityTransformer_js_1.IdentityT
|
|
|
61
61
|
reviewBlock(block) {
|
|
62
62
|
const nodes = [];
|
|
63
63
|
const visit = (r, level) => {
|
|
64
|
-
if (r.type ==
|
|
64
|
+
if (r.type == "text") {
|
|
65
65
|
nodes.push({
|
|
66
66
|
node: r,
|
|
67
|
-
level
|
|
67
|
+
level,
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
|
-
else if (r.type ==
|
|
70
|
+
else if (r.type == "_block") {
|
|
71
71
|
this.reviewBlock(r);
|
|
72
72
|
nodes.push({ node: null, level });
|
|
73
73
|
}
|
|
@@ -82,7 +82,9 @@ class WhitespaceStretchingTransformer extends IdentityTransformer_js_1.IdentityT
|
|
|
82
82
|
}
|
|
83
83
|
for (let i = 0; i < nodes.length; i++) {
|
|
84
84
|
const first = nodes[i];
|
|
85
|
-
const second = i + 1 < nodes.length
|
|
85
|
+
const second = i + 1 < nodes.length
|
|
86
|
+
? nodes[i + 1]
|
|
87
|
+
: { node: null, level: 0 };
|
|
86
88
|
// No use acting on a dead node
|
|
87
89
|
if (!first.node || !second.node) {
|
|
88
90
|
continue;
|
|
@@ -92,13 +94,13 @@ class WhitespaceStretchingTransformer extends IdentityTransformer_js_1.IdentityT
|
|
|
92
94
|
continue;
|
|
93
95
|
}
|
|
94
96
|
if (first.level < second.level) {
|
|
95
|
-
if (second.node.text.startsWith(
|
|
97
|
+
if (second.node.text.startsWith(" ")) {
|
|
96
98
|
second.node.text = second.node.text.slice(1);
|
|
97
|
-
first.node.text +=
|
|
99
|
+
first.node.text += " ";
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
102
|
else if (first.level > second.level) {
|
|
101
|
-
if (first.node.text.endsWith(
|
|
103
|
+
if (first.node.text.endsWith(" ")) {
|
|
102
104
|
first.node.text = first.node.text.slice(0, -1);
|
|
103
105
|
second.node.text = ` ${second.node.text}`;
|
|
104
106
|
}
|
|
@@ -108,8 +110,8 @@ class WhitespaceStretchingTransformer extends IdentityTransformer_js_1.IdentityT
|
|
|
108
110
|
// deno-lint-ignore require-await
|
|
109
111
|
async text(node) {
|
|
110
112
|
const replacement = {
|
|
111
|
-
type:
|
|
112
|
-
text: `${node.text}
|
|
113
|
+
type: "text",
|
|
114
|
+
text: `${node.text}`,
|
|
113
115
|
};
|
|
114
116
|
this.cursor.content.push(replacement);
|
|
115
117
|
return replacement;
|
|
@@ -5,7 +5,7 @@ const IdentityTransformer_js_1 = require("./IdentityTransformer.js");
|
|
|
5
5
|
class RemoveEmptyTextTransformer extends IdentityTransformer_js_1.IdentityTransformer {
|
|
6
6
|
// deno-lint-ignore require-await
|
|
7
7
|
async text(node) {
|
|
8
|
-
if (node.text ==
|
|
8
|
+
if (node.text == "") {
|
|
9
9
|
return null;
|
|
10
10
|
}
|
|
11
11
|
return node;
|
|
@@ -31,11 +31,11 @@ class WhitespaceTransformer extends IdentityTransformer_js_1.IdentityTransformer
|
|
|
31
31
|
}
|
|
32
32
|
// deno-lint-ignore require-await
|
|
33
33
|
async text(node) {
|
|
34
|
-
let result =
|
|
34
|
+
let result = "";
|
|
35
35
|
for (const c of node.text) {
|
|
36
|
-
if (c ==
|
|
36
|
+
if (c == " " || c == "\n" || c == "\t" || c == "\r") {
|
|
37
37
|
if (!this.stripWhitespace) {
|
|
38
|
-
result +=
|
|
38
|
+
result += " ";
|
|
39
39
|
this.stripWhitespace = true;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -48,15 +48,15 @@ class WhitespaceTransformer extends IdentityTransformer_js_1.IdentityTransformer
|
|
|
48
48
|
return null;
|
|
49
49
|
}
|
|
50
50
|
const text = {
|
|
51
|
-
type:
|
|
52
|
-
text: result
|
|
51
|
+
type: "text",
|
|
52
|
+
text: result,
|
|
53
53
|
};
|
|
54
54
|
this.lastText = text;
|
|
55
55
|
return text;
|
|
56
56
|
}
|
|
57
57
|
stripLastText() {
|
|
58
58
|
if (this.lastText) {
|
|
59
|
-
if (this.lastText.text.endsWith(
|
|
59
|
+
if (this.lastText.text.endsWith(" ")) {
|
|
60
60
|
this.lastText.text = this.lastText.text.slice(0, -1);
|
|
61
61
|
}
|
|
62
62
|
this.lastText = null;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/esm/ExampleDocument.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/esm/_dnt.test_shims.d.ts
DELETED
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
/** RGB 8-bits per channel. Each in range `0->255` or `0x00->0xff` */
|
|
2
|
-
interface Rgb {
|
|
3
|
-
r: number;
|
|
4
|
-
g: number;
|
|
5
|
-
b: number;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Set changing text color to enabled or disabled
|
|
9
|
-
* @param value
|
|
10
|
-
*/
|
|
11
|
-
export declare function setColorEnabled(value: boolean): void;
|
|
12
|
-
/** Get whether text color change is enabled or disabled. */
|
|
13
|
-
export declare function getColorEnabled(): boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Reset the text modified
|
|
16
|
-
* @param str text to reset
|
|
17
|
-
*/
|
|
18
|
-
export declare function reset(str: string): string;
|
|
19
|
-
/**
|
|
20
|
-
* Make the text bold.
|
|
21
|
-
* @param str text to make bold
|
|
22
|
-
*/
|
|
23
|
-
export declare function bold(str: string): string;
|
|
24
|
-
/**
|
|
25
|
-
* The text emits only a small amount of light.
|
|
26
|
-
* @param str text to dim
|
|
27
|
-
*/
|
|
28
|
-
export declare function dim(str: string): string;
|
|
29
|
-
/**
|
|
30
|
-
* Make the text italic.
|
|
31
|
-
* @param str text to make italic
|
|
32
|
-
*/
|
|
33
|
-
export declare function italic(str: string): string;
|
|
34
|
-
/**
|
|
35
|
-
* Make the text underline.
|
|
36
|
-
* @param str text to underline
|
|
37
|
-
*/
|
|
38
|
-
export declare function underline(str: string): string;
|
|
39
|
-
/**
|
|
40
|
-
* Invert background color and text color.
|
|
41
|
-
* @param str text to invert its color
|
|
42
|
-
*/
|
|
43
|
-
export declare function inverse(str: string): string;
|
|
44
|
-
/**
|
|
45
|
-
* Make the text hidden.
|
|
46
|
-
* @param str text to hide
|
|
47
|
-
*/
|
|
48
|
-
export declare function hidden(str: string): string;
|
|
49
|
-
/**
|
|
50
|
-
* Put horizontal line through the center of the text.
|
|
51
|
-
* @param str text to strike through
|
|
52
|
-
*/
|
|
53
|
-
export declare function strikethrough(str: string): string;
|
|
54
|
-
/**
|
|
55
|
-
* Set text color to black.
|
|
56
|
-
* @param str text to make black
|
|
57
|
-
*/
|
|
58
|
-
export declare function black(str: string): string;
|
|
59
|
-
/**
|
|
60
|
-
* Set text color to red.
|
|
61
|
-
* @param str text to make red
|
|
62
|
-
*/
|
|
63
|
-
export declare function red(str: string): string;
|
|
64
|
-
/**
|
|
65
|
-
* Set text color to green.
|
|
66
|
-
* @param str text to make green
|
|
67
|
-
*/
|
|
68
|
-
export declare function green(str: string): string;
|
|
69
|
-
/**
|
|
70
|
-
* Set text color to yellow.
|
|
71
|
-
* @param str text to make yellow
|
|
72
|
-
*/
|
|
73
|
-
export declare function yellow(str: string): string;
|
|
74
|
-
/**
|
|
75
|
-
* Set text color to blue.
|
|
76
|
-
* @param str text to make blue
|
|
77
|
-
*/
|
|
78
|
-
export declare function blue(str: string): string;
|
|
79
|
-
/**
|
|
80
|
-
* Set text color to magenta.
|
|
81
|
-
* @param str text to make magenta
|
|
82
|
-
*/
|
|
83
|
-
export declare function magenta(str: string): string;
|
|
84
|
-
/**
|
|
85
|
-
* Set text color to cyan.
|
|
86
|
-
* @param str text to make cyan
|
|
87
|
-
*/
|
|
88
|
-
export declare function cyan(str: string): string;
|
|
89
|
-
/**
|
|
90
|
-
* Set text color to white.
|
|
91
|
-
* @param str text to make white
|
|
92
|
-
*/
|
|
93
|
-
export declare function white(str: string): string;
|
|
94
|
-
/**
|
|
95
|
-
* Set text color to gray.
|
|
96
|
-
* @param str text to make gray
|
|
97
|
-
*/
|
|
98
|
-
export declare function gray(str: string): string;
|
|
99
|
-
/**
|
|
100
|
-
* Set text color to bright black.
|
|
101
|
-
* @param str text to make bright-black
|
|
102
|
-
*/
|
|
103
|
-
export declare function brightBlack(str: string): string;
|
|
104
|
-
/**
|
|
105
|
-
* Set text color to bright red.
|
|
106
|
-
* @param str text to make bright-red
|
|
107
|
-
*/
|
|
108
|
-
export declare function brightRed(str: string): string;
|
|
109
|
-
/**
|
|
110
|
-
* Set text color to bright green.
|
|
111
|
-
* @param str text to make bright-green
|
|
112
|
-
*/
|
|
113
|
-
export declare function brightGreen(str: string): string;
|
|
114
|
-
/**
|
|
115
|
-
* Set text color to bright yellow.
|
|
116
|
-
* @param str text to make bright-yellow
|
|
117
|
-
*/
|
|
118
|
-
export declare function brightYellow(str: string): string;
|
|
119
|
-
/**
|
|
120
|
-
* Set text color to bright blue.
|
|
121
|
-
* @param str text to make bright-blue
|
|
122
|
-
*/
|
|
123
|
-
export declare function brightBlue(str: string): string;
|
|
124
|
-
/**
|
|
125
|
-
* Set text color to bright magenta.
|
|
126
|
-
* @param str text to make bright-magenta
|
|
127
|
-
*/
|
|
128
|
-
export declare function brightMagenta(str: string): string;
|
|
129
|
-
/**
|
|
130
|
-
* Set text color to bright cyan.
|
|
131
|
-
* @param str text to make bright-cyan
|
|
132
|
-
*/
|
|
133
|
-
export declare function brightCyan(str: string): string;
|
|
134
|
-
/**
|
|
135
|
-
* Set text color to bright white.
|
|
136
|
-
* @param str text to make bright-white
|
|
137
|
-
*/
|
|
138
|
-
export declare function brightWhite(str: string): string;
|
|
139
|
-
/**
|
|
140
|
-
* Set background color to black.
|
|
141
|
-
* @param str text to make its background black
|
|
142
|
-
*/
|
|
143
|
-
export declare function bgBlack(str: string): string;
|
|
144
|
-
/**
|
|
145
|
-
* Set background color to red.
|
|
146
|
-
* @param str text to make its background red
|
|
147
|
-
*/
|
|
148
|
-
export declare function bgRed(str: string): string;
|
|
149
|
-
/**
|
|
150
|
-
* Set background color to green.
|
|
151
|
-
* @param str text to make its background green
|
|
152
|
-
*/
|
|
153
|
-
export declare function bgGreen(str: string): string;
|
|
154
|
-
/**
|
|
155
|
-
* Set background color to yellow.
|
|
156
|
-
* @param str text to make its background yellow
|
|
157
|
-
*/
|
|
158
|
-
export declare function bgYellow(str: string): string;
|
|
159
|
-
/**
|
|
160
|
-
* Set background color to blue.
|
|
161
|
-
* @param str text to make its background blue
|
|
162
|
-
*/
|
|
163
|
-
export declare function bgBlue(str: string): string;
|
|
164
|
-
/**
|
|
165
|
-
* Set background color to magenta.
|
|
166
|
-
* @param str text to make its background magenta
|
|
167
|
-
*/
|
|
168
|
-
export declare function bgMagenta(str: string): string;
|
|
169
|
-
/**
|
|
170
|
-
* Set background color to cyan.
|
|
171
|
-
* @param str text to make its background cyan
|
|
172
|
-
*/
|
|
173
|
-
export declare function bgCyan(str: string): string;
|
|
174
|
-
/**
|
|
175
|
-
* Set background color to white.
|
|
176
|
-
* @param str text to make its background white
|
|
177
|
-
*/
|
|
178
|
-
export declare function bgWhite(str: string): string;
|
|
179
|
-
/**
|
|
180
|
-
* Set background color to bright black.
|
|
181
|
-
* @param str text to make its background bright-black
|
|
182
|
-
*/
|
|
183
|
-
export declare function bgBrightBlack(str: string): string;
|
|
184
|
-
/**
|
|
185
|
-
* Set background color to bright red.
|
|
186
|
-
* @param str text to make its background bright-red
|
|
187
|
-
*/
|
|
188
|
-
export declare function bgBrightRed(str: string): string;
|
|
189
|
-
/**
|
|
190
|
-
* Set background color to bright green.
|
|
191
|
-
* @param str text to make its background bright-green
|
|
192
|
-
*/
|
|
193
|
-
export declare function bgBrightGreen(str: string): string;
|
|
194
|
-
/**
|
|
195
|
-
* Set background color to bright yellow.
|
|
196
|
-
* @param str text to make its background bright-yellow
|
|
197
|
-
*/
|
|
198
|
-
export declare function bgBrightYellow(str: string): string;
|
|
199
|
-
/**
|
|
200
|
-
* Set background color to bright blue.
|
|
201
|
-
* @param str text to make its background bright-blue
|
|
202
|
-
*/
|
|
203
|
-
export declare function bgBrightBlue(str: string): string;
|
|
204
|
-
/**
|
|
205
|
-
* Set background color to bright magenta.
|
|
206
|
-
* @param str text to make its background bright-magenta
|
|
207
|
-
*/
|
|
208
|
-
export declare function bgBrightMagenta(str: string): string;
|
|
209
|
-
/**
|
|
210
|
-
* Set background color to bright cyan.
|
|
211
|
-
* @param str text to make its background bright-cyan
|
|
212
|
-
*/
|
|
213
|
-
export declare function bgBrightCyan(str: string): string;
|
|
214
|
-
/**
|
|
215
|
-
* Set background color to bright white.
|
|
216
|
-
* @param str text to make its background bright-white
|
|
217
|
-
*/
|
|
218
|
-
export declare function bgBrightWhite(str: string): string;
|
|
219
|
-
/**
|
|
220
|
-
* Set text color using paletted 8bit colors.
|
|
221
|
-
* https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
|
|
222
|
-
* @param str text color to apply paletted 8bit colors to
|
|
223
|
-
* @param color code
|
|
224
|
-
*/
|
|
225
|
-
export declare function rgb8(str: string, color: number): string;
|
|
226
|
-
/**
|
|
227
|
-
* Set background color using paletted 8bit colors.
|
|
228
|
-
* https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
|
|
229
|
-
* @param str text color to apply paletted 8bit background colors to
|
|
230
|
-
* @param color code
|
|
231
|
-
*/
|
|
232
|
-
export declare function bgRgb8(str: string, color: number): string;
|
|
233
|
-
/**
|
|
234
|
-
* Set text color using 24bit rgb.
|
|
235
|
-
* `color` can be a number in range `0x000000` to `0xffffff` or
|
|
236
|
-
* an `Rgb`.
|
|
237
|
-
*
|
|
238
|
-
* To produce the color magenta:
|
|
239
|
-
*
|
|
240
|
-
* ```ts
|
|
241
|
-
* import { rgb24 } from "https://deno.land/std@$STD_VERSION/fmt/colors.ts";
|
|
242
|
-
* rgb24("foo", 0xff00ff);
|
|
243
|
-
* rgb24("foo", {r: 255, g: 0, b: 255});
|
|
244
|
-
* ```
|
|
245
|
-
* @param str text color to apply 24bit rgb to
|
|
246
|
-
* @param color code
|
|
247
|
-
*/
|
|
248
|
-
export declare function rgb24(str: string, color: number | Rgb): string;
|
|
249
|
-
/**
|
|
250
|
-
* Set background color using 24bit rgb.
|
|
251
|
-
* `color` can be a number in range `0x000000` to `0xffffff` or
|
|
252
|
-
* an `Rgb`.
|
|
253
|
-
*
|
|
254
|
-
* To produce the color magenta:
|
|
255
|
-
*
|
|
256
|
-
* ```ts
|
|
257
|
-
* import { bgRgb24 } from "https://deno.land/std@$STD_VERSION/fmt/colors.ts";
|
|
258
|
-
* bgRgb24("foo", 0xff00ff);
|
|
259
|
-
* bgRgb24("foo", {r: 255, g: 0, b: 255});
|
|
260
|
-
* ```
|
|
261
|
-
* @param str text color to apply 24bit rgb to
|
|
262
|
-
* @param color code
|
|
263
|
-
*/
|
|
264
|
-
export declare function bgRgb24(str: string, color: number | Rgb): string;
|
|
265
|
-
/**
|
|
266
|
-
* Remove ANSI escape codes from the string.
|
|
267
|
-
* @param string to remove ANSI escape codes from
|
|
268
|
-
*/
|
|
269
|
-
export declare function stripColor(string: string): string;
|
|
270
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export declare enum DiffType {
|
|
2
|
-
removed = "removed",
|
|
3
|
-
common = "common",
|
|
4
|
-
added = "added"
|
|
5
|
-
}
|
|
6
|
-
export interface DiffResult<T> {
|
|
7
|
-
type: DiffType;
|
|
8
|
-
value: T;
|
|
9
|
-
details?: Array<DiffResult<T>>;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Renders the differences between the actual and expected values
|
|
13
|
-
* @param A Actual value
|
|
14
|
-
* @param B Expected value
|
|
15
|
-
*/
|
|
16
|
-
export declare function diff<T>(A: T[], B: T[]): Array<DiffResult<T>>;
|
|
17
|
-
/**
|
|
18
|
-
* Renders the differences between the actual and expected strings
|
|
19
|
-
* Partially inspired from https://github.com/kpdecker/jsdiff
|
|
20
|
-
* @param A Actual string
|
|
21
|
-
* @param B Expected string
|
|
22
|
-
*/
|
|
23
|
-
export declare function diffstr(A: string, B: string): DiffResult<string>[];
|
|
24
|
-
export declare function buildMessage(diffResult: ReadonlyArray<DiffResult<string>>, { stringDiff }?: {
|
|
25
|
-
stringDiff?: boolean | undefined;
|
|
26
|
-
}): string[];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function format(v: unknown): string;
|