Socket
Socket
Sign inDemoInstall

svgicons2svgfont

Package Overview
Dependencies
27
Maintainers
4
Versions
56
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 9.0.4 to 9.1.0

20

.readme/contents.md

@@ -178,2 +178,18 @@ svgicons2svgfont is a simple tool to merge

#### options.metadataProvider
Type: `(file: string, cb: (err: any, metadata: {file: string, name: string, unicode: string[], renamed: boolean}) => void`
Default value: `require('svgicons2svgfont/src/metadata')(options)`
A function which determines the metadata for an icon. It takes a parameter `file` with an icon svg and should return
icon metadata (asynchronously) via the callback function. You can use this function to provide custom logic for svg to
codepoint mapping.
| | |
| ------------------ | ---------------------------------------------------------------------------------------- |
| `metadata.path` | The path to the icon file. (The original `file` param is the file was not moved.) |
| `metadata.name` | The name of the icon |
| `metadata.unicode` | The unicode codepoints corresponding to this glyph. Each should be a 1-codepoint string. |
| `metadata.renamed` | Wether the original file was moved (e.g. to prefix it with its unicode codepoint) |
#### options.log

@@ -217,6 +233,6 @@ Type: `Function`

[![NPM](https://nodei.co/npm/svgicons2svgfont.png?downloads=true&stars=true)](https://nodei.co/npm/svgicon2svgfont/)
[![NPM](https://nodei.co/npm-dl/svgicons2svgfont.png)](https://nodei.co/npm/svgicon2svgfont/)
[![NPM](https://nodei.co/npm/svgicons2svgfont.png?downloads=true&stars=true)](https://nodei.co/npm/svgicons2svgfont/)
[![NPM](https://nodei.co/npm-dl/svgicons2svgfont.png)](https://nodei.co/npm/svgicons2svgfont/)
## Contributing
Feel free to push your code if you agree with publishing under the MIT license.

6

bin/svgicons2svgfont.js

@@ -10,3 +10,3 @@ #! /usr/bin/env node

const SVGIcons2SVGFont = require('../src/index.js');
const SVGIcons2SVGFontStream = require('../src/index.js');
const SVGIconsDirStream = require('../src/iconsdir.js');

@@ -69,3 +69,3 @@

const files = [].concat(...program.args.map(file => glob.sync(file)));
const files = program.args.flatMap(file => glob.sync(file));

@@ -78,3 +78,3 @@ new SVGIconsDirStream(files, {

.pipe(
new SVGIcons2SVGFont({
new SVGIcons2SVGFontStream({
fontName: program.fontname,

@@ -81,0 +81,0 @@ fontId: program.fontId,

@@ -1,3 +0,3 @@

<a name="9.0.4"></a>
## [9.0.4](https://github.com/nfroidure/svgicons2svgfont/compare/v9.0.3...v9.0.4) (2018-11-20)
<a name="9.1.0"></a>
# [9.1.0](https://github.com/nfroidure/svgicons2svgfont/compare/v9.0.3...v9.1.0) (2019-06-01)

@@ -10,3 +10,8 @@

### Features
* Add options.metadataProvider option + API doc ([3343d33](https://github.com/nfroidure/svgicons2svgfont/commit/3343d33))
<a name="9.0.3"></a>

@@ -13,0 +18,0 @@ ## [9.0.3](https://github.com/nfroidure/svgicons2svgfont/compare/v9.0.2...v9.0.3) (2018-06-02)

{
"name": "svgicons2svgfont",
"version": "9.0.4",
"version": "9.1.0",
"description": "Read a set of SVG icons and ouput a SVG font",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/nfroidure/svgicons2svgfont",

@@ -194,2 +194,18 @@ <!--

#### options.metadataProvider
Type: `(file: string, cb: (err: any, metadata: {file: string, name: string, unicode: string[], renamed: boolean}) => void`
Default value: `require('svgicons2svgfont/src/metadata')(options)`
A function which determines the metadata for an icon. It takes a parameter `file` with an icon svg and should return
icon metadata (asynchronously) via the callback function. You can use this function to provide custom logic for svg to
codepoint mapping.
| | |
| ------------------ | ---------------------------------------------------------------------------------------- |
| `metadata.path` | The path to the icon file. (The original `file` param is the file was not moved.) |
| `metadata.name` | The name of the icon |
| `metadata.unicode` | The unicode codepoints corresponding to this glyph. Each should be a 1-codepoint string. |
| `metadata.renamed` | Wether the original file was moved (e.g. to prefix it with its unicode codepoint) |
#### options.log

@@ -233,4 +249,4 @@ Type: `Function`

[![NPM](https://nodei.co/npm/svgicons2svgfont.png?downloads=true&stars=true)](https://nodei.co/npm/svgicon2svgfont/)
[![NPM](https://nodei.co/npm-dl/svgicons2svgfont.png)](https://nodei.co/npm/svgicon2svgfont/)
[![NPM](https://nodei.co/npm/svgicons2svgfont.png?downloads=true&stars=true)](https://nodei.co/npm/svgicons2svgfont/)
[![NPM](https://nodei.co/npm-dl/svgicons2svgfont.png)](https://nodei.co/npm/svgicons2svgfont/)

@@ -237,0 +253,0 @@ ## Contributing

@@ -7,30 +7,16 @@ /* eslint-disable complexity */

function fileSorter(fileA, fileB) {
let result = 0;
const hasUnicodeA = testExpression.test(fileA);
const hasUnicodeB = testExpression.test(fileB);
if (testExpression.test(fileA)) {
if (testExpression.test(fileB)) {
// Compare filenames without their .svg extension
if (
fileA.substring(0, fileA.length - 4) <
fileB.substring(0, fileB.length - 4)
) {
result = -1;
} else {
result = 1;
}
} else {
result = -1;
}
} else if (testExpression.test(fileB)) {
result = 1;
} else if (
fileA.substring(0, fileA.length - 4) < fileB.substring(0, fileB.length - 4)
) {
result = -1;
if (hasUnicodeA == hasUnicodeB) {
// just compare alphabetically
const fileA_ = fileA.substr(0, fileA.lastIndexOf('.'));
const fileB_ = fileB.substr(0, fileB.lastIndexOf('.'));
return fileA_ < fileB_ ? -1 : 1;
} else {
result = 1;
// map true to 0, because we want it to be first
return (hasUnicodeA ? 0 : 1) - (hasUnicodeB ? 0 : 1);
}
return result;
}
module.exports = fileSorter;

@@ -16,3 +16,3 @@ /* eslint-disable prefer-template,no-confusing-arrow */

super({ objectMode: true });
this.getMetadata = initMetadataService(options);
this.getMetadata = options.metadataProvider || initMetadataService(options);
this.gotFilesInfos = false;

@@ -19,0 +19,0 @@ this.dir = dir;

@@ -10,7 +10,6 @@ /* eslint-disable prefer-template,newline-per-chained-call,complexity */

function getMetadataService(options) {
function getMetadataService(options = {}) {
let usedUnicodes = [];
// Default options
options = options || {};
options.prependUnicode = !!options.prependUnicode;

@@ -60,7 +59,7 @@ options.startUnicode =

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

@@ -67,0 +66,0 @@ if (options.prependUnicode) {

Sorry, the diff of this file is not supported yet

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