2018-07-18 07:38:59 +00:00
|
|
|
# badgen
|
|
|
|
|
2018-07-19 07:23:26 +00:00
|
|
|
[![npm version][npm-badge]][npm-link]
|
2018-07-18 07:38:59 +00:00
|
|
|
[![install size][pp-badge]][pp-link]
|
2018-07-19 06:54:54 +00:00
|
|
|
[![Coverage Status][cr-badge]][cr-link]
|
2018-05-30 03:13:32 +00:00
|
|
|
|
2018-07-19 07:05:23 +00:00
|
|
|
Fast handcraft svg badge generator.
|
2018-05-30 03:13:32 +00:00
|
|
|
|
2018-07-19 06:54:54 +00:00
|
|
|
- 🌀 1 dependency ([unicode-astral-regex][uar-link])
|
|
|
|
- ⚡️ Fast by design (see [benchmarks](#benchmarks))
|
|
|
|
- 👯 Pure JavaScript, running in node & browser
|
2018-06-23 09:54:52 +00:00
|
|
|
|
2018-05-30 03:13:32 +00:00
|
|
|
## Usage
|
|
|
|
|
2018-06-26 06:57:57 +00:00
|
|
|
### npm package
|
2018-06-23 03:20:45 +00:00
|
|
|
|
|
|
|
`npm install badgen`
|
2018-05-30 03:13:32 +00:00
|
|
|
|
2018-06-23 03:20:45 +00:00
|
|
|
```javascript
|
|
|
|
const badgen = require('badgen')
|
2018-05-30 03:13:32 +00:00
|
|
|
|
2018-06-23 03:20:45 +00:00
|
|
|
const svgString = badgen({
|
2018-06-29 15:21:35 +00:00
|
|
|
subject: 'npm', // <Text>
|
|
|
|
status: 'v1.2.3', // <Text>
|
2018-07-20 08:30:13 +00:00
|
|
|
color: 'blue', // <Color RGB> or <Color Name>, optional
|
|
|
|
style: 'flat', // 'flat' or undefined, optional
|
|
|
|
emoji: true, // Support emoji in text, optional
|
2018-07-28 10:23:42 +00:00
|
|
|
icon: 'data:image/svg+xml;base64,PHN2Zy...', // Use icon, optional
|
|
|
|
iconWidth: 13 // Use this if icon is not square.
|
2018-07-16 13:58:23 +00:00
|
|
|
})
|
2018-06-23 03:20:45 +00:00
|
|
|
```
|
2018-06-22 17:20:48 +00:00
|
|
|
|
2018-06-29 15:21:35 +00:00
|
|
|
Available color names:
|
|
|
|
|
2018-07-27 06:45:25 +00:00
|
|
|
![](https://badgen.net/badge/color/blue/blue)
|
|
|
|
![](https://badgen.net/badge/color/cyan/cyan)
|
|
|
|
![](https://badgen.net/badge/color/green/green)
|
|
|
|
![](https://badgen.net/badge/color/yellow/yellow)
|
|
|
|
![](https://badgen.net/badge/color/orange/orange)
|
|
|
|
![](https://badgen.net/badge/color/red/red)
|
|
|
|
![](https://badgen.net/badge/color/pink/pink)
|
|
|
|
![](https://badgen.net/badge/color/purple/purple)
|
|
|
|
![](https://badgen.net/badge/color/grey/grey)
|
2018-06-29 15:21:35 +00:00
|
|
|
|
2018-07-27 06:45:25 +00:00
|
|
|
### Badge As A Service
|
2018-06-26 06:57:57 +00:00
|
|
|
|
2018-07-27 06:45:25 +00:00
|
|
|
https://badgen.net
|
2018-06-26 06:57:57 +00:00
|
|
|
|
2018-06-23 09:54:52 +00:00
|
|
|
## Benchmarks
|
|
|
|
|
2018-06-23 10:01:51 +00:00
|
|
|
`npm run bench` on my iMac5K(Late 2014), 3.5G i5, with Node.js 10.5.0:
|
2018-06-23 09:54:52 +00:00
|
|
|
|
|
|
|
```bash
|
2018-07-28 10:23:42 +00:00
|
|
|
[classic] style, long params x 742,904 ops/sec ±0.92% (88 runs sampled)
|
|
|
|
[classic] style, full params x 998,716 ops/sec ±0.78% (93 runs sampled)
|
|
|
|
[flat] style, long params x 618,005 ops/sec ±0.77% (92 runs sampled)
|
|
|
|
[flat] style, full params x 677,415 ops/sec ±0.67% (93 runs sampled)
|
|
|
|
[classic] style, with emoji x 502,203 ops/sec ±2.11% (91 runs sampled)
|
|
|
|
[classic] style, with icon x 844,518 ops/sec ±1.10% (94 runs sampled)
|
2018-06-23 09:54:52 +00:00
|
|
|
```
|
|
|
|
|
2018-06-22 17:20:48 +00:00
|
|
|
## License
|
|
|
|
|
2018-07-27 06:45:25 +00:00
|
|
|
![ISC](https://badgen.net/badge/license/ISC/blue)
|
2018-06-22 17:20:48 +00:00
|
|
|
|
2018-07-27 06:45:25 +00:00
|
|
|
[npm-badge]: https://badgen.net/npm/v/badgen
|
2018-06-22 17:20:48 +00:00
|
|
|
[npm-link]: https://www.npmjs.com/package/badgen
|
|
|
|
[pp-badge]: https://packagephobia.now.sh/badge?p=badgen
|
|
|
|
[pp-link]: https://packagephobia.now.sh/result?p=badgen
|
2018-07-18 07:38:59 +00:00
|
|
|
[cr-badge]: https://coveralls.io/repos/github/amio/badgen/badge.svg?branch=master
|
|
|
|
[cr-link]: https://coveralls.io/github/amio/badgen?branch=master
|
2018-07-19 06:54:54 +00:00
|
|
|
[uar-link]: https://www.npmjs.com/package/unicode-astral-regex
|