mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Merge pull request #30202 from Gustavo6046/master
Updating the ANSI typings.
This commit is contained in:
@@ -20,5 +20,13 @@ Object.keys({
|
||||
, brightCyan: 96
|
||||
, brightWhite: 97
|
||||
}).forEach((color) => {
|
||||
cursor[color]().bold().write(`Hello, bold ${color.replace(/([a-z])([A-Z])/g, (_: string, l: string, u: string): string => `${l} ${u.toLowerCase()}`)} world!\n`).reset();
|
||||
const cname = color.replace(/([a-z])([A-Z])/g, (_: string, l: string, u: string): string => `${l} ${u.toLowerCase()}`);
|
||||
|
||||
((<(...anything: any[]) => ansi.Cursor> cursor[color])()
|
||||
.bold()
|
||||
.bg)[color === 'blue' || color === 'brightBlue' ? 'black' : 'blue']()
|
||||
.write(
|
||||
`Hello, bold ${cname} world!\n`
|
||||
)
|
||||
.reset();
|
||||
});
|
||||
|
||||
Vendored
+16
-3
@@ -2,6 +2,7 @@
|
||||
// Project: https://www.npmjs.com/package/ansi
|
||||
// Definitions by: Gustavo6046 <https://github.com/Gustavo6046>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
/**
|
||||
* References:
|
||||
@@ -14,11 +15,19 @@
|
||||
/// <reference types="node" />
|
||||
import { Stream } from "stream";
|
||||
|
||||
declare function ansi(stream: Stream, options?: any): ansi.Cursor;
|
||||
interface CursorOptions {
|
||||
enabled: boolean;
|
||||
buffering: boolean;
|
||||
}
|
||||
|
||||
declare function ansi(stream: Stream, options?: CursorOptions): ansi.Cursor;
|
||||
|
||||
declare namespace ansi {
|
||||
class Cursor {
|
||||
constructor(stream: Stream, options?: any);
|
||||
bg: Colorer;
|
||||
fg: Colorer;
|
||||
|
||||
constructor(stream: Stream, options?: CursorOptions);
|
||||
|
||||
/**
|
||||
* Helper function that calls `write()` on the underlying Stream.
|
||||
@@ -161,7 +170,11 @@ declare namespace ansi {
|
||||
}
|
||||
|
||||
interface Cursor {
|
||||
[key: string]: (...anything: any[]) => Cursor;
|
||||
[key: string]: ((...anything: any[]) => Cursor) | Colorer;
|
||||
}
|
||||
|
||||
interface Colorer {
|
||||
[key: string]: (...anything: any[]) => (Cursor | Colorer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user