cloggi 1.0.6 → 1.0.7
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/dist/index.d.ts +3 -0
- package/dist/index.js +19 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ declare class ClogBuilder {
|
|
|
2
2
|
private _color;
|
|
3
3
|
private _modifiers;
|
|
4
4
|
private _timed;
|
|
5
|
+
private _overwrite;
|
|
6
|
+
private _lastWasOverwrite;
|
|
5
7
|
private _print;
|
|
6
8
|
get red(): this;
|
|
7
9
|
get green(): this;
|
|
@@ -19,6 +21,7 @@ declare class ClogBuilder {
|
|
|
19
21
|
get inverse(): this;
|
|
20
22
|
get hidden(): this;
|
|
21
23
|
get timed(): this;
|
|
24
|
+
get ow(): this;
|
|
22
25
|
log(text: number | string | object): this;
|
|
23
26
|
error(text: number | string | object): this;
|
|
24
27
|
success(text: number | string | object): this;
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,8 @@ class ClogBuilder {
|
|
|
5
5
|
this._color = 'white';
|
|
6
6
|
this._modifiers = [];
|
|
7
7
|
this._timed = false;
|
|
8
|
+
this._overwrite = false;
|
|
9
|
+
this._lastWasOverwrite = false;
|
|
8
10
|
}
|
|
9
11
|
_print(text) {
|
|
10
12
|
const str = typeof text === 'object'
|
|
@@ -14,10 +16,22 @@ class ClogBuilder {
|
|
|
14
16
|
: text;
|
|
15
17
|
const output = `${this._timed ? `[${new Date().toTimeString().slice(0, 8)}]${typeof text === 'object' ? '\n' : ' - '}` : ''}${str}`;
|
|
16
18
|
const formats = [this._color, ...this._modifiers];
|
|
17
|
-
|
|
19
|
+
const styled = st(formats, output, { validateStream: false });
|
|
20
|
+
if (this._lastWasOverwrite) {
|
|
21
|
+
process.stdout.write('\r\x1B[2K');
|
|
22
|
+
}
|
|
23
|
+
if (this._overwrite) {
|
|
24
|
+
process.stdout.write(styled);
|
|
25
|
+
this._lastWasOverwrite = true;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
console.log(styled);
|
|
29
|
+
this._lastWasOverwrite = false;
|
|
30
|
+
}
|
|
18
31
|
this._color = 'white';
|
|
19
32
|
this._modifiers = [];
|
|
20
33
|
this._timed = false;
|
|
34
|
+
this._overwrite = false;
|
|
21
35
|
return this;
|
|
22
36
|
}
|
|
23
37
|
get red() {
|
|
@@ -84,6 +98,10 @@ class ClogBuilder {
|
|
|
84
98
|
this._timed = true;
|
|
85
99
|
return this;
|
|
86
100
|
}
|
|
101
|
+
get ow() {
|
|
102
|
+
this._overwrite = true;
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
87
105
|
log(text) {
|
|
88
106
|
return this._print(text);
|
|
89
107
|
}
|