Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
turbocolor
Advanced tools
Turbocolor is a Node.js library for colorizing text using ANSI escape sequences.
npm i turbocolor
const tc = require("turbocolor")
Using styles.
console.log(tc.red("Hello!"))
Chaining styles.
console.log(tc.red.bold("Turbo") + tc.bgRed.white("Color"))
Using template literals.
console.log(`
${tc.bold("Score")}: ${100}
Lives: ${tc.red.inverse(1)}
Level: ${tc.bgCyan.black.inverse(2)}
`)
Nesting styles.
console.log(`Normal ${tc.bold(`Bold ${tc.red("Bold/Red")} Bold`)} Normal`)
Using console.log string substitution.
console.log(tc.green("Total: $%f"), 1.99)
Every style function can be chained or nested with one another and when invoked, will return the given string argument wrapped in the corresponding ANSI escape codes. Style precedence is determined by chaining order in a first-come, first-served basis. This means that tc.red.green.blue
is reduced to tc.red
.
Turbocolor exports ANSI escape codes for each available style. Use them if you want to stylize console output manually.
const { Styles } = require("turbocolor")
console.log(`${Styles.red.open}Red${Styles.red.close}`)
Color support is automatically enabled if your terminal supports it, but you can toggle it on/off as needed.
const tc = require("turbocolor")
tc.enabled = false
Turbocolor only supports the regular color set at the moment. If you want to use the high intensity variations or need 256 color/Truecolor support, please use chalk instead.
Colors | Background Colors | Modifiers |
---|---|---|
black | bgBlack | dim |
red | bgRed | bold |
green | bgGreen | hidden |
yellow | bgYellow | italic |
blue | bgBlue | underline |
magenta | bgMagenta | inverse |
cyan | bgCyan | |
white | bgWhite | reset |
gray |
All tests run on a 2.4GHz Intel Core i7 CPU with 16 GB memory.
npm i -C bench && node bench
# Using Styles chalk × 8,510 ops/sec kleur × 298,812 ops/sec ansi-colors × 299,145 ops/sec turbocolor × 606,180 ops/sec # Chaining Styles chalk × 1,881 ops/sec kleur × 43,187 ops/sec ansi-colors × 22,549 ops/sec turbocolor × 58,745 ops/sec # Nesting Styles chalk × 12,449 ops/sec kleur × 183,384 ops/sec ansi-colors × 123,488 ops/sec turbocolor × 197,616 ops/sec
Turbocolor is MIT licensed. See LICENSE.
FAQs
Node.js library for colorizing text using ANSI escape sequences.
The npm package turbocolor receives a total of 255 weekly downloads. As such, turbocolor popularity was classified as not popular.
We found that turbocolor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.