Installations
npm install ansi-styles-template
Releases
Unable to fetch releases
Developer
Developer Guide
Module System
CommonJS
Min. Node Version
>=6
Typescript Support
No
Node Version
6.8.0
NPM Version
3.10.8
Statistics
7 Commits
3 Watching
2 Branches
1 Contributors
Updated on 28 Dec 2017
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
28,227
Last day
80.6%
121
Compared to previous day
Last week
27.6%
467
Compared to previous week
Last month
87.2%
1,303
Compared to previous month
Last year
-68%
5,275
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Dev Dependencies
1
ansi-styles-template
Use ANSI styles in template notation
Installation
1npm install ansi-styles-template
Usage
Basic usage
1const {template} = require('ansi-styles-template'); 2 3const str = '{red}Bloody..{/red}'; 4 5console.log(template(str)); // -> "\u001b[31mBloody..\u001b[39m"
Built-in styles
The styles available as tags conform to ansy-styles.
Or dump replacementMap
in the following way, you can confirm more certainly.
1const {replacementMap} = require('ansi-styles-template'); 2 3console.log(replacementMap); 4// -> 5// Map { 6// 'reset' => { opener: '\u001b[0m', closer: '\u001b[0m' }, 7// 'bold' => { opener: '\u001b[1m', closer: '\u001b[22m' }, 8// 'dim' => { opener: '\u001b[2m', closer: '\u001b[22m' }, 9// 'italic' => { opener: '\u001b[3m', closer: '\u001b[23m' }, 10// 'underline' => { opener: '\u001b[4m', closer: '\u001b[24m' }, 11// 'inverse' => { opener: '\u001b[7m', closer: '\u001b[27m' }, 12// 'hidden' => { opener: '\u001b[8m', closer: '\u001b[28m' }, 13// 'strikethrough' => { opener: '\u001b[9m', closer: '\u001b[29m' }, 14// 'black' => { opener: '\u001b[30m', closer: '\u001b[39m' }, 15// 'red' => { opener: '\u001b[31m', closer: '\u001b[39m' }, 16// 'green' => { opener: '\u001b[32m', closer: '\u001b[39m' }, 17// 'yellow' => { opener: '\u001b[33m', closer: '\u001b[39m' }, 18// 'blue' => { opener: '\u001b[34m', closer: '\u001b[39m' }, 19// 'magenta' => { opener: '\u001b[35m', closer: '\u001b[39m' }, 20// 'cyan' => { opener: '\u001b[36m', closer: '\u001b[39m' }, 21// 'white' => { opener: '\u001b[37m', closer: '\u001b[39m' }, 22// 'gray' => { opener: '\u001b[90m', closer: '\u001b[39m' }, 23// 'redBright' => { opener: '\u001b[91m', closer: '\u001b[39m' }, 24// 'greenBright' => { opener: '\u001b[92m', closer: '\u001b[39m' }, 25// 'yellowBright' => { opener: '\u001b[93m', closer: '\u001b[39m' }, 26// 'blueBright' => { opener: '\u001b[94m', closer: '\u001b[39m' }, 27// 'magentaBright' => { opener: '\u001b[95m', closer: '\u001b[39m' }, 28// 'cyanBright' => { opener: '\u001b[96m', closer: '\u001b[39m' }, 29// 'whiteBright' => { opener: '\u001b[97m', closer: '\u001b[39m' }, 30// 'bgBlack' => { opener: '\u001b[40m', closer: '\u001b[49m' }, 31// 'bgRed' => { opener: '\u001b[41m', closer: '\u001b[49m' }, 32// 'bgGreen' => { opener: '\u001b[42m', closer: '\u001b[49m' }, 33// 'bgYellow' => { opener: '\u001b[43m', closer: '\u001b[49m' }, 34// 'bgBlue' => { opener: '\u001b[44m', closer: '\u001b[49m' }, 35// 'bgMagenta' => { opener: '\u001b[45m', closer: '\u001b[49m' }, 36// 'bgCyan' => { opener: '\u001b[46m', closer: '\u001b[49m' }, 37// 'bgWhite' => { opener: '\u001b[47m', closer: '\u001b[49m' }, 38// 'bgBlackBright' => { opener: '\u001b[100m', closer: '\u001b[49m' }, 39// 'bgRedBright' => { opener: '\u001b[101m', closer: '\u001b[49m' }, 40// 'bgGreenBright' => { opener: '\u001b[102m', closer: '\u001b[49m' }, 41// 'bgYellowBright' => { opener: '\u001b[103m', closer: '\u001b[49m' }, 42// 'bgBlueBright' => { opener: '\u001b[104m', closer: '\u001b[49m' }, 43// 'bgMagentaBright' => { opener: '\u001b[105m', closer: '\u001b[49m' }, 44// 'bgCyanBright' => { opener: '\u001b[106m', closer: '\u001b[49m' }, 45// 'bgWhiteBright' => { opener: '\u001b[107m', closer: '\u001b[49m' } }
API
template(str, options = {})
Arguments
str: string
- A string to be replaced
options.leftBrace: string
- Default:
"{"
- Default:
options.rightBrace: string
- Default:
"}"
- Default:
options.strict: boolean
- Default:
false
- Whether to throw an error if an unknown tag matches
- Default:
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 0/7 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
3
/10
Last Scanned on 2024-11-18
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