Fast handcraft svg badge generator library . Used on badgen.net.
 
 
Go to file
Amio fdb64c2618 2.4.4 2018-08-30 16:06:52 +08:00
bench chore: update bench 2018-08-24 12:40:11 +08:00
lib fix: sanitize text strings 2018-08-30 16:04:44 +08:00
preview fix: sanitize text strings 2018-08-30 16:04:44 +08:00
tap-snapshots fix: sanitize text strings 2018-08-30 16:04:44 +08:00
test fix: sanitize text strings 2018-08-30 16:04:44 +08:00
.gitignore Add test coverage report 2018-07-18 14:11:11 +08:00
.npmignore Update .npmignore 2018-07-19 14:21:31 +08:00
.travis.yml Revert "Add codecov report to travis.yml" 2018-07-18 15:18:35 +08:00
LICENSE.md chore: add license and improve readme 2018-08-08 22:05:01 +02:00
README.md chore: add black example (#15) 2018-08-24 22:02:08 +08:00
package-lock.json 2.4.4 2018-08-30 16:06:52 +08:00
package.json 2.4.4 2018-08-30 16:06:52 +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,PHN2Zy...', // Use icon, optional
  iconWidth: 13     // Use this if icon is not square.
})

Available color names:

Benchmarks

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

[classic] style, long params x 1,317,650 ops/sec ±0.44% (88 runs sampled)
[classic] style, full params x 1,711,139 ops/sec ±0.51% (94 runs sampled)
[classic] style, with emoji  x 1,308,026 ops/sec ±1.94% (88 runs sampled)
[classic] style, with icon   x 1,476,024 ops/sec ±0.48% (92 runs sampled)
   [flat] style, long params x 663,252 ops/sec ±0.65% (93 runs sampled)
   [flat] style, full params x 739,821 ops/sec ±1.56% (94 runs sampled)
   [flat] style, with emoji  x 674,228 ops/sec ±3.05% (88 runs sampled)
   [flat] style, with icon   x 764,540 ops/sec ±2.58% (88 runs sampled)