-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Perfect: You can clear the console before print
- Loading branch information
1 parent
978df75
commit db81bbb
Showing
3 changed files
with
70 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,53 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var print = { | ||
log: function (info) { | ||
log: function (info, clear) { | ||
if (clear) | ||
print.clear(); | ||
console.log(info); | ||
}, | ||
warn: function (info) { | ||
warn: function (info, clear) { | ||
if (clear) | ||
print.clear(); | ||
console.log('\x1b[31;33m' + info + '\x1b[0m'); | ||
}, | ||
error: function (info) { | ||
error: function (info, clear) { | ||
if (clear) | ||
print.clear(); | ||
console.log('\x1b[31;40m' + info + '\x1b[0m'); | ||
}, | ||
success: function (info) { | ||
success: function (info, clear) { | ||
if (clear) | ||
print.clear(); | ||
console.log('\x1b[42;30m' + info + '\x1b[0m'); | ||
}, | ||
tip: function (info) { | ||
tip: function (info, clear) { | ||
if (clear) | ||
print.clear(); | ||
console.log('\x1b[40;32m' + info + '\x1b[0m'); | ||
}, | ||
red: function (info) { | ||
red: function (info, clear) { | ||
if (clear) | ||
print.clear(); | ||
console.log('\x1b[31m' + info + '\x1b[39m'); | ||
}, | ||
green: function (info) { | ||
green: function (info, clear) { | ||
if (clear) | ||
print.clear(); | ||
console.log('\x1b[32m' + info + '\x1b[39m'); | ||
}, | ||
white: function (info) { | ||
white: function (info, clear) { | ||
if (clear) | ||
print.clear(); | ||
console.log('\x1b[37m' + info + '\x1b[39m'); | ||
}, | ||
yellow: function (info) { | ||
yellow: function (info, clear) { | ||
if (clear) | ||
print.clear(); | ||
console.log('\x1b[31;33m' + info + '\x1b[0m'); | ||
}, | ||
clear: function () { | ||
process.stdout.write(process.platform === 'win32' ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[3J\x1B[H'); | ||
}, | ||
}; | ||
exports.default = print; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,52 @@ | ||
const print = { | ||
log(info: string): void { | ||
log(info: string, clear?: boolean): void { | ||
if (clear) print.clear() | ||
|
||
console.log(info) | ||
}, | ||
warn(info: string): void { | ||
warn(info: string, clear?: boolean): void { | ||
if (clear) print.clear() | ||
|
||
console.log('\x1b[31;33m' + info + '\x1b[0m') | ||
}, | ||
error(info: string): void { | ||
error(info: string, clear?: boolean): void { | ||
if (clear) print.clear() | ||
|
||
console.log('\x1b[31;40m' + info + '\x1b[0m') | ||
}, | ||
success(info: string): void { | ||
success(info: string, clear?: boolean): void { | ||
if (clear) print.clear() | ||
|
||
console.log('\x1b[42;30m' + info + '\x1b[0m') | ||
}, | ||
tip(info: string): void { | ||
tip(info: string, clear?: boolean): void { | ||
if (clear) print.clear() | ||
|
||
console.log('\x1b[40;32m' + info + '\x1b[0m') | ||
}, | ||
red(info: string): void { | ||
red(info: string, clear?: boolean): void { | ||
if (clear) print.clear() | ||
|
||
console.log('\x1b[31m' + info + '\x1b[39m') | ||
}, | ||
green(info: string): void { | ||
green(info: string, clear?: boolean): void { | ||
if (clear) print.clear() | ||
|
||
console.log('\x1b[32m' + info + '\x1b[39m') | ||
}, | ||
white(info: string): void { | ||
white(info: string, clear?: boolean): void { | ||
if (clear) print.clear() | ||
|
||
console.log('\x1b[37m' + info + '\x1b[39m') | ||
}, | ||
yellow(info: string): void { | ||
yellow(info: string, clear?: boolean): void { | ||
if (clear) print.clear() | ||
|
||
console.log('\x1b[31;33m' + info + '\x1b[0m') | ||
}, | ||
clear(): void { | ||
process.stdout.write(process.platform === 'win32' ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[3J\x1B[H') | ||
}, | ||
} | ||
|
||
export default print |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
declare const print: { | ||
log(info: string): void; | ||
warn(info: string): void; | ||
error(info: string): void; | ||
success(info: string): void; | ||
tip(info: string): void; | ||
red(info: string): void; | ||
green(info: string): void; | ||
white(info: string): void; | ||
yellow(info: string): void; | ||
log(info: string, clear?: boolean | undefined): void; | ||
warn(info: string, clear?: boolean | undefined): void; | ||
error(info: string, clear?: boolean | undefined): void; | ||
success(info: string, clear?: boolean | undefined): void; | ||
tip(info: string, clear?: boolean | undefined): void; | ||
red(info: string, clear?: boolean | undefined): void; | ||
green(info: string, clear?: boolean | undefined): void; | ||
white(info: string, clear?: boolean | undefined): void; | ||
yellow(info: string, clear?: boolean | undefined): void; | ||
clear(): void; | ||
}; | ||
export default print; |