Socket
Socket
Sign inDemoInstall

badgen

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

badgen - npm Package Compare versions

Comparing version 1.1.4 to 1.2.0

23

lib/index.js
const calcWidth = require('./calc-text-width.js').Verdana11
const colorPresets = require('./color-presets.js')
module.exports = function ({subject, status, color}) {
module.exports = function ({subject, status, color}, opts = {}) {
color = colorPresets[color] || color || colorPresets['blue']

@@ -11,2 +11,21 @@

const { style } = opts
if (style === 'flat') {
return `
<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="20">
<g>
<rect width="${sbRectWidth}" height="20" fill="#555"/>
<rect x="${sbRectWidth}" width="${stRectWidth}" height="20" fill="#${color}"/>
</g>
<g fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="11">
<text x="7" y="14.8" fill="#000" opacity="0.1">${subject}</text>
<text x="6" y="13.8">${subject}</text>
<text x="${sbRectWidth + 5.5}" y="14.8" fill="#000" opacity="0.1">${status}</text>
<text x="${sbRectWidth + 4.5}" y="13.8">${status}</text>
</g>
</svg>
`
}
return `

@@ -18,3 +37,3 @@ <svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="20">

</linearGradient>
<mask id="m"><rect width="${width}" height="20" rx="3" fill="#FFF"/></mask>
<mask id="m"><rect width="${width}" height="20" rx="3" fill="#FFF"/></mask>
<g mask="url(#m)">

@@ -21,0 +40,0 @@ <rect width="${sbRectWidth}" height="20" fill="#555"/>

12

package.json
{
"name": "badgen",
"version": "1.1.4",
"description": "Hand-crafted badge generator.",
"version": "1.2.0",
"description": "Fast svg badge generator.",
"author": "Amio <amio.cn@gmail.com>",

@@ -11,7 +11,5 @@ "license": "ISC",

"bench": "node bench/index.js",
"preview": "node test/serve-preview.js",
"test": "tap test/*.spec.js --reporter spec",
"start": "node service.js",
"predeploy": "now rm badgen --safe -y -T badgen",
"deploy": "now -T badgen --public && now -T badgen alias"
"preview": "node preview/serve.js",
"pretest": "npm run lint",
"test": "tap test/*.spec.js --reporter spec"
},

@@ -18,0 +16,0 @@ "devDependencies": {

@@ -16,2 +16,3 @@ # badgen [![npm-version][npm-badge]][npm-link] [![install size][pp-badge]][pp-link]

const badgen = require('badgen')
const options = { style: 'flat' }

@@ -21,4 +22,4 @@ const svgString = badgen({

status: 'v1.2.3', // <Text>
color: 'blue' // <Color RGB> or <Color Name>
})
color: 'blue' // <Color RGB> or <Color Name>, optional
}, options) // options is optional
```

@@ -47,4 +48,6 @@

```bash
generate by long params x 1,046,942 ops/sec ±0.61% (93 runs sampled)
generate by full params x 1,266,881 ops/sec ±0.76% (91 runs sampled)
[classic] style, long params x 1,071,083 ops/sec ±0.82% (89 runs sampled)
[classic] style, full params x 1,332,181 ops/sec ±0.80% (92 runs sampled)
[flat] style, long params x 1,145,825 ops/sec ±0.73% (94 runs sampled)
[flat] style, full params x 1,416,453 ops/sec ±0.69% (91 runs sampled)
```

@@ -51,0 +54,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc