Socket
Socket
Sign inDemoInstall

badgen

Package Overview
Dependencies
1
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.1 to 2.1.2

7

lib/calc-text-width.js

@@ -7,6 +7,5 @@ const widthsVerdana11 = require('./widths-verdana-11.json')

const widthTable = charWidthTable.map(w => Math.round(w * SCALE))
widthTable[64] = widthTable[64] + 4 // Slightly increase width of "@" by 0.4px
widthTable[64] = widthTable[64] + 6 // Slightly increase width of "@" by 0.6px
return function (text, astral) {
typeAssert(typeof text === 'string', 'Input must be string')
if (astral) text = text.match(astralRegex)

@@ -25,8 +24,4 @@

const typeAssert = (assertion, message) => {
if (!assertion) throw new TypeError(message)
}
module.exports = {
Verdana11: calcWidth(widthsVerdana11)
}

19

lib/index.js

@@ -5,6 +5,9 @@ const calcWidth = require('./calc-text-width.js').Verdana11

module.exports = function ({subject, status, color, style, emoji, icon}) {
typeAssert(typeof subject === 'string', '<subject> must be string')
typeAssert(typeof status === 'string', '<status> must be string')
color = colorPresets[color] || color || colorPresets['blue']
const stTextWidth = calcWidth(status, emoji)
const sbRectWidth = calcWidth(subject, emoji) + 10 + (icon ? 15 : 0)
const sbRectWidth = calcWidth(subject, emoji) + 10 + (icon ? 17 : 0)
const stRectWidth = stTextWidth + 10

@@ -21,4 +24,4 @@ const width = sbRectWidth + stRectWidth

<g fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="11">
<text x="${icon ? '22' : '6'}" y="14.8" fill="#000" opacity="0.1">${subject}</text>
<text x="${icon ? '21' : '5'}" y="13.8">${subject}</text>
<text x="${icon ? '23' : '6'}" y="14.8" fill="#000" opacity="0.1">${subject}</text>
<text x="${icon ? '22' : '5'}" y="13.8">${subject}</text>
<text x="${sbRectWidth + 5.5}" y="14.8" fill="#000" opacity="0.1" textLength="${stTextWidth}">${status}</text>

@@ -44,4 +47,4 @@ <text x="${sbRectWidth + 4.5}" y="13.8" textLength="${stTextWidth}">${status}</text>

<g fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="11">
<text x="${icon ? '22' : '6.2'}" y="14.8" fill="#000" opacity="0.25">${subject}</text>
<text x="${icon ? '21' : '5.2'}" y="13.8">${subject}</text>
<text x="${icon ? '23' : '6.2'}" y="14.8" fill="#000" opacity="0.25">${subject}</text>
<text x="${icon ? '22' : '5.2'}" y="13.8">${subject}</text>
<text x="${sbRectWidth + 5.5}" y="14.8" fill="#000" opacity="0.25" textLength="${stTextWidth}">${status}</text>

@@ -55,3 +58,7 @@ <text x="${sbRectWidth + 4.5}" y="13.8" textLength="${stTextWidth}">${status}</text>

function genIconMarkup (iconB64) {
return `<image x="4.5" y="3" width="14" height="14" xlink:href="${iconB64}"/>`
return `<image x="4.8" y="3" width="14" height="14" xlink:href="${iconB64}"/>`
}
function typeAssert (assertion, message) {
if (!assertion) throw new TypeError(message)
}
{
"name": "badgen",
"version": "2.1.1",
"version": "2.1.2",
"description": "Fast svg badge generator.",

@@ -5,0 +5,0 @@ "repository": "amio/badgen",

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc