https://github.com/sdgluck/carbonate
:art: colourful sprintf
https://github.com/sdgluck/carbonate
colours javascript-library sprintf
Last synced: about 1 month ago
JSON representation
:art: colourful sprintf
- Host: GitHub
- URL: https://github.com/sdgluck/carbonate
- Owner: sdgluck
- License: mit
- Created: 2017-04-26T16:13:05.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-06T12:53:47.000Z (over 8 years ago)
- Last Synced: 2025-08-16T09:54:48.443Z (about 2 months ago)
- Topics: colours, javascript-library, sprintf
- Language: JavaScript
- Homepage:
- Size: 22.5 KB
- Stars: 23
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# carbonate
> 🎨 colourful sprintf
Made with ❤ at [@outlandish](http://www.twitter.com/outlandish)
![]()
[](http://standardjs.com/)```js
sprintf('I do not like %s(green) and ham.', 'green eggs')
sprintf('I do not like them, %s(yellow.bold.underline).', 'Sam-I-am')
```🍪 Give some colour to your sprintf strings with [chalk](https://github.com/chalk/chalk).
✨ Written for ES2015 environments.
👉 Use your preferred bundler and transpiler as required.## Install
```sh
npm install --save carbonate
``````sh
yarn add carbonate
```## Import
```js
// ES2015
import sprintf from 'carbonate'
``````js
// CommonJS
var sprintf = require('carbonate')
```## Usage
### `sprintf(str[, ...values]) : String`
Format a string with values.
- __str__ {String} The string to format
- [__values__] {Any} Values to interpolateReturns a string.
Examples:
```js
// simple colour
sprintf('I do not like %s(green) and ham.', 'green eggs')// use chalk's chaining for bold, etc.
sprintf('I do not like them, %s(yellow.bold.underline).', 'Sam-I-am')
```### `sprintf.log(str[, ...values])`
Format and console.log a string.
- __str__ {String} The string to format
- [__values__] {Any} Values to interpolate### Type specifiers
All specifiers in [`sprintf.js`](https://github.com/alexei/sprintf.js) are available.
## Contributing
All pull requests and issues welcome!
If you're not sure how, check out the [great video tutorials on egghead.io](http://bit.ly/2aVzthz)!
## License
MIT © [Sam Gluck](github.com/sdgluck)