Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@digitak/print
Advanced tools
Readme
cute-print
is an alternative to well-known libraries like chalk which focus on less typing, more readability and confort of use.
Note that colors will not display on windows console. If you work on windows, you should really consider using an external terminal tool like cmder or hyper.
Also see cute-dump if you need to pretty-dump an object.
Import print
:
import { print } from 'cute-print'
Print a colored value :
print `Hello [red: world]!`
print `Hello [red.bgWhite: world]!`
const who = 'world'
print `Hello [green.bold:${who}]!`
// the default style is 'bold'. Both are identical :
print `Hello [:${who}]!`
print `Hello [bold:${who}]!`
You can nest colors - although it becomes easily complex : (you should consider using the next syntax)
print `Hello [red: world and [bold:universe]]!`
You can use a tag without the :
- that will affect the string up to the end.
print `Hello [red] world and [bold] universe!`
You can use [reset]
to reset the style :
print `Hello [red.bold] world and [reset] universe!`
You can also use a default styling for the whole string :
print.red `Hello red world!`
print.red.bgWhite `Hello red world on white background!`
Printing on the error
or warning
streams :
print.warn `You are a cute dangerous guy`
print.error `Something wrong happened`
print.error.red `Something wrong happened`
Remember that every library has its pros and cons - and everyone has its own preferences.
chalk
has support for true colorschalk
can be used to manipulate any strings where cute-print
purpose is only to print in the consolecute-print
has no dependenciescute-print
is written in Typescript and so can be used in any Typescript project with zero effortcute-print
has a cleaner syntax :The exemples are actually from my own code. I had a lot of logs to do and the syntax started to be painful so I decided to create this utilitary library.
// chalk : 74 characters (~ +50%)
console.log(chalk.green('\n-' + chalk.bold(' The mole starts to sniff!')))
// cute-print : 50 characters
print.green `\n- [bold] The mole starts to sniff!`
// chalk : 58 characters (~ +25%)
console.log(chalk.blueBright('Entities :'), total - empty)
// cute-print : 46 characters
print.brightBlue `Entities : ${total - empty}`
You can mix any tag anytime by using a dot .
as separator.
Color | Bright color | Background color |
---|---|---|
black | brightBlack | bgBlack |
red | brightRed | bgRed |
green | brightGreen | bgGreen |
yellow | brightYellow | bgYellow |
blue | brightBlue | bgBlue |
magenta | brightMagenta | bgMagenta |
cyan | brightCyan | bgCyan |
white | brightWhite | bgWhite |
All tags marked with an asterisk *
are not supported in many consoles.
Style | Effect |
---|---|
reset | Reset all style and color |
bold | Increase intensity |
dim | Decrease intensity |
italic* | |
underline | |
blink* | |
fastblink* | |
reverse | Swap foreground and background colors |
hidden* | Hide the given text |
stroke* | Strike text |
default |
FAQs
Enjoyable and colored printing in the console with node
The npm package @digitak/print receives a total of 6 weekly downloads. As such, @digitak/print popularity was classified as not popular.
We found that @digitak/print 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.