From 09e5a22cb78bf85a7d913d826fbd66bbc202c5ef Mon Sep 17 00:00:00 2001 From: Yanis Benson Date: Mon, 22 Jul 2019 02:26:44 +0300 Subject: [PATCH] stop triggering lazy loading of color converters on init --- source/index.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/source/index.js b/source/index.js index 686758b..90a6348 100644 --- a/source/index.js +++ b/source/index.js @@ -15,9 +15,6 @@ const levelMapping = [ 'ansi16m' ]; -// `color-convert` models to exclude from the Chalk API due to conflicts and such -const skipModels = new Set(['gray']); - const styles = Object.create(null); const applyOptions = (object, options = {}) => { @@ -76,11 +73,9 @@ styles.visible = { } }; -for (const model of Object.keys(ansiStyles.color.ansi)) { - if (skipModels.has(model)) { - continue; - } +const useModels = ['rgb', 'hsl', 'hsv', 'hwb', 'cmyk', 'xyz', 'lab', 'lch', 'hex', 'keyword', 'ansi', 'ansi256', 'hcg', 'apple']; +for (const model of useModels) { styles[model] = { get() { const {level} = this; @@ -92,11 +87,7 @@ for (const model of Object.keys(ansiStyles.color.ansi)) { }; } -for (const model of Object.keys(ansiStyles.bgColor.ansi)) { - if (skipModels.has(model)) { - continue; - } - +for (const model of useModels) { const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1); styles[bgModel] = { get() {