Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyraspopov committed Oct 13, 2021
1 parent 147fbdb commit 228cea3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [v1.0.0](https://github.com/alexeyraspopov/picocolors/releases/tag/v1.0.0)

- Removed several code elements to reduce the package size ([#31](https://github.com/alexeyraspopov/picocolors/pull/31))
- Fixed optional flag for `createColors()` in TypeScript typings ([#34](https://github.com/alexeyraspopov/picocolors/pull/34))

## [v0.2.1](https://github.com/alexeyraspopov/picocolors/releases/tag/v0.2.1)

- Removed semicolons to reduce the package size ([#28](https://github.com/alexeyraspopov/picocolors/pull/28))
Expand Down
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ console.log(
)
```

* **No dependencies.**
* It **14 times** smaller and **2 times** faster than chalk.
* Used by popular tools like PostCSS, SVGO, Stylelint, and Browserslist.
* Node.js v6+ & browsers support. Support both CJS and ESM projects.
* TypeScript type declarations included.
* [`NO_COLOR`](https://no-color.org/) friendly.
- **No dependencies.**
- **14 times** smaller and **2 times** faster than chalk.
- Used by popular tools like PostCSS, SVGO, Stylelint, and Browserslist.
- Node.js v6+ & browsers support. Support for both CJS and ESM projects.
- TypeScript type declarations included.
- [`NO_COLOR`](https://no-color.org/) friendly.

## Motivation

Expand Down Expand Up @@ -95,13 +95,13 @@ $ node ./benchmarks/complex.js
Picocolors provides an object which includes a variety of text coloring and formatting functions

```javascript
import pc from "picocolors";
import pc from "picocolors"
```

The object includes following coloring functions: `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`, `gray`.

```javascript
console.log(`I see a ${pc.red("red door")} and I want it painted ${pc.black("black")}`);
console.log(`I see a ${pc.red("red door")} and I want it painted ${pc.black("black")}`)
```

The object also includes following background color modifier functions: `bgBlack`, `bgRed`, `bgGreen`, `bgYellow`, `bgBlue`, `bgMagenta`, `bgCyan`, `bgWhite`.
Expand All @@ -111,14 +111,14 @@ console.log(
pc.bgBlack(
pc.white(`Tom appeared on the sidewalk with a bucket of whitewash and a long-handled brush.`)
)
);
)
```

Besides colors, the object includes following formatting functions: `dim`, `bold`, `hidden`, `italic`, `underline`, `strikethrough`, `reset`, `inverse`.

```javascript
for (let task of tasks) {
console.log(`${pc.bold(task.name)} ${pc.dim(task.durationMs + "ms")}`);
console.log(`${pc.bold(task.name)} ${pc.dim(task.durationMs + "ms")}`)
}
```

Expand All @@ -127,19 +127,19 @@ The library provides additional utilities to ensure the best results for the tas
- `isColorSupported` — boolean, explicitly tells whether or not the colors or formatting appear on the screen

```javascript
import pc from "picocolors";
import pc from "picocolors"

if (pc.isColorSupported) {
console.log("Yay! This script can use colors and formatters");
console.log("Yay! This script can use colors and formatters")
}
```

- `createColors(enabled)` — a function that returns a new API object with manually defined color support configuration

```javascript
import pc from "picocolors";
import pc from "picocolors"

let { red, bgWhite } = pc.createColors(options.enableColors);
let { red, bgWhite } = pc.createColors(options.enableColors)
```

## Replacing `chalk`
Expand Down Expand Up @@ -167,10 +167,10 @@ The library provides additional utilities to ensure the best results for the tas

4. You can use [`colorize-template`](https://github.com/usmanyunusov/colorize-template)
to replace chalk’s tagged template literal.

```diff
+ import { createColorize } from 'colorize-template'

+ let colorize = createColorize(pico)
- chalk.red.bold`full {yellow ${"text"}}`
+ colorize`{red.bold full {yellow ${"text"}}}`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "picocolors",
"version": "0.2.1",
"version": "1.0.0",
"main": "./picocolors.js",
"types": "./picocolors.d.ts",
"browser": {
Expand Down

0 comments on commit 228cea3

Please sign in to comment.