Socket
Socket
Sign inDemoInstall

badge-up

Package Overview
Dependencies
Maintainers
5
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

badge-up - npm Package Compare versions

Comparing version 2.3.0 to 2.4.0

.editorconfig

5

index.js

@@ -41,4 +41,5 @@ /*

// Run the SVG through SVGO.
svgo.optimize(template(data), function (object) {
callback(null, object.data);
return svgo.optimize(template(data)).then(function (object) {
if (callback) callback(null, object.data);
return object.data;
});

@@ -45,0 +46,0 @@ };

36

package.json
{
"name": "badge-up",
"version": "2.3.0",
"version": "2.4.0",
"description": "A module that produces hot badges without the need of Cairo",
"main": "index.js",
"nyc": {
"reporter": [
"lcov",
"text"
]
},
"scripts": {
"lint": "jshint *.js test/*.js",
"test": "jenkins-mocha"
"test": "nyc --report-dir ./artifacts/coverage mocha --color true",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
},

@@ -16,3 +23,4 @@ "repository": {

"keywords": [
"badge"
"badge",
"yahoo"
],

@@ -28,2 +36,8 @@ "license": "BSD-3-Clause",

],
"release": {
"debug": false,
"verifyConditions": {
"path": "./node_modules/semantic-release/src/lib/plugin-noop.js"
}
},
"jshintConfig": {

@@ -33,12 +47,14 @@ "node": true

"devDependencies": {
"chai": "~1.9.1",
"jenkins-mocha": "^2.6.0",
"jshint": "^2.9.2",
"sinon": "~1.10.3"
"chai": "^4.2.0",
"coveralls": "^3.0.11",
"jshint": "^2.11.0",
"mocha": "^7.1.1",
"nyc": "^15.0.0",
"sinon": "^9.0.1"
},
"dependencies": {
"css-color-names": "~0.0.3",
"dot": "~1.0.2",
"svgo": "~0.4.5"
"css-color-names": "~1.0.1",
"dot": "^1.1.3",
"svgo": "^1.3.2"
}
}

@@ -5,2 +5,4 @@ # badge-up

[![downloads](https://img.shields.io/npm/dt/badge-up.svg?maxAge=2592000)](https://www.npmjs.com/package/badge-up)
[![build](https://cd.screwdriver.cd/pipelines/62/badge?maxAge=2592000)](https://cd.screwdriver.cd/pipelines/62)
[![coverage](https://coveralls.io/repos/github/yahoo/badge-up/badge.svg)](https://coveralls.io/github/yahoo/badge-up)

@@ -18,3 +20,3 @@ This is a simple library that generates SVG badges without Cairo.

```js
var badge = require('badge-up');
const badge = require('badge-up');
badge('batman', 'component', badge.colors.green, function (error, svg) {

@@ -30,3 +32,15 @@ // some callback

You can alternatively use the returned `Promise`:
```js
const badge = require('badge-up');
(async () => {
try {
const svg = await badge('batman', 'component', badge.colors.green);
} catch (error) {
//
}
}());
```
## V2 Usage

@@ -53,9 +67,9 @@

```js
var badge = require('badge-up');
var sections = [
'foo/far;fun',
[ 'bar\nbaz', 'orange'],
[ 'mork "mindy"', 'olive', 's{white}'],
[ '<∀>', 'moccasin']
];
const badge = require('badge-up');
const sections = [
'foo/far;fun',
[ 'bar\nbaz', 'orange'],
[ 'mork "mindy"', 'olive', 's{white}'],
[ '<∀>', 'moccasin']
];
badge.v2(sections, function (error, svg) {

@@ -68,2 +82,20 @@ // some callback

You can also use the returned `Promise`:
```js
const badge = require('badge-up');
const sections = [
'foo/far;fun',
[ 'bar\nbaz', 'orange'],
[ 'mork "mindy"', 'olive', 's{white}'],
[ '<∀>', 'moccasin']
];
(async () => {
try {
const svg = await badge.v2(sections);
} catch (error) {
//
}
}());
```

@@ -13,4 +13,10 @@ /*

SVGO = require('svgo'),
svgo = new SVGO(),
svgo = new SVGO({
plugins: [{
sortDefsChildren: false
}]
}),
TEMPLATE = dot.template(fs.readFileSync(path.join(__dirname, 'templates', 'v2.svg'), 'utf-8')),
COLOR_REGEX = /^[0-9a-f]{6}$/i,
STROKE_REGEX = /^s\{(.+?)\}$/i,
DEFAULT_COLOR_FIRST = '#696969', // dimgrey

@@ -30,3 +36,3 @@ DEFAULT_COLOR_REST = '#d3d3d3', // lightgrey

function getColorCode(input) {
if (input.match(/^[0-9a-f]{6}$/i)) {
if (COLOR_REGEX.test(input)) {
return '#' + input.toLowerCase();

@@ -64,9 +70,6 @@ }

section.forEach(function(attribute) {
// stroke attribute `s{color}` as CSS color or color code in hex
var strokeAttribute = attribute.match(/^s\{(.*?)\}/i);
if (strokeAttribute && strokeAttribute.length > 0) {
if (getColorCode(strokeAttribute[1])) {
sectionData.stroke = getColorCode(strokeAttribute[1]);
}
var strokeAttribute = STROKE_REGEX.exec(attribute);
if (strokeAttribute) {
sectionData.stroke = getColorCode(strokeAttribute[1]) || null;
}

@@ -106,4 +109,5 @@

var raw = TEMPLATE(sectionsToData(sections));
svgo.optimize(raw, function(optimized) {
callback(undefined, optimized.data);
return svgo.optimize(raw).then(function(optimized) {
if (callback) callback(undefined, optimized.data);
return optimized.data;
});

@@ -110,0 +114,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