Comparing version
# CHANGELOG | ||
*versions follow [SemVer](http://semver.org)* | ||
## 3.0.0 - 2022-12-30 | ||
**BREAKING CHANGE**: convert to ES module | ||
## 2.0.0 - 2019-09-25 | ||
@@ -5,0 +8,0 @@ **BREAKING CHANGE**: |
49
index.js
@@ -50,3 +50,3 @@ // Copied from https://github.com/chalk/chalk | ||
module.exports = Object.keys(styleMap).reduce((index, styleName) => { | ||
const chalk = Object.keys(styleMap).reduce((index, styleName) => { | ||
index[styleName] = function (content) { | ||
@@ -57,1 +57,48 @@ return `\u001B[${styleMap[styleName][0]}m${content}\u001B[${styleMap[styleName][1]}m` | ||
}, {}) | ||
export default chalk | ||
export const reset = chalk.reset | ||
export const bold = chalk.bold | ||
export const dim = chalk.dim | ||
export const italic = chalk.italic | ||
export const underline = chalk.underline | ||
export const inverse = chalk.inverse | ||
export const hidden = chalk.hidden | ||
export const strikethrough = chalk.strikethrough | ||
// front color | ||
export const black = chalk.black | ||
export const red = chalk.red | ||
export const green = chalk.green | ||
export const yellow = chalk.yellow | ||
export const blue = chalk.blue | ||
export const magenta = chalk.magenta | ||
export const cyan = chalk.cyan | ||
export const white = chalk.white | ||
export const grey = chalk.grey | ||
export const redBright = chalk.redBright | ||
export const greenBright = chalk.greenBright | ||
export const yellowBright = chalk.yellowBright | ||
export const blueBright = chalk.blueBright | ||
export const magentaBright = chalk.magentaBright | ||
export const cyanBright = chalk.cyanBright | ||
export const whiteBright = chalk.whiteBright | ||
// back color | ||
export const bgBlack = chalk.bgBlack | ||
export const bgRed = chalk.bgRed | ||
export const bgGreen = chalk.bgGreen | ||
export const bgYellow = chalk.bgYellow | ||
export const bgBlue = chalk.bgBlue | ||
export const bgMagenta = chalk.bgMagenta | ||
export const bgCyan = chalk.bgCyan | ||
export const bgWhite = chalk.bgWhite | ||
export const bgGrey = chalk.bgGrey | ||
export const bgRedBright = chalk.bgRedBright | ||
export const bgGreenBright = chalk.bgGreenBright | ||
export const bgYellowBright = chalk.bgYellowBright | ||
export const bgBlueBright = chalk.bgBlueBright | ||
export const bgMagentaBright = chalk.bgMagentaBright | ||
export const bgCyanBright = chalk.bgCyanBright | ||
export const bgWhiteBright = chalk.bgWhiteBright |
{ | ||
"name": "tiny-chalk", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"type": "module", | ||
"description": "A super tiny version of chalk", | ||
"main": "./index.js", | ||
"scripts": { | ||
"test": "node ./test.js" | ||
}, | ||
"repository": { | ||
@@ -27,3 +25,6 @@ "type": "git", | ||
}, | ||
"homepage": "https://github.com/maxlath/tiny-chalk#readme" | ||
} | ||
"homepage": "https://github.com/maxlath/tiny-chalk#readme", | ||
"scripts": { | ||
"test": "node ./test.js" | ||
} | ||
} |
# tiny-chalk | ||
A super tiny version of [chalk](https://github.com/chalk/chalk), loading in ~1ms instead of ~10ms for chalk | ||
A super tiny version of [chalk](https://github.com/chalk/chalk), loading in ~1ms instead of ~10ms for chalk (YMMV) | ||
This is convenient when you are in a controlled environment (that is that you don't need all the `supports-color` detection `chalk` provides) | ||
## Install | ||
```bash | ||
# ES module | ||
npm install tiny-chalk | ||
# CommonJS | ||
npm install tiny-chalk@v2 | ||
``` | ||
@@ -14,3 +20,3 @@ | ||
```js | ||
const { red, bold, bgBlack } = require('tiny-chalk') | ||
import { red, bold, bgBlack } from 'tiny-chalk' | ||
console.log(red('Hello world!')) | ||
@@ -17,0 +23,0 @@ console.log(bold(bgBlack(red('Hello world again!')))) |
18
test.js
#!/usr/bin/env node | ||
console.time('init time') | ||
const chalk = require('.') | ||
console.timeEnd('init time') | ||
import { red, blue, yellow, green, bgGrey, bgMagenta } from './index.js' | ||
console.log(chalk.red('chalk')) | ||
console.log(chalk.blue('chalk')) | ||
console.log(chalk.yellow('chalk')) | ||
console.log(chalk.green('chalk')) | ||
console.log(chalk.grey('chalk')) | ||
console.log(chalk.bgGrey('chalk')) | ||
console.log(chalk.bgMagenta(chalk.blue('chalk'))) | ||
console.log(red('chalk')) | ||
console.log(blue('chalk')) | ||
console.log(yellow('chalk')) | ||
console.log(green('chalk')) | ||
console.log(grey('chalk')) | ||
console.log(bgGrey('chalk')) | ||
console.log(bgMagenta(chalk.blue('chalk'))) |
6084
88.71%7
40%104
65.08%74
8.82%Yes
NaN