Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

svgicons2svgfont

Package Overview
Dependencies
13
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.2 to 3.0.3

src/filesorter.js

21

package.json
{
"name": "svgicons2svgfont",
"version": "3.0.2",
"version": "3.0.3",
"description": "Read a set of SVG icons and ouput a SVG font",

@@ -23,13 +23,18 @@ "homepage": "https://github.com/nfroidure/svgicons2svgfont",

],
"engines": {
"node": ">= 0.10.0"
},
"dependencies": {
"commander": "^2.8.1",
"readable-stream": "^2.0.0",
"sax": "1.1.x",
"svg-pathdata": "1.0.0"
"readable-stream": "^2.0.1",
"sax": "^1.1.1",
"string.fromcodepoint": "^0.2.1",
"string.prototype.codepointat": "^0.2.0",
"svg-pathdata": "^1.0.1"
},
"devDependencies": {
"coveralls": "~2.11.2",
"istanbul": "~0.3.15",
"mocha": "~2.2.5",
"mocha-lcov-reporter": "0.0.2",
"coveralls": "^2.11.2",
"istanbul": "^0.3.16",
"mocha": "^2.2.5",
"mocha-lcov-reporter": "^0.0.2",
"streamtest": "^1.2.1"

@@ -36,0 +41,0 @@ },

var fs = require('fs');
var util = require('util');
var path = require('path');
var fileSorter = require('./filesorter');
var Readable = require('stream').Readable;
require('string.prototype.codepointat');
// Inherit of duplex stream

@@ -31,25 +34,3 @@ util.inherits(SVGIconsDirStream, Readable);

// Ensure prefixed files come first
files = files.slice(0).sort(function(fileA, fileB) {
var result = 0;
if((/(^|\/)(?:((?:u[0-9a-f]{4,6},?)+)\-)(.+)\.svg$/i).test(fileA)) {
if((/(^|\/)(?:((?:u[0-9a-f]{4,6},?)+)\-)(.+)\.svg$/i).test(fileB)) {
if(fileA < fileB) {
result = -1;
} else {
result = 1;
}
} else {
result = -1;
}
} else {
if((/(^|\/)(?:((?:u[0-9a-f]{4,6},?)+)\-)(.+)\.svg$/i).test(fileB)) {
result = 1;
} else if(fileA < fileB) {
result = -1;
} else {
result = 1;
}
}
return result;
});
files = files.slice(0).sort(fileSorter);
files.forEach(function(file) {

@@ -63,3 +44,3 @@ getMetadata((dir ? dir + '/' : '') + file, function(err, metadata) {

options.log('Saved codepoint: ' +
'u' + metadata.unicode[0].charCodeAt(0).toString(16).toUpperCase() +
'u' + metadata.unicode[0].codePointAt(0).toString(16).toUpperCase() +
' for the glyph "' + metadata.name + '"');

@@ -66,0 +47,0 @@ }

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

require('string.prototype.codepointat');
// Transform helpers (will move elsewhere later)

@@ -416,3 +418,3 @@ function parseTransforms(value) {

unicode="' + unicode.split('').map(function(char) {
return '&#x' + char.charCodeAt(0).toString(16).toUpperCase() + ';';
return '&#x' + char.codePointAt(0).toString(16).toUpperCase() + ';';
}).join('') + '"\n\

@@ -419,0 +421,0 @@ horiz-adv-x="' + glyph.width + '" d="' + d +'" />\n');

var path = require('path');
var fs = require('fs');
require('string.fromcodepoint');
require('string.prototype.codepointat');
function getMetadataService(options) {

@@ -31,3 +34,3 @@ var usedUnicodes = [];

return match.split('u').map(function(code) {
return String.fromCharCode(parseInt(code, 16));
return String.fromCodePoint(parseInt(code, 16));
}).join('');

@@ -42,3 +45,3 @@ });

do {
metadata.unicode[0] = String.fromCharCode(options.startUnicode++);
metadata.unicode[0] = String.fromCodePoint(options.startUnicode++);
} while(-1 !== usedUnicodes.indexOf(metadata.unicode[0]));

@@ -49,3 +52,3 @@ usedUnicodes.push(metadata.unicode[0]);

metadata.path = path.dirname(file) + '/' +
'u' + metadata.unicode[0].charCodeAt(0).toString(16).toUpperCase() +
'u' + metadata.unicode[0].codePointAt(0).toString(16).toUpperCase() +
'-' + basename;

@@ -56,3 +59,3 @@ fs.rename(file, metadata.path,

return cb(new Error('Could not save codepoint: ' +
'u' + metadata.unicode[0].charCodeAt(0).toString(16).toUpperCase() +
'u' + metadata.unicode[0].codePointAt(0).toString(16).toUpperCase() +
' for ' + basename));

@@ -59,0 +62,0 @@ }

@@ -5,2 +5,4 @@ var metadata = require(__dirname + '/../src/metadata.js');

require('string.fromcodepoint');
describe('Metadata service', function() {

@@ -106,2 +108,17 @@

it("should work for higher codepoint codes", function(done) {
var metadataService = metadata();
metadataService('/var/plop/u1F63A-hello.svg', function(err, infos) {
assert(!err);
assert.deepEqual(infos, {
path: '/var/plop/u1F63A-hello.svg',
name: 'hello',
unicode: [String.fromCodePoint(0x1f63a)],
renamed: false
}
);
done();
});
});
it("should work for ligature codes", function(done) {

@@ -140,4 +157,29 @@ var metadataService = metadata();

it("should not set the same codepoint twice", function(done) {
var metadataService = metadata();
metadataService('/var/plop/uEA01-hello.svg', function(err, infos) {
assert(!err);
assert.deepEqual(infos, {
path: '/var/plop/uEA01-hello.svg',
name: 'hello',
unicode: [String.fromCharCode(0xEA01)],
renamed: false
}
);
metadataService('/var/plop/plop.svg', function(err, infos) {
assert(!err);
assert.deepEqual(infos, {
path: '/var/plop/plop.svg',
name: 'plop',
unicode: [String.fromCharCode(0xEA02)],
renamed: false
}
);
done();
});
});
});
});
});
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc