Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
svg-parser
Advanced tools
The svg-parser npm package is a utility for parsing SVG (Scalable Vector Graphics) files into a JavaScript object representation. This can be useful for manipulating or analyzing SVG content programmatically.
Parsing SVG to JavaScript Object
This feature allows you to parse an SVG string into a JavaScript object. The resulting object can then be manipulated or analyzed as needed.
const { parse } = require('svg-parser');
const svg = '<svg><circle cx="50" cy="50" r="40" /></svg>';
const result = parse(svg);
console.log(result);
svgson is a library that converts SVG into a JSON object and vice versa. It offers more advanced features like transforming the SVG structure and manipulating attributes, making it more versatile compared to svg-parser.
SVGO (SVG Optimizer) is a tool for optimizing SVG files by removing unnecessary data. While it focuses on optimization rather than parsing, it can still be used to manipulate SVG content programmatically, offering a different set of functionalities compared to svg-parser.
xml2js is a library for converting XML to JavaScript objects and vice versa. Since SVG is XML-based, xml2js can be used to parse SVG files, although it is a more general-purpose XML parser and lacks SVG-specific features.
Take a string representing an SVG document or fragment, turn it into HAST JavaScript object.
npm install svg-parser
, or grab it from npmcdn.com/svg-parser.
import { parse } from 'svg-parser';
const parsed = parse( `
<svg viewBox='0 0 100 100'>
<!-- stuff goes here... -->
</svg>
` );
/*
{
type: 'root',
children: [
{
type: 'element',
tagName: 'svg',
properties: {
viewBox: '0 0 100 100'
},
children: [...]
}
]
}
*/
MIT
FAQs
Create a JSON-friendly object from an SVG string
The npm package svg-parser receives a total of 4,516,218 weekly downloads. As such, svg-parser popularity was classified as popular.
We found that svg-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.