{"id":18465,"library":"kld-path-parser","title":"kld-path-parser","description":"An event-driven SVG path data parser for Node.js and browsers. Version 0.2.1 is the latest stable release (no cadence documented). It parses SVG path 'd' attribute strings and emits events for each command (moveto, lineto, curveto, arc, etc.) via a handler interface. Unlike a full SVG renderer, it focuses solely on parsing, making it lightweight for path analysis, manipulation, or conversion. Supports ES modules, CommonJS, and UMD bundles. Minimal dependencies; compatible with Node >= 10.15.3.","status":"active","version":"0.2.1","language":"javascript","source_language":"en","source_url":"git://github.com/thelonious/kld-path-parser","tags":["javascript","paths","parser","SVG"],"install":[{"cmd":"npm install kld-path-parser","lang":"bash","label":"npm"},{"cmd":"yarn add kld-path-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add kld-path-parser","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export not available; must use named import. ES module syntax works in Node (v13+) and bundlers.","wrong":"import PathParser from 'kld-path-parser'","symbol":"PathParser","correct":"import { PathParser } from 'kld-path-parser'"},{"note":"CommonJS require works but prefer ESM. SampleHandler logs parsed commands.","wrong":"const SampleHandler = require('kld-path-parser').SampleHandler","symbol":"SampleHandler","correct":"import { SampleHandler } from 'kld-path-parser'"},{"note":"CommonJS destructuring required. Returns an object with named exports.","wrong":"const PathParser = require('kld-path-parser')","symbol":"PathParser","correct":"const { PathParser } = require('kld-path-parser')"}],"quickstart":{"code":"import { PathParser, SampleHandler } from 'kld-path-parser';\n\nconst parser = new PathParser();\nconst handler = new SampleHandler();\nconst pathData = 'M40,70 Q50,150 90,90 T135,130 L160,70 C180,180 280,55 280,140 S400,110 290,100';\n\nparser.setHandler(handler);\nparser.parseData(pathData);\n\nconsole.log(handler.logs.join('\\n'));\n// Expected output:\n// movetoAbs(40,70)\n// curvetoQuadraticAbs(50,150,90,90)\n// curvetoQuadraticSmoothAbs(135,130)\n// linetoAbs(160,70)\n// curvetoCubicAbs(180,180,280,55,280,140)\n// curvetoCubicSmoothAbs(400,110,290,100)","lang":"javascript","description":"Parses an SVG path string and prints each command using the SampleHandler logging handler."},"warnings":[{"fix":"Update to named imports: import { PathParser } from 'kld-path-parser'","message":"In v0.2.0, imports changed from default to named exports. Older code using 'import PathParser from ...' will break.","severity":"breaking","affected_versions":"<0.2.0"},{"fix":"Use npm install with version exactly as shown: '0.2.1' (no 'v').","message":"The version range uses a leading 'v' in the git tag but npm version is just numbers. Ensure you use 'npm install kld-path-parser@0.2.1' not 'v0.2.1'.","severity":"deprecated","affected_versions":"all"},{"fix":"Call setHandler and parseData without await; they are synchronous.","message":"Parser methods (setHandler, parseData) do not return a promise; they execute synchronously. Do not await them.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use exact camelCase names from the handler method list.","message":"Handler methods must be exactly named as listed in the documentation (e.g., 'movetoAbs', not 'moveToAbs'). Case-sensitive.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use `import { PathParser } from 'kld-path-parser'`","cause":"Wrong import style: default import instead of named import in versions >=0.2.0.","error":"TypeError: PathParser is not a constructor"},{"fix":"Run `npm install kld-path-parser`. If using bundler, ensure it handles node_modules.","cause":"Package not installed or bundler misconfigured for ESM.","error":"Could not resolve 'kld-path-parser'"},{"fix":"Run `npm install kld-path-parser` and import from installed package.","cause":"Missing install or incorrect path in Node.js.","error":"Cannot find module 'kld-path-parser'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}