Fast handcraft svg badge generator library . Used on badgen.net.
 
 
Go to file
dependabot[bot] 22aa7c1691 build(deps-dev): bump tap from 12.1.3 to 12.4.0 (#36)
Bumps [tap](https://github.com/tapjs/node-tap) from 12.1.3 to 12.4.0.
- [Release notes](https://github.com/tapjs/node-tap/releases)
- [Changelog](https://github.com/tapjs/node-tap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tapjs/node-tap/compare/v12.1.3...v12.4.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-01-24 12:47:17 +08:00
bench chore: update bench 2018-08-24 12:40:11 +08:00
lib add: support bare badge (without label & icon) 2019-01-02 20:39:28 +08:00
preview update preview 2019-01-02 20:49:23 +08:00
tap-snapshots update tests 2019-01-02 20:45:37 +08:00
test update tests 2019-01-02 20:45:37 +08:00
.gitignore chore: publish bundled badgen.min.js only 2018-09-07 23:05:09 +08:00
.npmignore chore: seprate browser & node release 2018-09-08 12:19:11 +08:00
.travis.yml chore: publish bundled badgen.min.js only 2018-09-07 23:05:09 +08:00
LICENSE.md chore: add license and improve readme 2018-08-08 22:05:01 +02:00
README.md docs: add gradient-badge link 2018-09-12 11:22:02 +08:00
package-lock.json build(deps-dev): bump tap from 12.1.3 to 12.4.0 (#36) 2019-01-24 12:47:17 +08:00
package.json v2.6.0 2019-01-02 20:50:46 +08:00

README.md

badgen

npm version Coverage Status Install size License

Fast handcraft svg badge generator. Used on badgen.net.

  • 🌀 Zero dependency
  • Fast by design (see benchmarks)
  • 👯 Pure JavaScript, running in node & browser

Usage

npm install badgen

const badgen = require('badgen')

const svgString = badgen({
  subject: 'npm',   // <Text>
  status: 'v1.2.3', // <Text>
  color: 'blue',    // <Color RGB> or <Color Name>, optional
  style: 'flat',    // 'flat' or undefined, optional
  icon: 'data:image/svg+xml;base64,...', // Use icon, optional
  iconWidth: 13     // Use this if icon is not square.
})

Available color names:

In browser

<script src="https://cdn.jsdelivr.net/npm/badgen/badgen.min.js"></script>
<script>
  var svgString = badgen({ /*...*/ })
</script>

Benchmarks

npm run bench on my MacBook Pro (Early 2015), 2.7G i5, with Node.js 10.9.0:

[classic] style, long params x 784,111 ops/sec ±1.53% (89 runs sampled)
[classic] style, full params x 1,096,667 ops/sec ±1.37% (90 runs sampled)
[classic] style, with emoji  x 1,086,230 ops/sec ±1.85% (92 runs sampled)
[classic] style, with icon   x 941,914 ops/sec ±0.41% (93 runs sampled)
   [flat] style, long params x 546,447 ops/sec ±0.52% (91 runs sampled)
   [flat] style, full params x 612,977 ops/sec ±1.08% (94 runs sampled)
   [flat] style, with emoji  x 620,193 ops/sec ±0.95% (92 runs sampled)
   [flat] style, with icon   x 566,848 ops/sec ±0.84% (93 runs sampled)

See Also