{"metapak":{"data":{"files":"'src/**/*.ts'","testsFiles":"'src/**/*.test.ts'","distFiles":"'dist/**/*.js'","ignore":["dist"],"bundleFiles":["dist","src"]},"configs":["main","readme","eslint","tsesm","jest","jsdocs","ghactions","coveralls"]},"name":"svg-pathdata","version":"9.0.0","description":"Manipulate SVG path data (path[d] attribute content) simply and efficiently.","type":"module","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"rimraf 'dist' && tsc --outDir dist","changelog":"conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md","cli":"env NODE_ENV=${NODE_ENV:-cli}","commitlint":"commitlint","cover":"node --run jest -- --coverage","doc":"echo \"# API\" > API.md; jsdoc2md 'dist/**/*.js' >> API.md && git add API.md","format":"node --run prettier","jest":"NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest","lint":"eslint 'src/**/*.ts'","metapak":"metapak","precommit":"node --run test && node --run lint && node --run metapak -- -s && node --run build && node --run doc","prettier":"prettier --write 'src/**/*.ts'","preversion":"node --run test && node --run lint && node --run build && node --run doc && node --run metapak -- -s","rebuild":"swc ./src -s -d dist -C jsc.target=es2022","test":"node --run jest","version":"node --run changelog"},"repository":{"type":"git","url":"git+https://github.com/nfroidure/svg-pathdata.git"},"keywords":["svg","path","data","parser","encoder","transformer","reader","writer","stream","typescript"],"author":{"name":"Nicolas Froidure","email":"nicolas.froidure@insertafter.com","url":"https://insertafter.com/en/index.html"},"contributors":[{"name":"Anders Kaseorg","email":"andersk@mit.edu"}],"license":"MIT","bugs":{"url":"https://github.com/nfroidure/SVGPathData/issues"},"engines":{"node":">=24.14.0"},"devDependencies":{"@commitlint/cli":"^20.5.0","@commitlint/config-conventional":"^20.5.0","@eslint/js":"^10.0.1","@swc/cli":"^0.8.0","@swc/core":"^1.15.21","@swc/jest":"^0.2.39","conventional-changelog":"^7.2.0","eslint":"^10.1.0","eslint-config-prettier":"^10.1.8","eslint-plugin-jest":"^29.15.1","eslint-plugin-prettier":"^5.5.5","jest":"^30.3.0","jsdoc-to-markdown":"^9.1.3","metapak":"^7.0.0","metapak-nfroidure":"22.0.1","prettier":"^3.8.1","rimraf":"^6.1.3","typescript":"^6.0.2","typescript-eslint":"^8.57.2"},"funding":{"type":"individual","url":"https://github.com/sponsors/nfroidure"},"config":{},"prettier":{"semi":true,"printWidth":80,"singleQuote":true,"trailingComma":"all","proseWrap":"always"},"jest":{"coverageReporters":["lcov"],"testPathIgnorePatterns":["/node_modules/"],"roots":["<rootDir>/src"],"transform":{"^.+\\.tsx?$":["@swc/jest",{}]},"testEnvironment":"node","moduleNameMapper":{"(.+)\\.js":"$1"},"extensionsToTreatAsEsm":[".ts"]},"jsarch":{"parserOptions":{"plugins":["typescript"]}},"overrides":{"typescript-eslint":{"typescript":"^6"},"@typescript-eslint/eslint-plugin":{"typescript":"^6"},"@typescript-eslint/parser":{"typescript":"^6"}},"gitHead":"c90936bfcb601c5a9c6d6fa655adc04bcad0b2e8","_id":"svg-pathdata@9.0.0","homepage":"https://github.com/nfroidure/svg-pathdata#readme","_nodeVersion":"24.14.0","_npmVersion":"11.9.0","dist":{"integrity":"sha512-h9FuqmNsgDKq2hQBqTMOWjZwqdZOnWijZmcg6FL4iSmH6VvRnobhHrBQSdOiP0W9nwgv0qiW5vQ3//Arrmp19g==","shasum":"8a067c72ffef4645cea7a1de948c5061ebc9175e","tarball":"http://registry-npm.ywwl.com/svg-pathdata/download/svg-pathdata-9.0.0.tgz","fileCount":176,"unpackedSize":686330,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIAVGzZwTrEB413IFVENfdZJZt9Tvg/mVOUdCTXehHvMTAiEA62glNrp6O65lN7sjvFXo7qve9m4jHlRc2niC5ZitvU4="}],"size":120775,"noattachment":false,"key":"/svg-pathdata/-/svg-pathdata-9.0.0.tgz"},"_npmUser":{"name":"nfroidure","email":"nicolas.froidure@insertafter.com"},"directories":{},"maintainers":[{"name":"nfroidure","email":"nicolas.froidure@insertafter.com"},{"name":"pioug","email":"gilles.piou@gmail.com"},{"name":"huerlisi","email":"simon.huerlimann@cyt.ch"},{"name":"narida","email":"adrianleonhard@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/svg-pathdata_9.0.0_1774619611036_0.8839919923568318"},"_hasShrinkwrap":false,"readme":"[//]: # ( )\n[//]: # (This file is automatically generated by a `metapak`)\n[//]: # (module. Do not change it  except between the)\n[//]: # (`content:start/end` flags, your changes would)\n[//]: # (be overridden.)\n[//]: # ( )\n# svg-pathdata\n> Manipulate SVG path data (path[d] attribute content) simply and efficiently.\n\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/nfroidure/svg-pathdata/blob/main/LICENSE)\n[![Coverage Status](https://coveralls.io/repos/github/nfroidure/svg-pathdata/badge.svg?branch=main)](https://coveralls.io/github/nfroidure/svg-pathdata?branch=main)\n\n\n[//]: # (::contents:start)\n\n## Usage\n\nInstall the module:\n\n```sh\nnpm install --save svg-pathdata\n```\n\nThen in your JavaScript files:\n\n```js\nimport {\n  SVGPathData,\n  SVGPathDataTransformer,\n  SVGPathDataEncoder,\n  SVGPathDataParser,\n} from 'svg-pathdata';\n```\n\n## Reading PathData\n\n```js\nconst pathData = new SVGPathData(`\n  M 10 10\n  H 60\n  V 60\n  L 10 60\n  Z`);\n\nconsole.log(pathData.commands);\n\n// [  {type: SVGPathData.MOVE_TO,       relative: false,  x: 10,  y: 10},\n//    {type: SVGPathData.HORIZ_LINE_TO, relative: false,  x: 60},\n//    {type: SVGPathData.VERT_LINE_TO,  relative: false,          y: 60},\n//    {type: SVGPathData.LINE_TO,       relative: false,  x: 10,  y: 60},\n//    {type: SVGPathData.CLOSE_PATH}]\n```\n\n## Reading PathData in chunks\n\n```js\nconst parser = new SVGPathDataParser();\n\nparser.parse('   '); // returns []\nparser.parse('M 10'); // returns []\nparser.parse(' 10'); // returns [{type: SVGPathData.MOVE_TO, relative: false, x: 10, y: 10 }]\n\nparser.write('H 60'); // returns [{type: SVGPathData.HORIZ_LINE_TO, relative: false, x: 60 }]\n\nparser.write('V'); // returns []\nparser.write('60'); // returns [{type: SVGPathData.VERT_LINE_TO, relative: false, y: 60 }]\n\nparser.write('L 10 60 \\n  Z');\n// returns [\n//   {type: SVGPathData.LINE_TO, relative: false, x: 10, y: 60 },\n//   {type: SVGPathData.CLOSE_PATH }]\n\nparser.finish(); // tell parser there is no more data: will throw if there are unfinished commands.\n```\n\n## Outputting PathData\n\n```js\nconst pathData = new SVGPathData(`\n  M 10 10\n  H 60\n  V 60\n  L 10 60\n  Z`);\n// returns \"M10 10H60V60L10 60Z\"\n\nencodeSVGPath({ type: SVGPathData.MOVE_TO, relative: false, x: 10, y: 10 });\n// returns \"M10 10\"\n\nencodeSVGPath({ type: SVGPathData.HORIZ_LINE_TO, relative: false, x: 60 });\n// returns \"H60\"\n\nencodeSVGPath([\n  { type: SVGPathData.VERT_LINE_TO, relative: false, y: 60 },\n  { type: SVGPathData.LINE_TO, relative: false, x: 10, y: 60 },\n  { type: SVGPathData.CLOSE_PATH },\n]);\n// returns \"V60L10 60Z\"\n```\n\n## Transforming PathData\n\nThis library can perform transformations on SVG paths. Here is\n[an example of that kind of use](https://github.com/nfroidure/svgicons2svgfont/blob/aa6df0211419e9d61c417c63bcc353f0cb2ea0c8/src/index.js#L192).\n\n### Transforming entire paths\n\n```js\nnew SVGPathData(`\n   m 10,10\n   h 60\n   v 60\n   l 10,60\n   z`)\n  .toAbs()\n  .encode();\n// return s\"M10,10 H70 V70 L80,130 Z\"\n```\n\n### Transforming partial data\n\nHere, we take SVGPathData from stdin and output it transformed to stdout.\n\n```js\nconst transformingParser = new SVGPathDataParser().toAbs().scale(2, 2);\ntransformingParser.parse('m 0 0'); // returns [{ type: SVGPathData.MOVE_TO,       relative: false, x: 0, y: 0 }]\ntransformingParser.parse('l 2 3'); // returns [{ type: SVGPathData.LINE_TO,       relative: false, x: 4, y: 6 }]\n```\n\n## Supported transformations\n\nYou can find all supported transformations in\n[src/SVGPathDataTransformer.ts](https://github.com/nfroidure/SVGPathData/blob/master/src/SVGPathDataTransformer.ts#L47).\nAdditionally, you can create your own by writing a function with the following\nsignature:\n\n```js\ntype TransformFunction = (command: SVGCommand) => SVGCommand | SVGCommand[];\n\nfunction SET_X_TO(xValue = 10) {\n  return function(command) {\n    command.x = xValue; // transform command objects and return them\n    return command;\n  };\n};\n\n// Synchronous usage\nnew SVGPathData('...')\n  .transform(SET_X_TO(25))\n  .encode();\n\n// Chunk usage\nnew SVGPathDataParser().transform(SET_X_TO(25));\n```\n\n## Contributing\n\nClone this project, run:\n\n```sh\nnpm install; npm test\n```\n\n[//]: # (::contents:end)\n\n# API\n## Functions\n\n<dl>\n<dt><a href=\"#annotateArcCommand\">annotateArcCommand()</a></dt>\n<dd><p><a href=\"https://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes\">https://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes</a>\nFixes rX and rY.\nEnsures lArcFlag and sweepFlag are 0 or 1\nAdds center coordinates: command.cX, command.cY (relative or absolute, depending on command.relative)\nAdds start and end arc parameters (in degrees): command.phi1, command.phi2; phi1 &lt; phi2 iff. c.sweepFlag == true</p>\n</dd>\n<dt><a href=\"#intersectionUnitCircleLine\">intersectionUnitCircleLine()</a></dt>\n<dd><p>Solves a quadratic system of equations of the form\n     a * x + b * y = c\n     x² + y² = 1\nThis can be understood as the intersection of the unit circle with a line.\n     =&gt; y = (c - a x) / b\n     =&gt; x² + (c - a x)² / b² = 1\n     =&gt; x² b² + c² - 2 c a x + a² x² = b²\n     =&gt; (a² + b²) x² - 2 a c x + (c² - b²) = 0</p>\n</dd>\n<dt><a href=\"#arePointsCollinear\">arePointsCollinear(p1, p2, p3)</a> ⇒</dt>\n<dd><p>Determines if three points are collinear (lie on the same straight line)\nand the middle point is on the line segment between the first and third points</p>\n</dd>\n<dt><a href=\"#createEllipse\">createEllipse()</a></dt>\n<dd><p>Creates an ellipse path centered at (cx,cy) with radii rx and ry</p>\n</dd>\n<dt><a href=\"#createRect\">createRect()</a></dt>\n<dd><p>Creates a rectangle path with optional rounded corners</p>\n</dd>\n<dt><a href=\"#createPolyline\">createPolyline()</a></dt>\n<dd><p>Creates a polyline from an array of coordinates [x1,y1,x2,y2,...]</p>\n</dd>\n<dt><a href=\"#createPolygon\">createPolygon()</a></dt>\n<dd><p>Creates a closed polygon from an array of coordinates</p>\n</dd>\n<dt><a href=\"#REMOVE_COLLINEAR\">REMOVE_COLLINEAR(commands)</a> ⇒</dt>\n<dd><p>Process a path and remove collinear points</p>\n</dd>\n<dt><a href=\"#REVERSE_PATH\">REVERSE_PATH(commands, preserveSubpathOrder)</a> ⇒</dt>\n<dd><p>Reverses the order of path commands to go from end to start\nIMPORTANT: This function expects absolute commands as input.\nIt doesn&#39;t convert relative to absolute - use SVGPathDataTransformer.TO_ABS() first if needed.</p>\n</dd>\n</dl>\n\n<a name=\"annotateArcCommand\"></a>\n\n## annotateArcCommand()\nhttps://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes\nFixes rX and rY.\nEnsures lArcFlag and sweepFlag are 0 or 1\nAdds center coordinates: command.cX, command.cY (relative or absolute, depending on command.relative)\nAdds start and end arc parameters (in degrees): command.phi1, command.phi2; phi1 < phi2 iff. c.sweepFlag == true\n\n**Kind**: global function  \n<a name=\"intersectionUnitCircleLine\"></a>\n\n## intersectionUnitCircleLine()\nSolves a quadratic system of equations of the form\n     a * x + b * y = c\n     x² + y² = 1\nThis can be understood as the intersection of the unit circle with a line.\n     => y = (c - a x) / b\n     => x² + (c - a x)² / b² = 1\n     => x² b² + c² - 2 c a x + a² x² = b²\n     => (a² + b²) x² - 2 a c x + (c² - b²) = 0\n\n**Kind**: global function  \n<a name=\"arePointsCollinear\"></a>\n\n## arePointsCollinear(p1, p2, p3) ⇒\nDetermines if three points are collinear (lie on the same straight line)\nand the middle point is on the line segment between the first and third points\n\n**Kind**: global function  \n**Returns**: true if the points are collinear and p2 is on the segment p1-p3  \n\n| Param | Description |\n| --- | --- |\n| p1 | First point [x, y] |\n| p2 | Middle point that might be removed |\n| p3 | Last point [x, y] |\n\n<a name=\"createEllipse\"></a>\n\n## createEllipse()\nCreates an ellipse path centered at (cx,cy) with radii rx and ry\n\n**Kind**: global function  \n<a name=\"createRect\"></a>\n\n## createRect()\nCreates a rectangle path with optional rounded corners\n\n**Kind**: global function  \n<a name=\"createPolyline\"></a>\n\n## createPolyline()\nCreates a polyline from an array of coordinates [x1,y1,x2,y2,...]\n\n**Kind**: global function  \n<a name=\"createPolygon\"></a>\n\n## createPolygon()\nCreates a closed polygon from an array of coordinates\n\n**Kind**: global function  \n<a name=\"REMOVE_COLLINEAR\"></a>\n\n## REMOVE\\_COLLINEAR(commands) ⇒\nProcess a path and remove collinear points\n\n**Kind**: global function  \n**Returns**: New array with collinear points removed  \n\n| Param | Description |\n| --- | --- |\n| commands | Array of SVG path commands to process (must be absolute) |\n\n<a name=\"REVERSE_PATH\"></a>\n\n## REVERSE\\_PATH(commands, preserveSubpathOrder) ⇒\nReverses the order of path commands to go from end to start\nIMPORTANT: This function expects absolute commands as input.\nIt doesn't convert relative to absolute - use SVGPathDataTransformer.TO_ABS() first if needed.\n\n**Kind**: global function  \n**Returns**: New SVG commands in reverse order with absolute coordinates  \n\n| Param | Description |\n| --- | --- |\n| commands | SVG path commands in absolute form to reverse |\n| preserveSubpathOrder | If true, keeps subpaths in their original order |\n\n\n# Authors\n- [Nicolas Froidure](https://insertafter.com/en/index.html)\n- [Anders Kaseorg](mailto:andersk@mit.edu)\n\n# License\n[MIT](https://github.com/nfroidure/svg-pathdata/blob/main/LICENSE)\n","publish_time":1774619611198,"_cnpm_publish_time":1774619611198,"dist-tags":{"latest":"9.0.0"}}