Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

svgfont2svgicons

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svgfont2svgicons - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

CHANGELOG.md

50

bin/svgfont2svgicons.js
#! /usr/bin/env node
var svgfont2svgicons = require(__dirname + '/../src/index.js')
, Fs = require('fs')
, path = require('path')
;
import { SVGFont2SVGIconsStream } from '../dist/index.js';
import { createReadStream, createWriteStream } from 'node:fs';
import { readFile } from 'node:fs/promises';
import { join } from 'node:path';
import { argv, exit } from 'node:process';
import program from 'commander';
var fontStream = Fs.createReadStream(process.argv[2]);
var iconProvider = svgfont2svgicons();
var unamedIconCount = 0;
program
.version('2.0.0')
.usage('[options] <font file> <destination path>')
.option('--namemap <json file>', 'get unicode to name map from json file', '')
.parse(argv);
if (program.args.length < 2) {
console.log('Usage: node svgfont2svgicons', program.usage());
exit(1);
}
const srcFile = program.args[0],
destPath = program.args[1],
options = {};
if (program.namemap)
options.nameMap = JSON.parse(await readFile(program.namemap));
const fontStream = createReadStream(srcFile);
const iconProvider = new SVGFont2SVGIconsStream(options);
fontStream.pipe(iconProvider);
iconProvider.on('readable', function() {
var glyph, steam, glyphPath;
while(null !== glyph) {
glyph = iconProvider.read();
if(glyph) {
glyphPath = path.join(process.argv[3], glyph.name + '.svg');
console.log('Saving glyph "' + glyph.name + '" to "' + glyphPath + '"');
glyph.stream.pipe(Fs.createWriteStream(glyphPath));
}
iconProvider.on('readable', function () {
let glyph;
while ((glyph = iconProvider.read()) !== null) {
const glyphName = glyph.metadata.name;
const glyphPath = join(destPath, glyphName + '.svg');
console.log('Saving glyph "' + glyphName + '" to "' + glyphPath + '"');
glyph.pipe(createWriteStream(glyphPath));
}
});
{
"metapak": {
"data": {
"files": "src/*.ts",
"testFiles": "tests/*.test.ts",
"bundleFiles": [
"dist",
"src",
"bin"
],
"ignore": [
"dist"
]
},
"configs": [
"main",
"readme",
"jest",
"eslint",
"tsesm",
"codeclimate",
"ghactions"
]
},
"name": "svgfont2svgicons",
"version": "2.0.0",
"version": "3.0.0",
"description": "Extract SVG icons from an SVG font",
"homepage": "https://github.com/nfroidure/svgfont2svgicons",
"main": "src/index.js",
"main": "dist/index.js",
"scripts": {
"test": "node_modules/mocha/bin/mocha tests/*.mocha.js",
"coveralls": "./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha --report lcovonly -- tests/*.mocha.js -R spec -t 5000 && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
"cover": "./node_modules/istanbul/lib/cli.js cover --report html ./node_modules/mocha/bin/_mocha -- tests/*.mocha.js -R spec -t 5000"
"build": "rimraf 'dist' && tsc --outDir dist",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md",
"cli": "env NODE_ENV=${NODE_ENV:-cli}",
"cover": "npm run jest -- --coverage",
"cz": "env NODE_ENV=${NODE_ENV:-cli} git cz",
"format": "npm run prettier",
"jest": "NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest",
"lint": "eslint src/*.ts",
"metapak": "metapak",
"precz": "npm t && npm run lint && npm run metapak -- -s && npm run build",
"prettier": "prettier --write src/*.ts",
"preversion": "npm t && npm run lint && npm run metapak -- -s && npm run build",
"rebuild": "swc ./src -s -d dist -C jsc.target=es2022",
"test": "npm run jest",
"type-check": "tsc --pretty --noEmit",
"version": "npm run changelog"
},

@@ -24,19 +60,34 @@ "repository": {

"dependencies": {
"sax": "1.1.x",
"svg-pathdata": "1.0.0",
"readable-stream": "^2.0.0",
"plexer": "0.0.3",
"streamqueue": "^1.1.0"
"commander": "^12.1.0",
"sax": "^1.4.1",
"streamqueue": "^2.0.0",
"svg-pathdata": "^7.0.0"
},
"devDependencies": {
"coveralls": "~2.11.2",
"istanbul": "~0.3.15",
"mocha": "~2.2.5",
"mocha-lcov-reporter": "0.0.2",
"streamtest": "^1.2.0",
"svgicons2svgfont": "^2.0.2"
"@eslint/js": "^9.7.0",
"@swc/cli": "^0.4.0",
"@swc/core": "^1.6.13",
"@swc/helpers": "^0.5.12",
"@swc/jest": "^0.2.36",
"commitizen": "^4.3.0",
"conventional-changelog-cli": "^5.0.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^9.7.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest": "^28.6.0",
"eslint-plugin-prettier": "^5.1.3",
"jest": "^29.7.0",
"metapak": "^6.0.1",
"metapak-nfroidure": "18.2.0",
"prettier": "^3.3.3",
"rimraf": "^6.0.1",
"streamtest": "^3.0.1",
"svgicons2svgfont": "^14.0.1",
"typescript": "^5.5.3",
"typescript-eslint": "^7.16.0"
},
"author": {
"name": "Nicolas Froidure",
"url": "http://www.insertafter.com/blog.html"
"email": "nicolas.froidure@insertafter.com",
"url": "https://insertafter.com/en/index.html"
},

@@ -52,6 +103,79 @@ "licenses": [

},
"preferGlobal": "true",
"bin": {
"svgfont2svgicons": "bin/svgfont2svgicons.js"
}
},
"contributors": [],
"license": "MIT",
"engines": {
"node": ">=20.11.1"
},
"files": [
"dist",
"src",
"bin",
"LICENSE",
"README.md",
"CHANGELOG.md"
],
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"greenkeeper": {
"ignore": [
"commitizen",
"cz-conventional-changelog",
"conventional-changelog-cli",
"jest",
"@swc/jest",
"eslint",
"prettier",
"eslint-config-prettier",
"eslint-plugin-prettier",
"typescript-eslint",
"typescript",
"rimraf",
"@swc/cli",
"@swc/core",
"@swc/helpers"
]
},
"jest": {
"coverageReporters": [
"lcov"
],
"testPathIgnorePatterns": [
"/node_modules/"
],
"roots": [
"<rootDir>/src"
],
"transform": {
"^.+\\.tsx?$": [
"@swc/jest",
{}
]
},
"testEnvironment": "node",
"moduleNameMapper": {
"(.+)\\.js": "$1"
},
"extensionsToTreatAsEsm": [
".ts"
],
"prettierPath": null
},
"overrides": {
"eslint": "^9.7.0"
},
"prettier": {
"semi": true,
"printWidth": 80,
"singleQuote": true,
"trailingComma": "all",
"proseWrap": "always"
},
"type": "module",
"types": "dist/index.d.ts"
}

@@ -0,15 +1,26 @@

[//]: # ( )
[//]: # (This file is automatically generated by a `metapak`)
[//]: # (module. Do not change it except between the)
[//]: # (`content:start/end` flags, your changes would)
[//]: # (be overridden.)
[//]: # ( )
# svgfont2svgicons
> svgfont2svgicons is a simple tool to explode a SVG font into multiple icons.
> Extract SVG icons from an SVG font
[![NPM version](https://badge.fury.io/js/svgfont2svgicons.png)](https://npmjs.org/package/svgfont2svgicons) [![Build status](https://secure.travis-ci.org/nfroidure/svgfont2svgicons.png)](https://travis-ci.org/nfroidure/svgfont2svgicons) [![Dependency Status](https://david-dm.org/nfroidure/svgfont2svgicons.png)](https://david-dm.org/nfroidure/svgfont2svgicons) [![devDependency Status](https://david-dm.org/nfroidure/svgfont2svgicons/dev-status.png)](https://david-dm.org/nfroidure/svgfont2svgicons#info=devDependencies) [![Coverage Status](https://coveralls.io/repos/nfroidure/svgfont2svgicons/badge.png?branch=master)](https://coveralls.io/r/nfroidure/svgfont2svgicons?branch=master) [![Code Climate](https://codeclimate.com/github/nfroidure/svgfont2svgicons.png)](https://codeclimate.com/github/nfroidure/svgfont2svgicons)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/nfroidure/svgfont2svgicons/blob/main/LICENSE)
## Usage
[//]: # (::contents:start)
## Usage
### In your scripts
```js
var svgfont2svgicons = require('svgfont2svgicons');
var fs = require('fs');
var fontStream = fs.createReadStream('myFont.svg');
var iconProvider = svgfont2svgicons(options);
import svgfont2svgicons from 'svgfont2svgicons';
import fs from 'node:fs';
const fontStream = fs.createReadStream('myFont.svg');
const iconProvider = svgfont2svgicons(options);
// Piping the font

@@ -20,4 +31,5 @@ fontStream.pipe(iconProvider);

iconProvider.on('readable', function() {
var icon;
do {
let icon;
do {
icon = iconProvider.read();

@@ -30,7 +42,7 @@ if(icon) {

}).once('end', function() {
console.log('No more icons !')
console.log('No more icons!')
});
```
## CLI interface
## CLI interface
```sh

@@ -45,9 +57,13 @@ svgfont2svgicons font/src/file.svg icons/dest/directory

## Stats
[![NPM](https://nodei.co/npm/svgfont2svgicons.png?downloads=true&stars=true)](https://nodei.co/npm/svgicon2svgfont/)
[![NPM](https://nodei.co/npm-dl/svgfont2svgicons.png)](https://nodei.co/npm/svgicon2svgfont/)
## Contributing
Feel free to pull your code if you agree with publishing under the MIT license.
[//]: # (::contents:end)
# Authors
- [Nicolas Froidure](https://insertafter.com/en/index.html)
# License
[MIT](https://github.com/nfroidure/svgfont2svgicons/blob/main/LICENSE)
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