
Research
/Security News
Contagious Interview Campaign Escalates With 67 Malicious npm Packages and New Malware Loader
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
d-path-parser
Advanced tools
JavaScript parser for SVG <path>
's d
attribute.
The syntax for the d
attribute is compact and expressive, but unfortunately it's also
dramatic to debug/maintain/read. This parser gives you a breakdown of the commands in the string, ready for you to read and
manipulate.
There's another library with the same purpose around, maintained by Hugh Kennedy.
Its main feature is that's generated from a formal grammar, so that's actually pretty neat. On the down size, there's its...
size, and the fact that it's quite slow compared to this one. We're talking about 11x the size minified, 3.5 the size minified
and gzipped (d-path-parser
is less than 1K), and 6x-10x slower depending on the input (the longer, the slower) and the environment.
One may argue that size and speed aren't usually important features, and they might be right. d-path-parser
also has 100%
test coverage, by the way.
Via npm
/yarn
:
npm install d-path-parser
yarn add d-path-parser
Via bower
;
bower install d-path-parser
As a CommonJS package:
const parse = require("d-path-parser");
const path = "M0,0 l10,10 A14.142 14.142 0 1 1 10,-10 Z";
const commands = parse(path);
This will yield the following result:
[{
code: "M",
relative: false,
end: { x: 0, y: 0 }
}, {
code: "l",
relative: true,
end: { x: 10, y: 10 }
}, {
code: "A",
relative: false,
radii: { x: 14.142, y: 14.142 },
rotation: 0,
large: true,
clockwise: true,
end: { x: 10, y: -10 }
}, {
code: "Z"
}]
The parser can also be loaded via AMD (define([ "d-path-parser", ... ], function(parse) { ... })
) and, if no module loader is
detected, a global function dPathParse
will be defined.
d-path-parser
does not assume the given string is the full path string of a d
attribute. In short, it won't throw if the
first command is not a moveTo
.
Mocha and Chai are used for tests. Just run npm test
(or mocha
if it's globally
installed).
MIT @ Massimo Artizzu 2016. See LICENSE.
FAQs
JavaScript parser for SVG path's d attribute
The npm package d-path-parser receives a total of 2,029 weekly downloads. As such, d-path-parser popularity was classified as popular.
We found that d-path-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.