forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request DefinitelyTyped#2411 from Bartvds/def/chalk
added definitions for chalk
- Loading branch information
Showing
2 changed files
with
122 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/// <reference path="chalk.d.ts" /> | ||
|
||
import chalk = require('chalk'); | ||
|
||
var str: string; | ||
var bool: boolean; | ||
|
||
chalk.enabled = bool; | ||
str = chalk.stripColor(str); | ||
|
||
bool = chalk.supportsColor; | ||
bool = chalk.hasColor(str); | ||
|
||
// style a string | ||
console.log( chalk.blue('Hello world!') ); | ||
|
||
// combine styled and normal strings | ||
console.log( chalk.blue('Hello'), 'World' + chalk.red('!') ); | ||
|
||
// compose multiple styles using the chainable API | ||
console.log( chalk.blue.bgRed.bold('Hello world!') ); | ||
|
||
// pass in multiple arguments | ||
console.log( chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz') ); | ||
|
||
// nest styles | ||
console.log( chalk.red('Hello', chalk.underline.bgBlue('world') + '!') ); | ||
|
||
// nest styles of the same type even (color, underline, background) | ||
console.log( chalk.green('I am a green line ' + chalk.blue('with a blue substring') + ' that becomes green again!') ); |
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 |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// Type definitions for chalk v0.4.0 | ||
// Project: https://github.com/sindresorhus/chalk | ||
// Definitions by: Diullei Gomes <https://github.com/Diullei>, Bart van der Schoor <https://github.com/Bartvds> | ||
// Definitions: https://github.com/borisyankov/DefinitelyTyped | ||
|
||
declare module Chalk { | ||
export interface ChalkModule extends ChalkStyle { | ||
enabled: boolean; | ||
supportsColor: boolean; | ||
styles: ChalkStyleMap; | ||
|
||
stripColor(value: string): any; | ||
hasColor(str: string): boolean; | ||
} | ||
|
||
export interface ChalkChain extends ChalkStyle { | ||
(...text: string[]): ChalkChain; | ||
} | ||
|
||
export interface ChalkStyleElement { | ||
open: string; | ||
close: string; | ||
} | ||
|
||
export interface ChalkStyle { | ||
// General | ||
reset: ChalkChain; | ||
bold: ChalkChain; | ||
italic: ChalkChain; | ||
underline: ChalkChain; | ||
inverse: ChalkChain; | ||
strikethrough: ChalkChain; | ||
|
||
// Text colors | ||
black: ChalkChain; | ||
red: ChalkChain; | ||
green: ChalkChain; | ||
yellow: ChalkChain; | ||
blue: ChalkChain; | ||
magenta: ChalkChain; | ||
cyan: ChalkChain; | ||
white: ChalkChain; | ||
gray: ChalkChain; | ||
|
||
// Background colors | ||
bgBlack: ChalkChain; | ||
bgRed: ChalkChain; | ||
bgGreen: ChalkChain; | ||
bgYellow: ChalkChain; | ||
bgBlue: ChalkChain; | ||
bgMagenta: ChalkChain; | ||
bgCyan: ChalkChain; | ||
bgWhite: ChalkChain; | ||
} | ||
|
||
export interface ChalkStyleMap { | ||
// General | ||
reset: ChalkStyleElement; | ||
bold: ChalkStyleElement; | ||
italic: ChalkStyleElement; | ||
underline: ChalkStyleElement; | ||
inverse: ChalkStyleElement; | ||
strikethrough: ChalkStyleElement; | ||
|
||
// Text colors | ||
black: ChalkStyleElement; | ||
red: ChalkStyleElement; | ||
green: ChalkStyleElement; | ||
yellow: ChalkStyleElement; | ||
blue: ChalkStyleElement; | ||
magenta: ChalkStyleElement; | ||
cyan: ChalkStyleElement; | ||
white: ChalkStyleElement; | ||
gray: ChalkStyleElement; | ||
|
||
// Background colors | ||
bgBlack: ChalkStyleElement; | ||
bgRed: ChalkStyleElement; | ||
bgGreen: ChalkStyleElement; | ||
bgYellow: ChalkStyleElement; | ||
bgBlue: ChalkStyleElement; | ||
bgMagenta: ChalkStyleElement; | ||
bgCyan: ChalkStyleElement; | ||
bgWhite: ChalkStyleElement; | ||
} | ||
} | ||
|
||
declare module "chalk" { | ||
var ch: Chalk.ChalkModule; | ||
export = ch; | ||
} | ||
|