diff --git a/index.js b/index.js index d80fe2b..fe06001 100644 --- a/index.js +++ b/index.js @@ -13,10 +13,10 @@ const hasColor = () => { return false; }; -const create = () => { +const create = ({ enabled, visible = true } = {}) => { const colors = { - enabled: hasColor(), - visible: true, + enabled: enabled === undefined ? hasColor() : enabled, + visible, styles: {}, keys: {} }; diff --git a/types/index.d.ts b/types/index.d.ts index ca52c52..c545c92 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -229,7 +229,18 @@ declare namespace ansiColors { */ function ok(...args: string[]): string; - function create(): typeof ansiColors; + interface Options { + /** + * Force enable or disable regardless of the environment. + */ + enabled?: boolean | undefined; + /** + * When set to false, all styled text will be invisible. Defaults to true. + */ + visible?: boolean | undefined; + } + + function create(options?: Options): typeof ansiColors; } export = ansiColors;