{"_id":"path-data-parser","_rev":"3-e0a740f89cca4ba3d8663cfe5bb16699","name":"path-data-parser","dist-tags":{"latest":"0.1.0"},"versions":{"0.0.1":{"name":"path-data-parser","version":"0.0.1","description":"Yet another SVG path parser. This one's tiny","main":"lib/index.js","module":"lib/index.js","types":"lib/index.d.ts","scripts":{"build":"rm -rf lib && tsc","lint":"tslint -p tsconfig.json","test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/pshihn/path-data-parser.git"},"keywords":["SVG","PATH","SVGPATH","pathdata","parser"],"author":{"name":"Preet Shihn"},"license":"MIT","bugs":{"url":"https://github.com/pshihn/path-data-parser/issues"},"homepage":"https://github.com/pshihn/path-data-parser#readme","devDependencies":{"tslint":"^6.1.1","typescript":"^3.8.3"},"gitHead":"d79e7395a964d7798e0a7789a681bebefd43e32d","_id":"path-data-parser@0.0.1","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-HnasQcgdOop8oTltyohyP1CO38ma3X4Kv2+VqzohgO0SRUUTeyzHlM8PC4noqcEpyyD5nRfBBbubZpIHSzXojQ==","shasum":"e529279db466dce0bc49312c2081ec4b54a4176d","tarball":"https://registry.npmjs.org/path-data-parser/-/path-data-parser-0.0.1.tgz","fileCount":17,"unpackedSize":29717,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJej/iqCRA9TVsSAnZWagAAwZ4P/jNCqNah61eTwXt1/sQ0\nf/gu2nBTQ1li19U+DT+co6MUHZ9XD0uUvimTWsNwCM0eetRl4X4CczpVVZFz\nqC1BuIOiio1swoTD/v5OTWaejggG+di7HeIdguAFFcCJcOWySa3MfNSwrG/0\nFL9jIV24SycdLevOgsMKxR90iZ0tCoBlUZBDBqPGHrVA8WeRgH1c7j8uYAwI\nxm7eXSIkPnJ21JGzx4K5M1VdKWbDYJm5V7mELxj5wrBQ6gsIH3IOe6RX9e5U\nddyRbXnDNhSvZKllp3VfdBPYYlGNw8qoM7rUejNacMgTp8/HKKKTpEoyWQkI\n9ua46zZs6iyHK/viusqdGVXP7YwYMCtZQo+9Lw0LlSbi7pGsjizJKMEomTdD\nSLE93EOreZvMyKIpPIQQpFZqUJQU7DAx+e5WTIRn6piofq4Q9UF7HUnsxHZI\nKEJLKvhEnKtvpt8Cl+/5nKaw51NhHa6tFAvjWdX08bsIE+unGIZsPA+Mx2Dh\nF+YjBnsiuJniNCEz7Ly5vgW/5rNehHuPvRxKwtFgCV+CGV/IFoZ1HjZOG3KP\nFxWcQF+0VA4J+Rnj/uZQm8BgQxDrKivi3ZFnJ+RSNb1ayrD9MAwhVbrrw8z6\nTGZ2iq0vNh9Zuglv5/e8OC76fBYWIlCMCtu9MKeN/re2wJKzAOBVtbxOPfNl\nbHjo\r\n=uD2L\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDhU/+R82+yoxxZzdoHPL5rnnIO20gLGaXd1gaFUMzfNAIgah/atKZjs9/iWNd2Ategs4Mlyc++Mk6IfXTS24/T1LY="}]},"maintainers":[{"name":"shihn","email":"preetshihn@gmail.com"}],"_npmUser":{"name":"shihn","email":"preetshihn@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/path-data-parser_0.0.1_1586493609779_0.9018511332420274"},"_hasShrinkwrap":false},"0.0.2":{"name":"path-data-parser","version":"0.0.2","description":"Yet another SVG path parser. This one's tiny","main":"lib/index.js","module":"lib/index.js","types":"lib/index.d.ts","scripts":{"build":"rm -rf lib && tsc","lint":"tslint -p tsconfig.json","test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/pshihn/path-data-parser.git"},"keywords":["SVG","PATH","SVGPATH","pathdata","parser"],"author":{"name":"Preet Shihn"},"license":"MIT","bugs":{"url":"https://github.com/pshihn/path-data-parser/issues"},"homepage":"https://github.com/pshihn/path-data-parser#readme","devDependencies":{"tslint":"^6.1.1","typescript":"^3.8.3"},"gitHead":"3717bf009bba91795c7c76cfa4924c09558c3c76","_id":"path-data-parser@0.0.2","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-zuIKW5r6927H+yJAlUyD7pVcaazH/f2RJbfrE/3gtpQqy7sRyovyno+nlG8jpDFBtb6zwPm2Jp+6nxDDH2vd4A==","shasum":"fd8ed4785949ecc7f0c4b3aee2f82ddfea70d6fc","tarball":"https://registry.npmjs.org/path-data-parser/-/path-data-parser-0.0.2.tgz","fileCount":17,"unpackedSize":29744,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJej/kCCRA9TVsSAnZWagAAkqcP/3v8LbojF6M1L8z8OGc1\nTEaLdseEh96pwP+VPOjWhgQ94J1U2xOEbtdyEBZdO+Dw0qTBGEGsLyJzE7xY\nfSnB31dAxP5p6lrEaQvIB0IXLS3c3ojsebZeSHTcwmMhT5UpP5mopenTd6Oz\nEcJwGrOTQ7Q8+eSBsAFmckspohfq4xx82Vuu4i4v5k5i1xyyMOvTM/ACQ5Vc\nf1Q+qDHB9uucfdRhEJZYkp/7FOTwGqkATQJP1y5z2ZLek/4Mcg5l29b5LhkC\nZhg8Tym9XJLHMTkz3Fl2aqauy4BeZiN1K+v1Rrn++jfiao8Vkiu6zTPWidqz\nt7+gEn8OjdZ1x1STgcKewj7B2S/5svuzGu6QtdhlYhL89BJzryDxMhhniTVm\nbJsTKvDxNcpQtgjBADXeENcdHTF6+tICHzWUcgbTtJgmnC6QXFbLGIOwju/C\n3R5Kp0X7aD+6+gQR76jtm3B69+6TahfrK58LMzQwWopzrGH2gaYSIwyFJqhW\nTXT+yLOg5Pc6pAlX/4x5rzd1Wdy2YTNfMmJBI3o66D5uqcJ2OCVDlLUlHQR5\nOUDZdLl94aE/o5RC0TGDnDLoi6Dujct5/q8Cz/y1LGkdiJJvXdqqy0lmTLgO\nCNCD8u+qDSNKYQfbh922Bz4dTManc7hqLfeJB46QlEgGb8n8eqUzOkEaxva9\nlR+s\r\n=7/Sf\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID4k96DvclJbmUynINUBCQc4bMnBb+EBmLFJj39AoGDWAiEA/zXCrZ3BROGCG0F+Uuc8lGkd6wRKLuc0qyzlim+kOGs="}]},"maintainers":[{"name":"shihn","email":"preetshihn@gmail.com"}],"_npmUser":{"name":"shihn","email":"preetshihn@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/path-data-parser_0.0.2_1586493698029_0.46766404841078146"},"_hasShrinkwrap":false},"0.1.0":{"name":"path-data-parser","version":"0.1.0","description":"Yet another SVG path parser. This one's tiny","main":"lib/index.js","module":"lib/index.js","types":"lib/index.d.ts","scripts":{"build":"rm -rf lib && tsc","lint":"tslint -p tsconfig.json","test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/pshihn/path-data-parser.git"},"keywords":["svg path parser","SVG","path parser","SVGPATH","pathdata","svg parser"],"author":{"name":"Preet Shihn"},"license":"MIT","bugs":{"url":"https://github.com/pshihn/path-data-parser/issues"},"homepage":"https://github.com/pshihn/path-data-parser#readme","devDependencies":{"tslint":"^6.1.1","typescript":"^3.8.3"},"gitHead":"93d3fa8448c50d1b6443b06b8c71202ee0967e25","_id":"path-data-parser@0.1.0","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-NOnmBpt5Y2RWbuv0LMzsayp3lVylAHLPUTut412ZA3l+C4uw4ZVkQbjShYCQ8TCpUMdPapr4YjUqLYD6v68j+w==","shasum":"8f5ba5cc70fc7becb3dcefaea08e2659aba60b8c","tarball":"https://registry.npmjs.org/path-data-parser/-/path-data-parser-0.1.0.tgz","fileCount":17,"unpackedSize":33682,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJekYElCRA9TVsSAnZWagAAPVsQAKNHk6pxiydazQGQbXYL\nDP0OCSGnasimithub61qF/wJpPM8Pr8DU5DZMK0Zc5wvvdbJiNSdxFctGLcF\nFdkCT1zRbziWv1q4rHHTIZ9bRPDn1lwZH1qXoSbHFICrsfSna/HwB3ZF9nzL\ndar7qumCeddRTR3jF3z7fSSbvysVE52WiGYhFi+RAq4kYSptWJ+Mzj46n6Rv\ntluPKvx8bM83ryqTIINk7RfxXh/tFBgLKEUUZNS9waG3+wxbm9KaHYMH5Z0o\n2A+w0YcnbEi49u3zkJP0/5nlvDPVbTzY0Z+Q6CkbJBbJEUTqak8YN4yp5F7/\nRsHCxNUjaRcNUPPvn8EjnLXH1zX7iJ3hGjjhKhIJILrzEB+PkTPG7NpB6SiN\nhqZpSDz8gFExQhyoWV2yl5ruE3DgUiJh2iS20Slt2IGeo0BVc7raDJ466ecJ\nlsWrN+WMHaTfAGQMGtK2CUW/vnAo8LE9BPGijGwTdXfn1sj0qOM+WwTunmb2\niPhzF2GEBOcLX4bAYxO94Re6st++Mpkb9K1/A0Ut7eiQzv6/G4/VGnbsYizg\nIWAM6i5s/Se1zc6kNDvYDBiR2hM2MhBm78F5syqOpEZwQONZ7gc/MgYGdD8m\nJJ5Y/VrcD/IPChiPjEeRz6ZRSUVamNPvzNPprsDZl2hSTgtry5h7TrmjoLrH\nuhwH\r\n=r7ql\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDqtvhoe/v5Xo9aSodYgH7nM0ey3xjfNBWWcJ3OXKNT/AIhAIvl7AASXFCo0ZNDjG3ujVQpJbYCBfFcIoSscLx4OJbw"}]},"maintainers":[{"name":"shihn","email":"preetshihn@gmail.com"}],"_npmUser":{"name":"shihn","email":"preetshihn@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/path-data-parser_0.1.0_1586594084534_0.5980694628865246"},"_hasShrinkwrap":false}},"time":{"created":"2020-04-10T04:40:09.779Z","0.0.1":"2020-04-10T04:40:09.943Z","modified":"2022-05-12T16:27:54.709Z","0.0.2":"2020-04-10T04:41:38.144Z","0.1.0":"2020-04-11T08:34:44.676Z"},"maintainers":[{"name":"shihn","email":"preetshihn@gmail.com"}],"description":"Yet another SVG path parser. This one's tiny","homepage":"https://github.com/pshihn/path-data-parser#readme","keywords":["svg path parser","SVG","path parser","SVGPATH","pathdata","svg parser"],"repository":{"type":"git","url":"git+https://github.com/pshihn/path-data-parser.git"},"author":{"name":"Preet Shihn"},"bugs":{"url":"https://github.com/pshihn/path-data-parser/issues"},"license":"MIT","readme":"# path-data-parser\n\nI know there are a bunch of SVG path parsers out there, but here's one that I have been using for a few years now. It's small, tree-shakable and provides four simple functions that I have needed in several graphics projects.\n\n## Install\n\nFrom npm\n\n```\nnpm install --save path-data-parser\n```\n\nThe code is shipped as ES6 modules. \n\n## Methods\n\nThe module exposes 4 methods\n\n### pasrePath(d: string): Segment[]\n\nThis is the main method that parses the SVG path data. You pass in the path string and it returns an array of `Segments`. A segment has a `key` which is the commands, e.g. `M` or `h` or `C`; and `data` which is an array of numbers used by the command\n\n```javascript\nSegment {\n  key: string;\n  data: number[];\n}\n```\n\nexample:\n\n```javascript\nimport { parsePath } from 'path-data-parser';\nconst segments = parsePath('M10 10 h 80 v 80 h -80 C Z');\n```\n\n### serialize(segments: Segment[]): string\n\nThis is essentially the opposite of the `parsePath` command. It outputs a path string from an array of `Segment` objects.\n\n```javascript\nimport { parsePath, serialize, absolutize } from 'path-data-parser';\n\nconst segments = parsePath('M10 10 h 80 v 80 h -80 Z');\nconst absoluteSegments = absolutize(segments); // Turns relative commands to absolute\nconst outputPath = serialize(absoluteSegments);\nconsole.log(outputPath); // M 10 10 H 90 V 90 H 10 Z\n```\n\n### absolutize(segments: Segment[]): Segment[]\n\nTranslates relative commands to absolute commands. i.e. all commands that use relative positions (lower-case ones), turns into absolute position commands (upper-case ones).\nSee the `serialize` example above. \n\n### normalize(segments: Segment[]): Segment[]\n\nNormalize takes a list of _absolute segments_ and outputs a list of segments with only four commands: `M, L, C, Z`. So every segment is described as move, line, or a bezier curve (cubic). \n\nThis is useful when translating SVG paths to non SVG mediums - Canvas, or some other graphics platform. Most such platforms will support lines and bezier curves. It also simplifies the cases to consider when modifying these segments.\n\n```javascript\nimport { parsePath, serialize, absolutize, normalize } from 'path-data-parser';\n \nconst segments = parsePath(' M 10 80 Q 52.5 10, 95 80 T 180 80');\nconst absoluteSegments = absolutize(segments);\nconst normalizedSegments = normalize(absoluteSegments);\n// M 10 80 C 38.33 33.33, 66.67 33.33, 95 80 C 123.33 126.67, 151.67 126.67, 180 80\n \n```\n\n## License\n[MIT License](https://github.com/pshihn/path-data-parser/blob/master/LICENSE)\n","readmeFilename":"README.md"}