Gathering detailed insights and metrics for chalk-template
Gathering detailed insights and metrics for chalk-template
Gathering detailed insights and metrics for chalk-template
Gathering detailed insights and metrics for chalk-template
npm install chalk-template
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99.3
Supply Chain
99.5
Quality
77.7
Maintenance
100
Vulnerability
100
License
JavaScript (93.9%)
TypeScript (6.1%)
Total Downloads
208,422,676
Last Day
317,782
Last Week
2,431,541
Last Month
11,029,671
Last Year
100,772,329
93 Stars
21 Commits
12 Forks
8 Watching
1 Branches
7 Contributors
Minified
Minified + Gzipped
Latest Version
1.1.0
Package Id
chalk-template@1.1.0
Unpacked Size
13.42 kB
Size
4.39 kB
File Count
5
NPM Version
9.2.0
Node Version
14.21.3
Publised On
23 May 2023
Cumulative downloads
Total Downloads
Last day
-33.4%
317,782
Compared to previous day
Last week
-12.5%
2,431,541
Compared to previous week
Last month
6.4%
11,029,671
Compared to previous month
Last year
47.4%
100,772,329
Compared to previous year
Terminal string styling with tagged template literals
1npm install chalk-template
For printing to standard output (stdout):
1import chalkTemplate from 'chalk-template'; 2import chalk from 'chalk'; 3 4console.log(chalkTemplate` 5CPU: {red ${cpu.totalPercent}%} 6RAM: {green ${ram.used / ram.total * 100}%} 7DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%} 8`); 9 10console.log(chalk.red.bgBlack(chalkTemplate`2 + 3 = {bold ${2 + 3}}`)); 11 12const miles = 18; 13const calculateFeet = miles => miles * 5280; 14 15console.log(chalkTemplate` 16 There are {bold 5280 feet} in a mile. 17 In {bold ${miles} miles}, there are {green.bold ${calculateFeet(miles)} feet}. 18`); 19 20console.log(chalkTemplate` 21 There are also {#FF0000 shorthand hex styles} for 22 both the {#ABCDEF foreground}, {#:123456 background}, 23 or {#ABCDEF:123456 both}. 24`);
For printing to standard error (stderr):
1import {chalkTemplateStderr} from 'chalk-template'; 2 3console.error(chalkTemplateStderr` 4CPU: {red ${cpu.totalPercent}%} 5RAM: {green ${ram.used / ram.total * 100}%} 6DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%} 7`);
Blocks are delimited by an opening curly brace ({
), a style, some content, and a closing curly brace (}
).
Template styles are chained exactly like normal Chalk styles. The following two statements are equivalent:
1import chalk from 'chalk'; 2import chalkTemplate from 'chalk-template'; 3 4console.log(chalk.bold.rgb(10, 100, 200)('Hello!')); 5console.log(chalkTemplate`{bold.rgb(10,100,200) Hello!}`);
Note that function styles (rgb()
, etc.) may not contain spaces between parameters.
All interpolated values (chalkTemplate`${foo}`
) are converted to strings via the .toString()
method. All curly braces ({
and }
) in interpolated value strings are escaped.
This function can be useful if you need to wrap the template function. However, prefer the default export whenever possible.
Note: It's up to you to properly escape the input.
1import {template} from 'chalk-template'; 2 3console.log(template('Today is {red hot}'));
1import {templateStderr} from 'chalk-template'; 2 3console.error(templateStderr('Today is {red hot}'));
The makeTemplate
and makeTaggedTemplate
functions are exported so functions can be created using a custom Chalk instance.
Note: When using a function created with makeTemplate
, it's up to you to properly escape the input.
1import {Chalk} from 'chalk' 2import {makeTemplate, makeTaggedTemplate} from 'chalk-template'; 3 4const template = makeTemplate(new Chalk({level: 3})); 5const chalkTemplate = makeTaggedTemplate(new Chalk({level: 3})); 6 7console.log(template('Today is {red hot}')); 8console.log(chalkTemplate`Today is {red hot}`);
No vulnerabilities found.
Reason
security policy file detected
Details
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 7/21 approved changesets -- score normalized to 3
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
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 2024-12-16
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