Expose enable/disable methods

closes #221
This commit is contained in:
Bastien Caudan 2018-04-09 08:16:20 +02:00
parent dc82cc01d0
commit b674514f1b
3 changed files with 13 additions and 1 deletions

2
index.d.ts vendored
View File

@ -46,6 +46,8 @@ export interface Color {
zalgo: Color;
}
export function enable(): void;
export function disable(): void;
export function setTheme(theme: any): void;
export let enabled: boolean;

View File

@ -2,7 +2,7 @@
The MIT License (MIT)
Original Library
Original Library
- Copyright (c) Marak Squires
Additional functionality
@ -42,6 +42,14 @@ if (typeof colors.enabled === "undefined") {
colors.enabled = colors.supportsColor() !== false;
}
colors.enable = function () {
colors.enabled = true;
};
colors.disable = function () {
colors.enabled = false;
};
colors.stripColors = colors.strip = function(str){
return ("" + str).replace(/\x1B\[\d+m/g, '');
};

2
safe.d.ts vendored
View File

@ -4,6 +4,8 @@
// Definitions: https://github.com/Marak/colors.js
export const enabled: boolean;
export function enable(): void;
export function disable(): void;
export function strip(str: string): string;
export function stripColors(str: string): string;