Fast handcraft svg badge generator library . Used on badgen.net.
 
 
Go to file
amio 0a2dd9d00e refactor: js => ts 2019-10-03 12:10:43 +08:00
.github Add workflow nodejs.yml 2019-08-24 13:47:07 +08:00
bench refactor: js => ts 2019-10-03 12:10:43 +08:00
preview feat: support `scale` arg (badgen/badgen.net#309) 2019-10-03 10:47:22 +08:00
src refactor: js => ts 2019-10-03 12:10:43 +08:00
tap-snapshots subject => label 2019-07-06 15:34:14 +08:00
test Use src for testing 2019-07-06 15:51:18 +08:00
.gitignore use ncc & test on dist 2019-01-29 20:53:41 +08:00
.npmignore use ncc & test on dist 2019-01-29 20:53:41 +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: update bench results (before migration to ts) 2019-10-03 10:58:00 +08:00
package-lock.json refactor: js => ts 2019-10-03 12:10:43 +08:00
package.json refactor: js => ts 2019-10-03 12:10:43 +08:00
tsconfig.json refactor: js => ts 2019-10-03 12:10:43 +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')

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

Available color names:

In browser

<script src="https://wzrd.in/standalone/badgen@latest"></script>
<script>
  var svgString = badgen({ /*...*/ })
</script>

Benchmarks

npm run bench on iMac 5K (Late 2014), 3.5G i5, with Node.js 12.11.0:

[classic] style, long params x 980,342 ops/sec ±0.36% (95 runs sampled)
[classic] style, full params x 1,282,650 ops/sec ±0.54% (93 runs sampled)
[classic] style, with emoji  x 1,286,513 ops/sec ±0.30% (92 runs sampled)
[classic] style, with icon   x 1,127,749 ops/sec ±0.38% (92 runs sampled)
   [flat] style, long params x 780,018 ops/sec ±0.32% (93 runs sampled)
   [flat] style, full params x 1,015,617 ops/sec ±0.27% (96 runs sampled)
   [flat] style, with emoji  x 1,033,564 ops/sec ±0.51% (95 runs sampled)
   [flat] style, with icon   x 988,562 ops/sec ±0.33% (96 runs sampled)

See Also