Socket
Socket
Sign inDemoInstall

picocolors

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    picocolors

The tiniest and the fastest coloring library ever


Version published
Weekly downloads
50M
decreased by-8.76%
Maintainers
1
Install size
9.41 kB
Created
Weekly downloads
 

Package description

What is picocolors?

The picocolors npm package is a minimalistic library for coloring terminal text. It provides a simple and efficient way to add color to console output in Node.js applications. The package is designed to be lightweight and fast, making it an excellent choice for projects that require colored output without the overhead of more feature-rich libraries.

What are picocolors's main functionalities?

Text coloring

This feature allows you to color text output in the terminal. The example demonstrates how to make text appear red.

"const pico = require('picocolors');\nconsole.log(pico.red('This text is red'));"

Text styling

This feature enables you to apply styles such as bolding to your text output. The example shows how to make text bold.

"const pico = require('picocolors');\nconsole.log(pico.bold('This text is bold'));"

Background coloring

With this feature, you can set the background color of your text output. The example illustrates setting a green background for the text.

"const pico = require('picocolors');\nconsole.log(pico.bgGreen('This text has a green background'));"

Other packages similar to picocolors

Readme

Source

picocolors

npm install picocolors

A tinier and faster alternative to nanocolors. Andrey, are you even trying?

import { green, italic } from "picocolors";

console.log(green(`How are ${italic(`you`)} doing?`));
  • Up to 2x faster and 2x smaller than alternatives
  • 3x faster and 10x smaller than chalk
  • TypeScript & Flowtype support
  • NO_COLOR friendly
  • The same API, but faster
  • No String.prototype modifications
  • No dependencies and the smallest node_modules footprint
  • Tree-shakeable (in case a Node.js package needs it?)

Prior Art

Credits go to the following projects:

Benchmarks

nanocolors benchmark:

./test/size.js
Data from packagephobia.com
chalk         101 kB
cli-color    1249 kB
ansi-colors    25 kB
kleur          21 kB
colorette      16 kB
nanocolors     16 kB
+picocolors      8 kB
$ ./test/complex-benchmark.js
chalk          2,618,824 ops/sec
cli-color        326,445 ops/sec
ansi-colors    1,057,188 ops/sec
kleur          2,543,659 ops/sec
kleur/colors   2,841,679 ops/sec
colorette      3,219,038 ops/sec
nanocolors     3,672,600 ops/sec
+picocolors     6,079,950 ops/sec

colorette benchmark:

$ npm start
+picocolors × 1,203,773 ops/sec
chalk × 474,359 ops/sec
kleur × 482,915 ops/sec
colors × 233,138 ops/sec
colorette × 657,896 ops/sec
nanocolors × 660,817 ops/sec
ansi-colors × 290,986 ops/sec

Replacing nanocolors

Just replace imports

-import { green, italic } from 'nanocolors';
+import { green, italic } from 'picocolors';

Keywords

FAQs

Last updated on 27 Sep 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc