chalk-template 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +12 -0
- package/index.js +1 -1
- package/package.json +3 -2
- package/readme.md +10 -0
package/index.d.ts
CHANGED
@@ -21,3 +21,15 @@ log(chalk.red.bgBlack(chalkTemplate`2 + 3 = {bold ${2 + 3}}`));
|
|
21
21
|
```
|
22
22
|
*/
|
23
23
|
export default function chalkTemplate(text: TemplateStringsArray, ...placeholders: unknown[]): string;
|
24
|
+
|
25
|
+
/**
|
26
|
+
Terminal string styling. It is preferred that you use the template tag (default export) but this function is useful if you'd like to wrap the color template function.
|
27
|
+
|
28
|
+
@example
|
29
|
+
```
|
30
|
+
import { template } from 'chalk-template';
|
31
|
+
|
32
|
+
log(template('Today is {red hot}')
|
33
|
+
```
|
34
|
+
*/
|
35
|
+
export function template(text: string): string;
|
package/index.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "chalk-template",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.4.0",
|
4
4
|
"description": "Terminal string styling with tagged template literals",
|
5
5
|
"license": "MIT",
|
6
6
|
"repository": "chalk/chalk-template",
|
@@ -11,7 +11,7 @@
|
|
11
11
|
"node": ">=12"
|
12
12
|
},
|
13
13
|
"scripts": {
|
14
|
-
"test": "xo && ava test/index.js && cross-env FORCE_COLOR=0 ava test/no-color.js && cross-env FORCE_COLOR=3 TERM=dumb ava test/full-color.js && tsd"
|
14
|
+
"test": "xo && ava test/index.js && cross-env FORCE_COLOR=0 ava test/no-color.js && cross-env FORCE_COLOR=3 TERM=dumb ava test/full-color.js && cross-env FORCE_COLOR=3 TERM=dumb ava test/template.js && tsd"
|
15
15
|
},
|
16
16
|
"files": [
|
17
17
|
"index.js",
|
@@ -49,6 +49,7 @@
|
|
49
49
|
"ava": "^3.15.0",
|
50
50
|
"cross-env": "^7.0.3",
|
51
51
|
"tsd": "^0.18.0",
|
52
|
+
"typescript": "^4.6.2",
|
52
53
|
"xo": "^0.45.0"
|
53
54
|
}
|
54
55
|
}
|
package/readme.md
CHANGED
@@ -58,6 +58,16 @@ Note that function styles (`rgb()`, etc.) may not contain spaces between paramet
|
|
58
58
|
|
59
59
|
All interpolated values (`` chalkTemplate`${foo}` ``) are converted to strings via the `.toString()` method. All curly braces (`{` and `}`) in interpolated value strings are escaped.
|
60
60
|
|
61
|
+
## Template function
|
62
|
+
|
63
|
+
You may also use the template function as an alternative to the tagged template function.
|
64
|
+
|
65
|
+
```js
|
66
|
+
import {template} from 'chalk-template';
|
67
|
+
|
68
|
+
console.log(template('Today is {red hot}'));
|
69
|
+
```
|
70
|
+
|
61
71
|
## Related
|
62
72
|
|
63
73
|
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
|