Registry / serialization / kld-path-parser

kld-path-parser

JSON →
library0.2.1jsnpmunverified

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.

npm install kld-path-parser
INSTALL
IMPORT
SIG · KLD-PATH-PARSER
K
kld-path-parser
serializationjavascriptv0.2.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PathParser
import { PathParser } from 'kld-path-parser'
import PathParser from 'kld-path-parser'
Default export not available; must use named import. ES module syntax works in Node (v13+) and bundlers.
SampleHandler
import { SampleHandler } from 'kld-path-parser'
const SampleHandler = require('kld-path-parser').SampleHandler
CommonJS require works but prefer ESM. SampleHandler logs parsed commands.
PathParser
const { PathParser } = require('kld-path-parser')
const PathParser = require('kld-path-parser')
CommonJS destructuring required. Returns an object with named exports.

Parses an SVG path string and prints each command using the SampleHandler logging handler.

import { PathParser, SampleHandler } from 'kld-path-parser'; const parser = new PathParser(); const handler = new SampleHandler(); const pathData = 'M40,70 Q50,150 90,90 T135,130 L160,70 C180,180 280,55 280,140 S400,110 290,100'; parser.setHandler(handler); parser.parseData(pathData); console.log(handler.logs.join('\n')); // Expected output: // movetoAbs(40,70) // curvetoQuadraticAbs(50,150,90,90) // curvetoQuadraticSmoothAbs(135,130) // linetoAbs(160,70) // curvetoCubicAbs(180,180,280,55,280,140) // curvetoCubicSmoothAbs(400,110,290,100)
Debug
Known issues
breakingIn v0.2.0, imports changed from default to named exports. Older code using 'import PathParser from ...' will break.
fix
Update to named imports: import { PathParser } from 'kld-path-parser'
affects: <0.2.0
deprecatedThe 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'.
fix
Use npm install with version exactly as shown: '0.2.1' (no 'v').
affects: all
gotchaParser methods (setHandler, parseData) do not return a promise; they execute synchronously. Do not await them.
fix
Call setHandler and parseData without await; they are synchronous.
affects: >=0.0.0
gotchaHandler methods must be exactly named as listed in the documentation (e.g., 'movetoAbs', not 'moveToAbs'). Case-sensitive.
fix
Use exact camelCase names from the handler method list.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: PathParser is not a constructor
Wrong import style: default import instead of named import in versions >=0.2.0.
fix
Use `import { PathParser } from 'kld-path-parser'`
Could not resolve 'kld-path-parser'
Package not installed or bundler misconfigured for ESM.
fix
Run `npm install kld-path-parser`. If using bundler, ensure it handles node_modules.
Cannot find module 'kld-path-parser'
Missing install or incorrect path in Node.js.
fix
Run `npm install kld-path-parser` and import from installed package.
Upgrade
Version history
0.2.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
kld-path-parser — npm install kld-path-parser · libregistry