badgen
TypeScript icon, indicating that this package has built-in type declarations

3.2.3 • Public • Published

badgen

npm version Coverage Status Bundle size License

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

  • 🌀 Zero dependency
  • ⚡️ Fast by design (see benchmarks)
  • 👯‍ 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 'classic' (default: 'classic')
  icon: 'data:image/svg+xml;base64,...', // Use icon (default: undefined)
  iconWidth: 13,     // Set this if icon is not square (default: 13)
  scale: 1           // Set badge scale (default: 1)
})

Available color names:

In browser

<script src="https://unpkg.com/badgen"></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 985,898 ops/sec ±0.37% (94 runs sampled)
[classic] style, full params x 1,284,886 ops/sec ±0.42% (95 runs sampled)
[classic] style, with emoji  x 1,291,768 ops/sec ±0.28% (95 runs sampled)
[classic] style, with icon   x 1,177,120 ops/sec ±0.94% (95 runs sampled)
   [flat] style, long params x 780,504 ops/sec ±0.39% (94 runs sampled)
   [flat] style, full params x 1,012,111 ops/sec ±0.40% (97 runs sampled)
   [flat] style, with emoji  x 1,013,695 ops/sec ±0.91% (95 runs sampled)
   [flat] style, with icon   x 994,481 ops/sec ±0.30% (94 runs sampled)

See Also

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
3.2.37,282latest

Version History

VersionDownloads (Last 7 Days)Published
3.2.37,282
3.2.22,391
3.2.131
3.2.00
3.1.01
3.0.10
3.0.012
2.8.2668
2.8.10
2.8.00
2.7.10
2.7.00
2.6.00
2.5.00
2.4.51
2.4.40
2.4.30
2.4.20
2.4.10
2.4.00
2.3.10
2.3.02
2.2.30
2.2.20
2.2.11
2.2.00
2.1.40
2.1.30
2.1.20
2.1.10
2.1.00
2.0.00
1.2.01
1.1.40
1.1.30
1.1.20
1.1.10
1.1.00
1.0.11
1.0.01
0.3.00
0.2.21
0.2.10
0.2.00
0.1.00

Package Sidebar

Install

npm i badgen

Weekly Downloads

10,393

Version

3.2.3

License

MIT

Unpacked Size

90.5 kB

Total Files

11

Last publish

Collaborators

  • amio