From 029eccf69717e46d73f9aa0d531a7a7f7a091d01 Mon Sep 17 00:00:00 2001 From: Juyeong Maing Date: Wed, 23 Jul 2025 20:53:59 +0900 Subject: [PATCH 1/2] add option `enable` --- index.js | 4 ++-- types/index.d.ts | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index d80fe2b..617773e 100644 --- a/index.js +++ b/index.js @@ -13,9 +13,9 @@ const hasColor = () => { return false; }; -const create = () => { +const create = ({ enabled } = {}) => { const colors = { - enabled: hasColor(), + enabled: enabled === undefined ? hasColor() : enabled, visible: true, styles: {}, keys: {} diff --git a/types/index.d.ts b/types/index.d.ts index ca52c52..3f8f33f 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -229,7 +229,14 @@ 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; + } + + function create(options?: Options): typeof ansiColors; } export = ansiColors; From 1e89507fcf7892c199a9d84921de6faa565b230c Mon Sep 17 00:00:00 2001 From: Juyeong Maing Date: Fri, 8 Aug 2025 23:27:09 +0900 Subject: [PATCH 2/2] add option `visible` --- index.js | 4 ++-- types/index.d.ts | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 617773e..fe06001 100644 --- a/index.js +++ b/index.js @@ -13,10 +13,10 @@ const hasColor = () => { return false; }; -const create = ({ enabled } = {}) => { +const create = ({ enabled, visible = true } = {}) => { const colors = { enabled: enabled === undefined ? hasColor() : enabled, - visible: true, + visible, styles: {}, keys: {} }; diff --git a/types/index.d.ts b/types/index.d.ts index 3f8f33f..c545c92 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -234,6 +234,10 @@ declare namespace ansiColors { * 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;