{"id":15999,"library":"d-path-parser","title":"SVG Path D Attribute Parser","description":"d-path-parser is a JavaScript library designed to parse the 'd' attribute of SVG `<path>` elements. Its current and only stable version is 1.0.0, released in 2016. The package is lightweight (under 1KB minified and gzipped) and engineered for performance, distinguishing itself from alternatives like `svg-path-parser` by being significantly smaller and faster (6-10x faster depending on input length) while maintaining 100% test coverage. It provides a structured breakdown of SVG path commands, facilitating easier debugging, reading, and manipulation of complex path data. The library supports CommonJS, AMD, and exposes a global function if no module loader is detected. Due to its last update being in 2016, the project is considered abandoned.","status":"abandoned","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/MaxArt2501/d-path-parser","tags":["javascript","svg","parser","path","drawing"],"install":[{"cmd":"npm install d-path-parser","lang":"bash","label":"npm"},{"cmd":"yarn add d-path-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add d-path-parser","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only, published in 2016. Modern ESM imports will require a build step, a dynamic import, or a CommonJS compatibility wrapper, which might lead to `ERR_REQUIRE_ESM` errors in pure ESM environments.","wrong":"import parse from 'd-path-parser';","symbol":"parse","correct":"const parse = require('d-path-parser');"}],"quickstart":{"code":"const parse = require('d-path-parser');\n\nconst path1 = \"M0,0 l10,10 A14.142 14.142 0 1 1 10,-10 Z\";\nconst commands1 = parse(path1);\nconsole.log('Parsed Path 1:', JSON.stringify(commands1, null, 2));\n\nconst path2 = \"m10 10c10-10 20-10 30 0\";\nconst commands2 = parse(path2);\nconsole.log('\\nParsed Path 2:', JSON.stringify(commands2, null, 2));\n\n/* Example of output for path1:\n[\n  {\n    \"code\": \"M\",\n    \"relative\": false,\n    \"end\": {\n      \"x\": 0,\n      \"y\": 0\n    }\n  },\n  {\n    \"code\": \"l\",\n    \"relative\": true,\n    \"end\": {\n      \"x\": 10,\n      \"y\": 10\n    }\n  },\n  {\n    \"code\": \"A\",\n    \"relative\": false,\n    \"radii\": {\n      \"x\": 14.142,\n      \"y\": 14.142\n    },\n    \"rotation\": 0,\n    \"large\": true,\n    \"clockwise\": true,\n    \"end\": {\n      \"x\": 10,\n      \"y\": -10\n    }\n  },\n  {\n    \"code\": \"Z\"\n  }\n]*/","lang":"javascript","description":"This example demonstrates how to import and use the `d-path-parser` library to parse an SVG path string, showing the resulting array of command objects."},"warnings":[{"fix":"Always validate or sanitize SVG path strings independently if strict adherence to the SVG specification is required for your application.","message":"The parser does not enforce SVG path strictness. It will not throw an error if the input string is not a complete SVG `d` attribute or if the first command is not a `moveTo`. This allows parsing of partial path segments.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider migrating to a more actively maintained SVG path parsing library if long-term support, security updates, or modern JavaScript feature compatibility are crucial for your project. Alternatives like `path-data-parser` (ESM native) or `svg-path-parser` (though noted as larger/slower by `d-path-parser`'s author) exist.","message":"The project is abandoned, with the last release (v1.0.0) and code update occurring in 2016. This means there will be no further updates, bug fixes, or compatibility improvements for newer JavaScript versions or browser environments.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"In CommonJS environments, use `const parse = require('d-path-parser');`. In ESM environments, you might need to use a dynamic import (`const parse = await import('d-path-parser').then(mod => mod.default);`) or configure your build system (e.g., Webpack, Rollup, Parcel) to handle CJS interoperability.","message":"The package is a CommonJS module and does not natively support ES Modules (ESM) `import` syntax. Attempting to use `import parse from 'd-path-parser'` directly in a pure ESM Node.js environment or a modern browser build without proper transpilation may lead to errors.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"This specific error likely occurs if a build process attempts to treat `d-path-parser` (a CJS module) as an ESM module when being `require`d by another CJS module, or if a newer Node.js environment tries to `require` it in an ESM context. Ensure your `package.json` `type` field is correctly set, or use dynamic `import()` for CJS modules in ESM contexts: `const parse = await import('d-path-parser').then(mod => mod.default);`","cause":"Attempting to `require()` an ES Module or using `import` for a CommonJS module in an incompatible environment or build configuration.","error":"Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: ...d-path-parser/index.js require() of ES modules is not supported."},{"fix":"Verify that `const parse = require('d-path-parser');` is used in a CommonJS context. If using a bundler, ensure it correctly handles CommonJS modules. Reinstall the package (`npm install d-path-parser`) to rule out corruption.","cause":"The imported `parse` symbol is not recognized as a function, often due to incorrect import syntax or a broken package installation.","error":"TypeError: parse is not a function"}],"ecosystem":"npm"}