Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
github.com/efekarakus/termcolor
Detects what level of color support your terminal has. This package is heavily inspired by chalk's support-color module.
go get github.com/efekarakus/termcolor
Colorize output by finding out which level of color your terminal support:
func main() {
switch l := termcolor.SupportLevel(os.Stderr); l {
case termcolor.Level16M:
// wrap text with 24 bit color https://en.wikipedia.org/wiki/ANSI_escape_code#24-bit
fmt.Fprint(os.Stderr, "\x1b[38;2;25;255;203mSuccess!\n\x1b[0m")
case termcolor.Level256:
// wrap text with 8 bit color https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
fmt.Fprint(os.Stderr, "\x1b[38;5;118mSuccess!\n\x1b[0m")
case termcolor.LevelBasic:
// wrap text with 3/4 bit color https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit
fmt.Fprint(os.Stderr, "\x1b[92mSuccess!\n\x1b[0m")
default:
// no color, return text as is.
fmt.Fprint(os.Stderr, "Success!\n")
}
}
Alternatively, you can use:
if termcolor.Supports16M(os.Stderr) {}
if termcolor.Supports256(os.Stderr) {}
if termcolor.SupportsBasic(os.Stderr) {}
if termcolor.SupportsNone(os.Stderr) {}
The same environment variable and flag priorities as chalk's supports-color module is applied.
It obeys the
--color
and--no-color
CLI flags.For situations where using
--color
is not possible, use the environment variableFORCE_COLOR=1
(level 1),FORCE_COLOR=2
(level 2), orFORCE_COLOR=3
(level 3) to forcefully enable color, orFORCE_COLOR=0
to forcefully disable. The use ofFORCE_COLOR
overrides all other color support checks.Explicit 256/Truecolor mode can be enabled using the
--color=256
and--color=16m
flags, respectively.
The MIT License (MIT) - see LICENSE for more details.
FAQs
Unknown package
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.