Registry / devops / pathinator

pathinator

JSON →
library0.4.3jsnpmunverified

Pathinator is an SVG path builder and minifier for Node.js and the browser. Version 0.4.3 provides a chainable API to programmatically construct SVG path data via commands like moveTo, lineTo, cubic/quadratic curves, and arc, then export to optimized path strings with optional compression. It also includes an optimizeSvgPaths function to batch-optimize all path and polygon/polyline data in an SVG string or DOM Document. The library is lightweight, has no dependencies, and works in both ESM and older JS environments. Compared to alternatives like svg.js or Snap.svg, Pathinator focuses specifically on path data manipulation and minification rather than full SVG rendering or DOM manipulation.

npm install pathinator
INSTALL
IMPORT
SIG · PATHINATOR
P
pathinator
devopsjavascriptv0.4.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

Path
import { Path } from 'pathinator'
const Path = require('pathinator').Path
ESM default. CommonJS require works if the environment supports it, but named import is preferred.
optimizeSvgPaths
import { optimizeSvgPaths } from 'pathinator'
import optimizeSvgPaths from 'pathinator'
This is a named export, not a default export.

Shows chainable path construction with Path class, export with compression, and batch optimization of SVG strings.

import { Path, optimizeSvgPaths } from 'pathinator'; const path = new Path() .move(50, 100) .line(100, 100) .line(200, 200) .close(); path.export({ compress: true }).then(console.log); // Output (compressed): M50 100H100L200 200Z optimizeSvgPaths('<svg><path d="M10 10 L 20 20"/></svg>', { compress: true }) .then(console.log); // Output: <svg><path d="M10 10L20 20"/></svg>
Debug
Known issues
gotchaThe optimizeSvgPaths function returns a Promise, not a synchronous result.
fix
Use await or .then() to handle the result.
affects: >=0.0.0
gotchaThe export() method on Path is async and returns a Promise< string >, even if called synchronously.
fix
Use await or .then() to get the exported path string.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: path.export is not a function
Calling path.export() on a string instead of a Path instance.
fix
Ensure you call export() on a Path object, e.g., new Path().move(10,10).export()
Upgrade
Version history
0.4.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
pathinator — npm install pathinator · libregistry