https://github.com/jessety/simple-log-colors
Extremely lightweight zero-dependency library for coloring Node terminal output
https://github.com/jessety/simple-log-colors
Last synced: 9 months ago
JSON representation
Extremely lightweight zero-dependency library for coloring Node terminal output
- Host: GitHub
- URL: https://github.com/jessety/simple-log-colors
- Owner: jessety
- License: mit
- Created: 2019-01-04T05:04:31.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2021-05-16T03:38:13.000Z (over 4 years ago)
- Last Synced: 2025-02-04T04:56:32.864Z (10 months ago)
- Language: TypeScript
- Homepage: https://npmjs.com/package/simple-log-colors
- Size: 25.4 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# simple-log-colors
Extremely lightweight zero-dependency library for coloring Node terminal output
[](https://github.com/jessety/simple-log-colors/actions)
[](https://www.npmjs.com/package/simple-log-colors)
[](https://github.com/jessety/simple-log-colors/blob/main/LICENSE)
## Install
```bash
npm install simple-log-colors
```
## Usage
```javascript
// Modules
import colors from 'simple-log-colors';
// CommonJS
const colors = require('simple-log-colors');
```
Template strings
```javascript
console.log(`Hello, ${colors.blue('world')}!`);
console.log(`Everything looks ${colors.cyan('better')} with a little ${colors.magenta('color')}!`);
```
Concatenation
```javascript
console.log(colors.redBackground('WARNING') + ' things are getting pretty ' + colors.yellow('colorful') + ' around here.');
```
Functions
```javascript
const { red, green, blue } = require('simple-log-colors');
console.log(`${red('Error')} the ${green('POST')} request to the ${blue('/test')} route was not signed properly.`);
```
## Colors
The following colors are supported:
- `black`
- `red`
- `green`
- `yellow`
- `blue`
- `magenta`
- `cyan`
- `white`
All of these colors are also supported as background colors. For background colors, add the suffix `Background` onto a supported color.
```javascript
console.error(colors.redBackground('ERROR'));
```
## License
MIT © Jesse Youngblood