package
Chainable `util.styleText()`.
npm install node-style-textGitHub-flavored package documentation.
Across all versions, last 30 days.
22,258 in 30 days
Runtime metadata.
Estimated unpacked size across 1 packages.
11.4 kB
Includes dependencies.
Chainable
util.styleText().
yarn add node-style-textimport styleText from 'node-style-text'
console.log(styleText.blue.underline('Hello world!'))
console.log(styleText.blue.underline`Hello ${'world'}!`))Use process.stderr to validate colors.
import {stdout, stderr} from 'node-style-text'
// Validate `process.stderr` if it can be colored instead of `process.stdout`.
console.log(stderr.underline('Hello world!'))Check options.stream for util.styleText for details.
Provide convenience API.
Chainable
- import {styleText} from 'node:utils'
+ import styleText from 'node-style-text'
console.log(
- styleText('blue', 'Hello world!')
+ styleText.blue('Hello world!')
)
console.log(
- styleText(['blue', 'underline'], 'Hello world!')
+ styleText.blue.underline('Hello world!')
)Support tagged templates
- import {styleText} from 'node:utils'
+ import styleText from 'node-style-text'
console.log(
- styleText(['blue', 'underline'], `Hello ${'world'}!`)
+ styleText.blue.underline`Hello ${'world'}!`
)styleText.<format>[.<format>...](string)Example: styleText.red.bold.underline('Hello, world!');
Available formats: util.inspect.colors
This module also provide an ESLint config to enforce use tagged templates when possible
// ✅
styleText.red(`foo`)
// ❌
styleText.red`foo`Add this to you eslint.config.js
import eslintConfigNodeStyleText from 'node-style-text/eslint-config'
export default [
// ... Your other eslint configs
eslintConfigNodeStyleText,
]