Gathering detailed insights and metrics for @silva97/ansi
Gathering detailed insights and metrics for @silva97/ansi
Gathering detailed insights and metrics for @silva97/ansi
Gathering detailed insights and metrics for @silva97/ansi
Tag function to parse ANSI colors in template strings
npm install @silva97/ansi
Typescript
Module System
Node Version
NPM Version
68.5
Supply Chain
98.7
Quality
75.4
Maintenance
100
Vulnerability
100
License
JavaScript (62.2%)
TypeScript (37.8%)
Total Downloads
1,207
Last Day
1
Last Week
3
Last Month
22
Last Year
162
MIT License
1 Stars
36 Commits
1 Watchers
1 Branches
1 Contributors
Updated on May 17, 2022
Minified
Minified + Gzipped
Latest Version
1.1.3
Package Id
@silva97/ansi@1.1.3
Unpacked Size
8.45 kB
Size
3.72 kB
File Count
9
NPM Version
8.5.5
Node Version
16.15.0
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
0%
3
Compared to previous week
Last Month
633.3%
22
Compared to previous month
Last Year
-12.9%
162
Compared to previous year
4
This package implements a tag function to parse template strings and add ANSI escape sequences to use colors and text styles on terminal. (read about template strings)
1// Example 2const { ansi } = require('@silva97/ansi'); 3 4console.log(ansi`%{f.green}Hello %{f.red;bold;under}World!`);
Output:
1npm install @silva97/ansi 2# Or using yarn: 3yarn add @silva97/ansi
The ansi
tags follows the format %{...}
, it's similar to notation ${...}
of template strings
to expands the content of an expression on the string. But ansi tags is used to output ANSI escapes.
The color name is specified using the format mode.color
. Example f.blue
will be set the foreground
color to blue.
Mode | ANSI code | Description |
---|---|---|
f | 3 | Foreground color |
F | 9 | Light foreground color |
b | 4 | Background color |
Color | ANSI code |
---|---|
black | 0 |
red | 1 |
green | 2 |
yellow | 3 |
blue | 4 |
violet | 5 |
purple | 5 |
cyan | 6 |
white | 7 |
You can also specify styles to text. Example: %{bold;strike}Hello!
.
Style | ANSI code | Description |
---|---|---|
normal | 0 | Resets to normal style |
bold | 1 | Bold text |
italic | 3 | Italic text |
under | 4 | underline text |
blink | 5 | Blinks the text |
invert | 7 | Inverts background and foreground colors |
strike | 9 |
Warning: Some styles, like blink
and strike
, will not work on all terminals. (i.e. VS code integrated terminal)
Note: You can also specify the style numbers instead of the names. Example: %{31;1}
will be
translated to \x1b[31;1m
(same as %{f.red;bold}
).
Using ansi
tag function you can yet use ${}
expressions inside yours strings. Example:
1const { ansi } = require('@silva97/ansi'); 2 3const name = 'Luiz Felipe'; 4 5console.log(ansi`Your name is %{f.green;bold}${name}%{normal}!`);
You can simple disable the colors of the output if you set ansi.enabled
to false. For example:
1const { ansi } = require('@silva97/ansi'); 2 3ansi.enabled = false; 4const name = 'Luiz Felipe'; 5 6console.log(ansi`Your name is %{f.green;bold}${name}%{normal}!`); 7// Output: "Your name is Luiz Felipe!"
It's will print the text without colors.
If you previous has been escaped an text, but need the raw text back. You just need to use
the purify()
function and it will remove all ANSI escapes from the text.
1const { ansi, purify } = require('@silva97/ansi'); 2 3const name = 'Luiz Felipe'; 4const welcome = ansi`Your name is %{f.green;bold}${name}%{normal}!`; 5 6console.log(welcome); // Colored text 7console.log(purify(welcome)); // Normal text 8
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
8 existing vulnerabilities detected
Details
Reason
Found 0/20 approved changesets -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-04-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More