From dcef27757d5c0832b75da3468bf41d336dea1ab4 Mon Sep 17 00:00:00 2001 From: Jorge Bucaran Date: Fri, 17 Sep 2021 19:42:08 +0900 Subject: [PATCH] Introduce new API to allow instance reuse (#42) - New createColors function creates a Colorette instance - Color support is automatically detected, but you can override it via the useColor boolean property. - New isColorSupported property. true if the terminal supports color or false otherwise. - Remove options.enabled --- README.md | 41 +++++++++------- index.d.ts | 138 +++++++++++++++++++++++++++++++++++------------------ index.js | 75 ++++++++++++++++++++++------- 3 files changed, 174 insertions(+), 80 deletions(-) diff --git a/README.md b/README.md index 53badae..0fd9f29 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # Colorette -> Easily set the text color and style in the terminal. +> Easily set your terminal text color & styles. - No wonky prototype method-chain API. - Automatic color support detection. - Up to [2x faster](#benchmarks) than alternatives. -- [`NO_COLOR`](https://no-color.org) friendly. 👌 +- [`NO_COLOR`](https://no-color.org) friendly. ✅ Here's the first example to get you started. @@ -36,10 +36,14 @@ Of course, you can nest styles without breaking existing color sequences. console.log(bold(`I'm ${blue(`da ba ${underline("dee")} da ba`)} daa`)) ``` -Feeling adventurous? Try the [pipeline operator](https://github.com/tc39/proposal-pipeline-operator). +Need to dynamically enable or disable color? You can do that too. ```js -console.log("Da ba dee da ba daa" |> blue |> bold) +import { createColors } from "colorette" + +const { blue } = createColors({ useColor: false }) + +console.log(blue("Blue, not, nope, nah")) ``` ## Installation @@ -50,34 +54,37 @@ npm install colorette ## API -### `