badgen

Fast handcraft svg badge generating library.

Github星跟蹤圖

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://bundle.run/badgen"></script>
<script>
  var svgString = badgen.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

主要指標

概覽
名稱與所有者badgen/badgen
主編程語言JavaScript
編程語言JavaScript (語言數: 2)
平台
許可證ISC License
所有者活动
創建於2018-06-23 12:03:51
推送於2023-10-17 17:12:40
最后一次提交2023-07-21 20:04:46
發布數46
最新版本名稱v3.2.3 (發布於 2023-07-21 20:04:46)
第一版名稱v0.1.0 (發布於 2018-06-23 00:38:10)
用户参与
星數542
關注者數5
派生數39
提交數309
已啟用問題?
問題數22
打開的問題數7
拉請求數50
打開的拉請求數1
關閉的拉請求數9
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?