stop triggering lazy loading of color converters on init

This commit is contained in:
Yanis Benson 2019-07-22 02:26:44 +03:00
parent 2a53389d72
commit 09e5a22cb7

View file

@ -15,9 +15,6 @@ const levelMapping = [
'ansi16m' '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 styles = Object.create(null);
const applyOptions = (object, options = {}) => { const applyOptions = (object, options = {}) => {
@ -76,11 +73,9 @@ styles.visible = {
} }
}; };
for (const model of Object.keys(ansiStyles.color.ansi)) { const useModels = ['rgb', 'hsl', 'hsv', 'hwb', 'cmyk', 'xyz', 'lab', 'lch', 'hex', 'keyword', 'ansi', 'ansi256', 'hcg', 'apple'];
if (skipModels.has(model)) {
continue;
}
for (const model of useModels) {
styles[model] = { styles[model] = {
get() { get() {
const {level} = this; 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)) { for (const model of useModels) {
if (skipModels.has(model)) {
continue;
}
const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1); const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
styles[bgModel] = { styles[bgModel] = {
get() { get() {