Socket
Socket
Sign inDemoInstall

svg-pathdata

Package Overview
Dependencies
Maintainers
3
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svg-pathdata - npm Package Compare versions

Comparing version 5.0.1 to 5.0.2

.rpt2_cache/9a5f452c287d80911476f25c9679b0f96b5b8725/code/cache/05a94e263ccadb01d69bb3bb1ebcfbb13093a52a

5

CHANGELOG.md

@@ -0,1 +1,6 @@

<a name="5.0.2"></a>
## [5.0.2](https://github.com/nfroidure/svg-pathdata/compare/v5.0.1...v5.0.2) (2018-06-05)
<a name="5.0.1"></a>

@@ -2,0 +7,0 @@ ## [5.0.1](https://github.com/nfroidure/svg-pathdata/compare/v5.0.0...v5.0.1) (2018-06-03)

2

lib/mathUtils.d.ts

@@ -1,2 +0,2 @@

import { CommandA, CommandC } from "./SVGPathData";
import { CommandA, CommandC } from "./types";
export declare function rotate([x, y]: [number, number], rad: number): number[];

@@ -3,0 +3,0 @@ export declare function assertNumbers(...numbers: number[]): boolean;

import { TransformableSVG } from "./TransformableSVG";
export declare type CommandM = {
relative: boolean;
type: typeof SVGPathData.MOVE_TO;
x: number;
y: number;
};
export declare type CommandL = {
relative: boolean;
type: typeof SVGPathData.LINE_TO;
x: number;
y: number;
};
export declare type CommandH = {
relative: boolean;
type: typeof SVGPathData.HORIZ_LINE_TO;
x: number;
};
export declare type CommandV = {
relative: boolean;
type: typeof SVGPathData.VERT_LINE_TO;
y: number;
};
export declare type CommandZ = {
type: typeof SVGPathData.CLOSE_PATH;
};
export declare type CommandQ = {
relative: boolean;
type: typeof SVGPathData.QUAD_TO;
x1: number;
y1: number;
x: number;
y: number;
};
export declare type CommandT = {
relative: boolean;
type: typeof SVGPathData.SMOOTH_QUAD_TO;
x: number;
y: number;
};
export declare type CommandC = {
relative: boolean;
type: typeof SVGPathData.CURVE_TO;
x1: number;
y1: number;
x2: number;
y2: number;
x: number;
y: number;
};
export declare type CommandS = {
relative: boolean;
type: typeof SVGPathData.SMOOTH_CURVE_TO;
x2: number;
y2: number;
x: number;
y: number;
};
export declare type CommandA = {
relative: boolean;
type: typeof SVGPathData.ARC;
rX: number;
rY: number;
xRot: number;
sweepFlag: 0 | 1;
lArcFlag: 0 | 1;
x: number;
y: number;
cX?: number;
cY?: number;
phi1?: number;
phi2?: number;
};
export declare type SVGCommand = CommandM | CommandL | CommandH | CommandV | CommandZ | CommandQ | CommandT | CommandC | CommandS | CommandA;
export declare type TransformFunction = (input: SVGCommand) => SVGCommand | SVGCommand[];
import { SVGCommand } from "./types";
export declare class SVGPathData extends TransformableSVG {

@@ -80,3 +7,3 @@ commands: SVGCommand[];

encode(): string;
getBounds(): TransformFunction & {
getBounds(): import("./types").TransformFunction & {
minX: number;

@@ -103,5 +30,16 @@ maxX: number;

}
import { encodeSVGPath } from "./SVGPathDataEncoder";
import { SVGPathDataParser } from "./SVGPathDataParser";
import { SVGPathDataTransformer } from "./SVGPathDataTransformer";
export { encodeSVGPath, SVGPathDataParser, SVGPathDataTransformer };
export declare const COMMAND_ARG_COUNTS: {
[SVGPathData.MOVE_TO]: number;
[SVGPathData.LINE_TO]: number;
[SVGPathData.HORIZ_LINE_TO]: number;
[SVGPathData.VERT_LINE_TO]: number;
[SVGPathData.CLOSE_PATH]: number;
[SVGPathData.QUAD_TO]: number;
[SVGPathData.SMOOTH_QUAD_TO]: number;
[SVGPathData.CURVE_TO]: number;
[SVGPathData.SMOOTH_CURVE_TO]: number;
[SVGPathData.ARC]: number;
};
export { encodeSVGPath } from "./SVGPathDataEncoder";
export { SVGPathDataParser } from "./SVGPathDataParser";
export { SVGPathDataTransformer } from "./SVGPathDataTransformer";

@@ -1,82 +0,2 @@

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var TransformableSVG_1 = require("./TransformableSVG");
var SVGPathData = /** @class */ (function (_super) {
__extends(SVGPathData, _super);
function SVGPathData(content) {
var _this = _super.call(this) || this;
if ("string" === typeof content) {
_this.commands = SVGPathData.parse(content);
}
else {
_this.commands = content;
}
return _this;
}
SVGPathData.prototype.encode = function () {
return SVGPathData.encode(this.commands);
};
SVGPathData.prototype.getBounds = function () {
var boundsTransform = SVGPathDataTransformer_1.SVGPathDataTransformer.CALCULATE_BOUNDS();
this.transform(boundsTransform);
return boundsTransform;
};
SVGPathData.prototype.transform = function (transformFunction) {
var newCommands = [];
for (var _i = 0, _a = this.commands; _i < _a.length; _i++) {
var command = _a[_i];
var transformedCommand = transformFunction(command);
if (Array.isArray(transformedCommand)) {
newCommands.push.apply(newCommands, transformedCommand);
}
else {
newCommands.push(transformedCommand);
}
}
this.commands = newCommands;
return this;
};
SVGPathData.encode = function (commands) {
return SVGPathDataEncoder_1.encodeSVGPath(commands);
};
SVGPathData.parse = function (path) {
var parser = new SVGPathDataParser_1.SVGPathDataParser();
var commands = [];
parser.parse(path, commands);
parser.finish(commands);
return commands;
};
SVGPathData.CLOSE_PATH = 1;
SVGPathData.MOVE_TO = 2;
SVGPathData.HORIZ_LINE_TO = 4;
SVGPathData.VERT_LINE_TO = 8;
SVGPathData.LINE_TO = 16;
SVGPathData.CURVE_TO = 32;
SVGPathData.SMOOTH_CURVE_TO = 64;
SVGPathData.QUAD_TO = 128;
SVGPathData.SMOOTH_QUAD_TO = 256;
SVGPathData.ARC = 512;
SVGPathData.LINE_COMMANDS = SVGPathData.LINE_TO | SVGPathData.HORIZ_LINE_TO | SVGPathData.VERT_LINE_TO;
SVGPathData.DRAWING_COMMANDS = SVGPathData.HORIZ_LINE_TO | SVGPathData.VERT_LINE_TO | SVGPathData.LINE_TO |
SVGPathData.CURVE_TO | SVGPathData.SMOOTH_CURVE_TO | SVGPathData.QUAD_TO |
SVGPathData.SMOOTH_QUAD_TO | SVGPathData.ARC;
return SVGPathData;
}(TransformableSVG_1.TransformableSVG));
exports.SVGPathData = SVGPathData;
var SVGPathDataEncoder_1 = require("./SVGPathDataEncoder");
exports.encodeSVGPath = SVGPathDataEncoder_1.encodeSVGPath;
var SVGPathDataParser_1 = require("./SVGPathDataParser");
exports.SVGPathDataParser = SVGPathDataParser_1.SVGPathDataParser;
var SVGPathDataTransformer_1 = require("./SVGPathDataTransformer");
exports.SVGPathDataTransformer = SVGPathDataTransformer_1.SVGPathDataTransformer;
//# sourceMappingURL=SVGPathData.js.map
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(t.svgpathdata={})}(this,function(t){"use strict";var r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var e in r)r.hasOwnProperty(e)&&(t[e]=r[e])};function e(t,e){function a(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(a.prototype=e.prototype,new a)}function a(t,r){var e=t[0],a=t[1];return[e*Math.cos(r)-a*Math.sin(r),e*Math.sin(r)+a*Math.cos(r)]}function n(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];for(var e=0;e<t.length;e++)if("number"!=typeof t[e])throw new Error("assertNumbers arguments["+e+"] is not a number. "+typeof t[e]+" == typeof "+t[e]);return!0}var i=Math.PI;function o(t,r,e){t.lArcFlag=0===t.lArcFlag?0:1,t.sweepFlag=0===t.sweepFlag?0:1;var n=t.rX,o=t.rY,s=t.x,u=t.y;n=Math.abs(t.rX),o=Math.abs(t.rY);var h=a([(r-s)/2,(e-u)/2],-t.xRot/180*i),c=h[0],m=h[1],y=Math.pow(c,2)/Math.pow(n,2)+Math.pow(m,2)/Math.pow(o,2);1<y&&(n*=Math.sqrt(y),o*=Math.sqrt(y)),t.rX=n,t.rY=o;var p=Math.pow(n,2)*Math.pow(m,2)+Math.pow(o,2)*Math.pow(c,2),T=(t.lArcFlag!==t.sweepFlag?1:-1)*Math.sqrt(Math.max(0,(Math.pow(n,2)*Math.pow(o,2)-p)/p)),O=n*m/o*T,_=-o*c/n*T,f=a([O,_],t.xRot/180*i);t.cX=f[0]+(r+s)/2,t.cY=f[1]+(e+u)/2,t.phi1=Math.atan2((m-_)/o,(c-O)/n),t.phi2=Math.atan2((-m-_)/o,(-c-O)/n),0===t.sweepFlag&&t.phi2>t.phi1&&(t.phi2-=2*i),1===t.sweepFlag&&t.phi2<t.phi1&&(t.phi2+=2*i),t.phi1*=180/i,t.phi2*=180/i}function s(t,r,e){n(t,r,e);var a=t*t+r*r-e*e;if(0>a)return[];if(0===a)return[[t*e/(t*t+r*r),r*e/(t*t+r*r)]];var i=Math.sqrt(a);return[[(t*e+r*i)/(t*t+r*r),(r*e-t*i)/(t*t+r*r)],[(t*e-r*i)/(t*t+r*r),(r*e+t*i)/(t*t+r*r)]]}var u=Math.PI/180;function h(t,r,e){return(1-e)*t+e*r}function c(t,r,e,a){return t+Math.cos(a/180*i)*r+Math.sin(a/180*i)*e}function m(t,r,e,a){var n=r-t,i=e-r,o=3*n+3*(a-e)-6*i,s=6*(i-n),u=3*n;return Math.abs(o)<1e-6?[-u/s]:function(t,r,e){void 0===e&&(e=1e-6);var a=t*t/4-r;if(a<-e)return[];if(a<=e)return[-t/2];var n=Math.sqrt(a);return[-t/2-n,-t/2+n]}(s/o,u/o,1e-6)}function y(t,r,e,a,n){var i=1-n;return t*(i*i*i)+r*(3*i*i*n)+e*(3*i*n*n)+a*(n*n*n)}!function(t){function r(){return p(function(t,r,e){return t.relative&&(void 0!==t.x1&&(t.x1+=r),void 0!==t.y1&&(t.y1+=e),void 0!==t.x2&&(t.x2+=r),void 0!==t.y2&&(t.y2+=e),void 0!==t.x&&(t.x+=r),void 0!==t.y&&(t.y+=e),t.relative=!1),t})}function e(){var t=NaN,r=NaN,e=NaN,a=NaN;return p(function(n,i,o){return n.type&l.SMOOTH_CURVE_TO&&(n.type=l.CURVE_TO,t=isNaN(t)?i:t,r=isNaN(r)?o:r,n.x1=n.relative?i-t:2*i-t,n.y1=n.relative?o-r:2*o-r),n.type&l.CURVE_TO?(t=n.relative?i+n.x2:n.x2,r=n.relative?o+n.y2:n.y2):(t=NaN,r=NaN),n.type&l.SMOOTH_QUAD_TO&&(n.type=l.QUAD_TO,e=isNaN(e)?i:e,a=isNaN(a)?o:a,n.x1=n.relative?i-e:2*i-e,n.y1=n.relative?o-a:2*o-a),n.type&l.QUAD_TO?(e=n.relative?i+n.x1:n.x1,a=n.relative?o+n.y1:n.y1):(e=NaN,a=NaN),n})}function i(){var t=NaN,r=NaN;return p(function(e,a,n){if(e.type&l.SMOOTH_QUAD_TO&&(e.type=l.QUAD_TO,t=isNaN(t)?a:t,r=isNaN(r)?n:r,e.x1=e.relative?a-t:2*a-t,e.y1=e.relative?n-r:2*n-r),e.type&l.QUAD_TO){t=e.relative?a+e.x1:e.x1,r=e.relative?n+e.y1:e.y1;var i=e.x1,o=e.y1;e.type=l.CURVE_TO,e.x1=((e.relative?0:a)+2*i)/3,e.y1=((e.relative?0:n)+2*o)/3,e.x2=(e.x+2*i)/3,e.y2=(e.y+2*o)/3}else t=NaN,r=NaN;return e})}function p(t){var r=0,e=0,a=NaN,n=NaN;return function(i){if(isNaN(a)&&!(i.type&l.MOVE_TO))throw new Error("path must start with moveto");var o=t(i,r,e,a,n);return i.type&l.CLOSE_PATH&&(r=a,e=n),void 0!==i.x&&(r=i.relative?r+i.x:i.x),void 0!==i.y&&(e=i.relative?e+i.y:i.y),i.type&l.MOVE_TO&&(a=r,n=e),o}}function T(t,r,e,a,i,o){return n(t,r,e,a,i,o),p(function(n,s,u,h){var c=n.x1,m=n.x2,y=n.relative&&!isNaN(h),p=void 0!==n.x?n.x:y?0:s,T=void 0!==n.y?n.y:y?0:u;function O(t){return t*t}n.type&l.HORIZ_LINE_TO&&0!==r&&(n.type=l.LINE_TO,n.y=n.relative?0:u),n.type&l.VERT_LINE_TO&&0!==e&&(n.type=l.LINE_TO,n.x=n.relative?0:s),void 0!==n.x&&(n.x=n.x*t+T*e+(y?0:i)),void 0!==n.y&&(n.y=p*r+n.y*a+(y?0:o)),void 0!==n.x1&&(n.x1=n.x1*t+n.y1*e+(y?0:i)),void 0!==n.y1&&(n.y1=c*r+n.y1*a+(y?0:o)),void 0!==n.x2&&(n.x2=n.x2*t+n.y2*e+(y?0:i)),void 0!==n.y2&&(n.y2=m*r+n.y2*a+(y?0:o));var _=t*a-r*e;if(void 0!==n.xRot&&(1!==t||0!==r||0!==e||1!==a))if(0===_)delete n.rX,delete n.rY,delete n.xRot,delete n.lArcFlag,delete n.sweepFlag,n.type=l.LINE_TO;else{var f=n.xRot*Math.PI/180,v=Math.sin(f),N=Math.cos(f),E=1/O(n.rX),d=1/O(n.rY),A=O(N)*E+O(v)*d,x=2*v*N*(E-d),C=O(v)*E+O(N)*d,M=A*a*a-x*r*a+C*r*r,R=x*(t*a+r*e)-2*(A*e*a+C*t*r),S=A*e*e-x*t*e+C*t*t,I=(Math.atan2(R,M-S)+Math.PI)%Math.PI/2,g=Math.sin(I),V=Math.cos(I);n.rX=Math.abs(_)/Math.sqrt(M*O(V)+R*g*V+S*O(g)),n.rY=Math.abs(_)/Math.sqrt(M*O(g)-R*g*V+S*O(V)),n.xRot=180*I/Math.PI}return void 0!==n.sweepFlag&&0>_&&(n.sweepFlag=+!n.sweepFlag),n})}function O(){return function(t){var r={};for(var e in t)r[e]=t[e];return r}}t.ROUND=function(t){function r(r){return Math.round(r*t)/t}return void 0===t&&(t=1e13),n(t),function(t){return void 0!==t.x1&&(t.x1=r(t.x1)),void 0!==t.y1&&(t.y1=r(t.y1)),void 0!==t.x2&&(t.x2=r(t.x2)),void 0!==t.y2&&(t.y2=r(t.y2)),void 0!==t.x&&(t.x=r(t.x)),void 0!==t.y&&(t.y=r(t.y)),t}},t.TO_ABS=r,t.TO_REL=function(){return p(function(t,r,e){return t.relative||(void 0!==t.x1&&(t.x1-=r),void 0!==t.y1&&(t.y1-=e),void 0!==t.x2&&(t.x2-=r),void 0!==t.y2&&(t.y2-=e),void 0!==t.x&&(t.x-=r),void 0!==t.y&&(t.y-=e),t.relative=!0),t})},t.NORMALIZE_HVZ=function(t,r,e){return void 0===t&&(t=!0),void 0===r&&(r=!0),void 0===e&&(e=!0),p(function(a,n,i,o,s){if(isNaN(o)&&!(a.type&l.MOVE_TO))throw new Error("path must start with moveto");return r&&a.type&l.HORIZ_LINE_TO&&(a.type=l.LINE_TO,a.y=a.relative?0:i),e&&a.type&l.VERT_LINE_TO&&(a.type=l.LINE_TO,a.x=a.relative?0:n),t&&a.type&l.CLOSE_PATH&&(a.type=l.LINE_TO,a.x=a.relative?o-n:o,a.y=a.relative?s-i:s),a.type&l.ARC&&(0===a.rX||0===a.rY)&&(a.type=l.LINE_TO,delete a.rX,delete a.rY,delete a.xRot,delete a.lArcFlag,delete a.sweepFlag),a})},t.NORMALIZE_ST=e,t.QT_TO_C=i,t.INFO=p,t.SANITIZE=function(t){void 0===t&&(t=0),n(t);var r=NaN,e=NaN,a=NaN,i=NaN;return p(function(n,o,s,u,h){var c=Math.abs,m=!1,y=0,p=0;if(n.type&l.SMOOTH_CURVE_TO&&(y=isNaN(r)?0:o-r,p=isNaN(e)?0:s-e),n.type&(l.CURVE_TO|l.SMOOTH_CURVE_TO)?(r=n.relative?o+n.x2:n.x2,e=n.relative?s+n.y2:n.y2):(r=NaN,e=NaN),n.type&l.SMOOTH_QUAD_TO?(a=isNaN(a)?o:2*o-a,i=isNaN(i)?s:2*s-i):n.type&l.QUAD_TO?(a=n.relative?o+n.x1:n.x1,i=n.relative?s+n.y1:n.y2):(a=NaN,i=NaN),n.type&l.LINE_COMMANDS||n.type&l.ARC&&(0===n.rX||0===n.rY||!n.lArcFlag)||n.type&l.CURVE_TO||n.type&l.SMOOTH_CURVE_TO||n.type&l.QUAD_TO||n.type&l.SMOOTH_QUAD_TO){var T=void 0===n.x?0:n.relative?n.x:n.x-o,O=void 0===n.y?0:n.relative?n.y:n.y-s;y=isNaN(a)?void 0===n.x1?y:n.relative?n.x:n.x1-o:a-o,p=isNaN(i)?void 0===n.y1?p:n.relative?n.y:n.y1-s:i-s;var _=void 0===n.x2?0:n.relative?n.x:n.x2-o,f=void 0===n.y2?0:n.relative?n.y:n.y2-s;c(T)<=t&&c(O)<=t&&c(y)<=t&&c(p)<=t&&c(_)<=t&&c(f)<=t&&(m=!0)}return n.type&l.CLOSE_PATH&&c(o-u)<=t&&c(s-h)<=t&&(m=!0),m?[]:n})},t.MATRIX=T,t.ROTATE=function(t,r,e){void 0===r&&(r=0),void 0===e&&(e=0),n(t,r,e);var a=Math.sin(t),i=Math.cos(t);return T(i,a,-a,i,r-r*i+e*a,e-r*a-e*i)},t.TRANSLATE=function(t,r){return void 0===r&&(r=0),n(t,r),T(1,0,0,1,t,r)},t.SCALE=function(t,r){return void 0===r&&(r=t),n(t,r),T(t,0,0,r,0,0)},t.SKEW_X=function(t){return n(t),T(1,0,Math.atan(t),1,0,0)},t.SKEW_Y=function(t){return n(t),T(1,Math.atan(t),0,1,0,0)},t.X_AXIS_SYMMETRY=function(t){return void 0===t&&(t=0),n(t),T(-1,0,0,1,t,0)},t.Y_AXIS_SYMMETRY=function(t){return void 0===t&&(t=0),n(t),T(1,0,0,-1,0,t)},t.A_TO_C=function(){return p(function(t,r,e){return l.ARC===t.type?function(t,r,e){var n,i,s,c;t.cX||o(t,r,e);for(var m=Math.min(t.phi1,t.phi2),y=Math.max(t.phi1,t.phi2)-m,p=Math.ceil(y/90),T=new Array(p),O=r,_=e,f=0;f<p;f++){var v=h(t.phi1,t.phi2,f/p),N=h(t.phi1,t.phi2,(f+1)/p),E=N-v,d=4/3*Math.tan(E*u/4),A=[Math.cos(v*u)-d*Math.sin(v*u),Math.sin(v*u)+d*Math.cos(v*u)],x=A[0],C=A[1],M=[Math.cos(N*u),Math.sin(N*u)],R=M[0],S=M[1],I=[R+d*Math.sin(N*u),S-d*Math.cos(N*u)],g=I[0],V=I[1];T[f]={relative:t.relative,type:l.CURVE_TO};var L=function(r,e){var n=a([r*t.rX,e*t.rY],t.xRot),i=n[0],o=n[1];return[t.cX+i,t.cY+o]};n=L(x,C),T[f].x1=n[0],T[f].y1=n[1],i=L(g,V),T[f].x2=i[0],T[f].y2=i[1],s=L(R,S),T[f].x=s[0],T[f].y=s[1],t.relative&&(T[f].x1-=O,T[f].y1-=_,T[f].x2-=O,T[f].y2-=_,T[f].x-=O,T[f].y-=_),O=(c=[T[f].x,T[f].y])[0],_=c[1]}return T}(t,t.relative?0:r,t.relative?0:e):t})},t.ANNOTATE_ARCS=function(){return p(function(t,r,e){return t.relative&&(r=0,e=0),l.ARC===t.type&&o(t,r,e),t})},t.CLONE=O,t.CALCULATE_BOUNDS=function(){var t=function(t){var r={};for(var e in t)r[e]=t[e];return r},a=r(),n=i(),u=e(),h=p(function(r,e,i){var p=u(n(a(t(r))));function T(t){t>h.maxX&&(h.maxX=t),t<h.minX&&(h.minX=t)}function O(t){t>h.maxY&&(h.maxY=t),t<h.minY&&(h.minY=t)}if(p.type&l.DRAWING_COMMANDS&&(T(e),O(i)),p.type&l.HORIZ_LINE_TO&&T(p.x),p.type&l.VERT_LINE_TO&&O(p.y),p.type&l.LINE_TO&&(T(p.x),O(p.y)),p.type&l.CURVE_TO){T(p.x),O(p.y);for(var _=0,f=m(e,p.x1,p.x2,p.x);_<f.length;_++)0<(U=f[_])&&1>U&&T(y(e,p.x1,p.x2,p.x,U));for(var v=0,N=m(i,p.y1,p.y2,p.y);v<N.length;v++)0<(U=N[v])&&1>U&&O(y(i,p.y1,p.y2,p.y,U))}if(p.type&l.ARC){T(p.x),O(p.y),o(p,e,i);for(var E=p.xRot/180*Math.PI,d=Math.cos(E)*p.rX,A=Math.sin(E)*p.rX,x=-Math.sin(E)*p.rY,C=Math.cos(E)*p.rY,M=p.phi1<p.phi2?[p.phi1,p.phi2]:-180>p.phi2?[p.phi2+360,p.phi1+360]:[p.phi2,p.phi1],R=M[0],S=M[1],I=function(t){var r=t[0],e=t[1],a=180*Math.atan2(e,r)/Math.PI;return a<R?a+360:a},g=0,V=s(x,-d,0).map(I);g<V.length;g++)(U=V[g])>R&&U<S&&T(c(p.cX,d,x,U));for(var L=0,D=s(C,-A,0).map(I);L<D.length;L++){var U;(U=D[L])>R&&U<S&&O(c(p.cY,A,C,U))}}return r});return h.minX=1/0,h.maxX=-1/0,h.minY=1/0,h.maxY=-1/0,h}}(t.SVGPathDataTransformer||(t.SVGPathDataTransformer={}));var p,T,O=function(){function r(){}return r.prototype.round=function(r){return this.transform(t.SVGPathDataTransformer.ROUND(r))},r.prototype.toAbs=function(){return this.transform(t.SVGPathDataTransformer.TO_ABS())},r.prototype.toRel=function(){return this.transform(t.SVGPathDataTransformer.TO_REL())},r.prototype.normalizeHVZ=function(r,e,a){return this.transform(t.SVGPathDataTransformer.NORMALIZE_HVZ(r,e,a))},r.prototype.normalizeST=function(){return this.transform(t.SVGPathDataTransformer.NORMALIZE_ST())},r.prototype.qtToC=function(){return this.transform(t.SVGPathDataTransformer.QT_TO_C())},r.prototype.aToC=function(){return this.transform(t.SVGPathDataTransformer.A_TO_C())},r.prototype.sanitize=function(r){return this.transform(t.SVGPathDataTransformer.SANITIZE(r))},r.prototype.translate=function(r,e){return this.transform(t.SVGPathDataTransformer.TRANSLATE(r,e))},r.prototype.scale=function(r,e){return this.transform(t.SVGPathDataTransformer.SCALE(r,e))},r.prototype.rotate=function(r,e,a){return this.transform(t.SVGPathDataTransformer.ROTATE(r,e,a))},r.prototype.matrix=function(r,e,a,n,i,o){return this.transform(t.SVGPathDataTransformer.MATRIX(r,e,a,n,i,o))},r.prototype.skewX=function(r){return this.transform(t.SVGPathDataTransformer.SKEW_X(r))},r.prototype.skewY=function(r){return this.transform(t.SVGPathDataTransformer.SKEW_Y(r))},r.prototype.xSymmetry=function(r){return this.transform(t.SVGPathDataTransformer.X_AXIS_SYMMETRY(r))},r.prototype.ySymmetry=function(r){return this.transform(t.SVGPathDataTransformer.Y_AXIS_SYMMETRY(r))},r.prototype.annotateArcs=function(){return this.transform(t.SVGPathDataTransformer.ANNOTATE_ARCS())},r}(),_=function(t){return" "===t||"\t"===t||"\r"===t||"\n"===t},f=function(t){return"0".charCodeAt(0)<=t.charCodeAt(0)&&t.charCodeAt(0)<="9".charCodeAt(0)},v=function(t){function r(){var r=t.call(this)||this;return r.curNumber="",r.curCommandType=-1,r.curCommandRelative=!1,r.canParseCommandOrComma=!0,r.curNumberHasExp=!1,r.curNumberHasExpDigits=!1,r.curNumberHasDecimal=!1,r.curArgs=[],r}return e(r,t),r.prototype.finish=function(t){if(void 0===t&&(t=[]),this.parse(" ",t),0!==this.curArgs.length||!this.canParseCommandOrComma)throw new SyntaxError("Unterminated command at the path end.");return t},r.prototype.parse=function(t,r){var e=this;void 0===r&&(r=[]);for(var a=function(t){r.push(t),e.curArgs.length=0,e.canParseCommandOrComma=!0},n=0;n<t.length;n++){var i=t[n];if(f(i))this.curNumber+=i,this.curNumberHasExpDigits=this.curNumberHasExp;else if("e"!==i&&"E"!==i)if("-"!==i&&"+"!==i||!this.curNumberHasExp||this.curNumberHasExpDigits)if("."!==i||this.curNumberHasExp||this.curNumberHasDecimal){if(this.curNumber&&-1!==this.curCommandType){var o=Number(this.curNumber);if(isNaN(o))throw new SyntaxError("Invalid number ending at "+n);if(this.curCommandType===l.ARC)if(0===this.curArgs.length||1===this.curArgs.length){if(0>o)throw new SyntaxError('Expected positive number, got "'+o+'" at index "'+n+'"')}else if((3===this.curArgs.length||4===this.curArgs.length)&&"0"!==this.curNumber&&"1"!==this.curNumber)throw new SyntaxError('Expected a flag, got "'+this.curNumber+'" at index "'+n+'"');this.curArgs.push(o),this.curArgs.length===N[this.curCommandType]&&(l.HORIZ_LINE_TO===this.curCommandType?a({type:l.HORIZ_LINE_TO,relative:this.curCommandRelative,x:o}):l.VERT_LINE_TO===this.curCommandType?a({type:l.VERT_LINE_TO,relative:this.curCommandRelative,y:o}):this.curCommandType===l.MOVE_TO||this.curCommandType===l.LINE_TO||this.curCommandType===l.SMOOTH_QUAD_TO?(a({type:this.curCommandType,relative:this.curCommandRelative,x:this.curArgs[0],y:this.curArgs[1]}),l.MOVE_TO===this.curCommandType&&(this.curCommandType=l.LINE_TO)):this.curCommandType===l.CURVE_TO?a({type:l.CURVE_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x2:this.curArgs[2],y2:this.curArgs[3],x:this.curArgs[4],y:this.curArgs[5]}):this.curCommandType===l.SMOOTH_CURVE_TO?a({type:l.SMOOTH_CURVE_TO,relative:this.curCommandRelative,x2:this.curArgs[0],y2:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===l.QUAD_TO?a({type:l.QUAD_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===l.ARC&&a({type:l.ARC,relative:this.curCommandRelative,rX:this.curArgs[0],rY:this.curArgs[1],xRot:this.curArgs[2],lArcFlag:this.curArgs[3],sweepFlag:this.curArgs[4],x:this.curArgs[5],y:this.curArgs[6]})),this.curNumber="",this.curNumberHasExpDigits=!1,this.curNumberHasExp=!1,this.curNumberHasDecimal=!1,this.canParseCommandOrComma=!0}if(!_(i))if(","===i&&this.canParseCommandOrComma)this.canParseCommandOrComma=!1;else if("+"!==i&&"-"!==i&&"."!==i){if(0!==this.curArgs.length)throw new SyntaxError("Unterminated command at index "+n+".");if(!this.canParseCommandOrComma)throw new SyntaxError('Unexpected character "'+i+'" at index '+n+". Command cannot follow comma");if(this.canParseCommandOrComma=!1,"z"!==i&&"Z"!==i)if("h"===i||"H"===i)this.curCommandType=l.HORIZ_LINE_TO,this.curCommandRelative="h"===i;else if("v"===i||"V"===i)this.curCommandType=l.VERT_LINE_TO,this.curCommandRelative="v"===i;else if("m"===i||"M"===i)this.curCommandType=l.MOVE_TO,this.curCommandRelative="m"===i;else if("l"===i||"L"===i)this.curCommandType=l.LINE_TO,this.curCommandRelative="l"===i;else if("c"===i||"C"===i)this.curCommandType=l.CURVE_TO,this.curCommandRelative="c"===i;else if("s"===i||"S"===i)this.curCommandType=l.SMOOTH_CURVE_TO,this.curCommandRelative="s"===i;else if("q"===i||"Q"===i)this.curCommandType=l.QUAD_TO,this.curCommandRelative="q"===i;else if("t"===i||"T"===i)this.curCommandType=l.SMOOTH_QUAD_TO,this.curCommandRelative="t"===i;else{if("a"!==i&&"A"!==i)throw new SyntaxError('Unexpected character "'+i+'" at index '+n+".");this.curCommandType=l.ARC,this.curCommandRelative="a"===i}else r.push({type:l.CLOSE_PATH}),this.canParseCommandOrComma=!0,this.curCommandType=-1}else this.curNumber=i,this.curNumberHasDecimal="."===i}else this.curNumber+=i,this.curNumberHasDecimal=!0;else this.curNumber+=i;else this.curNumber+=i,this.curNumberHasExp=!0}return r},r.prototype.transform=function(t){return Object.create(this,{parse:{value:function(r,e){void 0===e&&(e=[]);for(var a=0,n=Object.getPrototypeOf(this).parse.call(this,r);a<n.length;a++){var i=n[a],o=t(i);Array.isArray(o)?e.push.apply(e,o):e.push(o)}return e}}})},r}(O),l=function(r){function a(t){var e=r.call(this)||this;return e.commands="string"==typeof t?a.parse(t):t,e}return e(a,r),a.prototype.encode=function(){return a.encode(this.commands)},a.prototype.getBounds=function(){var r=t.SVGPathDataTransformer.CALCULATE_BOUNDS();return this.transform(r),r},a.prototype.transform=function(t){for(var r=[],e=0,a=this.commands;e<a.length;e++){var n=t(a[e]);Array.isArray(n)?r.push.apply(r,n):r.push(n)}return this.commands=r,this},a.encode=function(t){return d(t)},a.parse=function(t){var r=new v,e=[];return r.parse(t,e),r.finish(e),e},a.CLOSE_PATH=1,a.MOVE_TO=2,a.HORIZ_LINE_TO=4,a.VERT_LINE_TO=8,a.LINE_TO=16,a.CURVE_TO=32,a.SMOOTH_CURVE_TO=64,a.QUAD_TO=128,a.SMOOTH_QUAD_TO=256,a.ARC=512,a.LINE_COMMANDS=a.LINE_TO|a.HORIZ_LINE_TO|a.VERT_LINE_TO,a.DRAWING_COMMANDS=a.HORIZ_LINE_TO|a.VERT_LINE_TO|a.LINE_TO|a.CURVE_TO|a.SMOOTH_CURVE_TO|a.QUAD_TO|a.SMOOTH_QUAD_TO|a.ARC,a}(O),N=((p={})[l.MOVE_TO]=2,p[l.LINE_TO]=2,p[l.HORIZ_LINE_TO]=1,p[l.VERT_LINE_TO]=1,p[l.CLOSE_PATH]=0,p[l.QUAD_TO]=4,p[l.SMOOTH_QUAD_TO]=2,p[l.CURVE_TO]=6,p[l.SMOOTH_CURVE_TO]=4,p[l.ARC]=7,p),E=" ";function d(t){var r="";Array.isArray(t)||(t=[t]);for(var e=0;e<t.length;e++){var a=t[e];if(a.type===l.CLOSE_PATH)r+="z";else if(a.type===l.HORIZ_LINE_TO)r+=(a.relative?"h":"H")+a.x;else if(a.type===l.VERT_LINE_TO)r+=(a.relative?"v":"V")+a.y;else if(a.type===l.MOVE_TO)r+=(a.relative?"m":"M")+a.x+E+a.y;else if(a.type===l.LINE_TO)r+=(a.relative?"l":"L")+a.x+E+a.y;else if(a.type===l.CURVE_TO)r+=(a.relative?"c":"C")+a.x1+E+a.y1+E+a.x2+E+a.y2+E+a.x+E+a.y;else if(a.type===l.SMOOTH_CURVE_TO)r+=(a.relative?"s":"S")+a.x2+E+a.y2+E+a.x+E+a.y;else if(a.type===l.QUAD_TO)r+=(a.relative?"q":"Q")+a.x1+E+a.y1+E+a.x+E+a.y;else if(a.type===l.SMOOTH_QUAD_TO)r+=(a.relative?"t":"T")+a.x+E+a.y;else{if(a.type!==l.ARC)throw new Error('Unexpected command type "'+a.type+'" at index '+e+".");r+=(a.relative?"a":"A")+a.rX+E+a.rY+E+a.xRot+E+ +a.lArcFlag+E+ +a.sweepFlag+E+a.x+E+a.y}}return r}var A=function(r){function a(t){var e=r.call(this)||this;return e.commands="string"==typeof t?a.parse(t):t,e}return e(a,r),a.prototype.encode=function(){return a.encode(this.commands)},a.prototype.getBounds=function(){var r=t.SVGPathDataTransformer.CALCULATE_BOUNDS();return this.transform(r),r},a.prototype.transform=function(t){for(var r=[],e=0,a=this.commands;e<a.length;e++){var n=t(a[e]);Array.isArray(n)?r.push.apply(r,n):r.push(n)}return this.commands=r,this},a.encode=function(t){return d(t)},a.parse=function(t){var r=new v,e=[];return r.parse(t,e),r.finish(e),e},a.CLOSE_PATH=1,a.MOVE_TO=2,a.HORIZ_LINE_TO=4,a.VERT_LINE_TO=8,a.LINE_TO=16,a.CURVE_TO=32,a.SMOOTH_CURVE_TO=64,a.QUAD_TO=128,a.SMOOTH_QUAD_TO=256,a.ARC=512,a.LINE_COMMANDS=a.LINE_TO|a.HORIZ_LINE_TO|a.VERT_LINE_TO,a.DRAWING_COMMANDS=a.HORIZ_LINE_TO|a.VERT_LINE_TO|a.LINE_TO|a.CURVE_TO|a.SMOOTH_CURVE_TO|a.QUAD_TO|a.SMOOTH_QUAD_TO|a.ARC,a}(O),x=((T={})[A.MOVE_TO]=2,T[A.LINE_TO]=2,T[A.HORIZ_LINE_TO]=1,T[A.VERT_LINE_TO]=1,T[A.CLOSE_PATH]=0,T[A.QUAD_TO]=4,T[A.SMOOTH_QUAD_TO]=2,T[A.CURVE_TO]=6,T[A.SMOOTH_CURVE_TO]=4,T[A.ARC]=7,T);t.SVGPathData=A,t.COMMAND_ARG_COUNTS=x,t.encodeSVGPath=d,t.SVGPathDataParser=v,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=SVGPathData.js.map

@@ -1,2 +0,2 @@

import { SVGCommand } from "./SVGPathData";
import { SVGCommand } from "./types";
export declare function encodeSVGPath(commands: SVGCommand | SVGCommand[]): string;

@@ -1,3 +0,3 @@

import { SVGCommand, TransformFunction } from "./SVGPathData";
import { TransformableSVG } from "./TransformableSVG";
import { TransformableSVG } from './TransformableSVG';
import { SVGCommand, TransformFunction } from './types';
export declare class SVGPathDataParser extends TransformableSVG {

@@ -4,0 +4,0 @@ private curNumber;

@@ -1,2 +0,2 @@

import { SVGCommand, TransformFunction } from "./SVGPathData";
import { SVGCommand, TransformFunction } from "./types";
export declare namespace SVGPathDataTransformer {

@@ -3,0 +3,0 @@ function ROUND(roundVal?: number): (command: any) => any;

@@ -1,2 +0,2 @@

import { TransformFunction } from "./SVGPathData";
import { TransformFunction } from "./types";
export declare abstract class TransformableSVG {

@@ -3,0 +3,0 @@ round(x?: number): this;

{
"name": "svg-pathdata",
"version": "5.0.1",
"version": "5.0.2",
"description": "Manipulate SVG path data (path[d] attribute content) simply and efficiently.",
"main": "lib/SVGPathData.js",
"module": "lib/SVGPathData.module.js",
"types": "lib/SVGPathData.d.ts",
"scripts": {

@@ -16,4 +18,5 @@ "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",

"version": "npm run changelog && git add CHANGELOG.md",
"build": "browserify lib/SVGPathData.js -o dist/SVGPathData.js -s svgpathdata",
"test:ci": "tsc && npm run lint && npm run build && npm run test"
"test:ci": "npm run build && npm run test",
"build": "rollup -c rollup.config.js",
"watch": "rollup -c rollup.config.js -w"
},

@@ -44,20 +47,18 @@ "repository": {

},
"dependencies": {},
"devDependencies": {
"@types/node": "^10.3.0",
"browserify": "^14.4.0",
"chai": "^4.1.2",
"chai-stats": "^0.3.0",
"commitizen": "^2.9.6",
"commitizen": "^2.10.1",
"conventional-changelog-cli": "^1.2.0",
"coveralls": "2.11.15",
"coveralls": "^3.0.1",
"cz-conventional-changelog": "^2.0.0",
"eslint": "^4.5.0",
"eslint-config-simplifield": "7.1.0",
"istanbul": "0.4.5",
"mocha": "^5.2.0",
"mocha-lcov-reporter": "1.3.0",
"rimraf": "^2.4.4",
"rollup": "^0.59.4",
"rollup-plugin-typescript2": "^0.14.0",
"rollup-plugin-uglify": "^4.0.0",
"tslint": "^5.6.0",
"typescript": "^2.9.1"
"typescript": "^2.9.1",
"uglify-es": "^3.3.9"
},

@@ -64,0 +65,0 @@ "config": {

@@ -18,3 +18,3 @@ # svg-pathdata

```
or add the [bundle](https://github.com/nfroidure/svg-pathdata/blob/master/dist/SVGPathData.js) to a script in your HTML.
or add the [bundle](https://github.com/nfroidure/svg-pathdata/blob/master/lib/SVGPathData.js) to a script in your HTML.

@@ -21,0 +21,0 @@ Then in your JavaScript files:

@@ -1,2 +0,3 @@

import {CommandA, CommandC, SVGPathData} from "./SVGPathData";
import { SVGPathData } from "./SVGPathData";
import { CommandA, CommandC } from "./types";

@@ -3,0 +4,0 @@ export function rotate([x, y]: [number, number], rad: number) {

@@ -1,42 +0,7 @@

import {TransformableSVG} from "./TransformableSVG";
export type CommandM = { relative: boolean, type: typeof SVGPathData.MOVE_TO, x: number, y: number };
export type CommandL = { relative: boolean, type: typeof SVGPathData.LINE_TO, x: number, y: number };
export type CommandH = { relative: boolean, type: typeof SVGPathData.HORIZ_LINE_TO, x: number };
export type CommandV = { relative: boolean, type: typeof SVGPathData.VERT_LINE_TO, y: number };
export type CommandZ = { type: typeof SVGPathData.CLOSE_PATH };
export type CommandQ = {
relative: boolean;
type: typeof SVGPathData.QUAD_TO;
x1: number;
y1: number;
x: number;
y: number;
};
export type CommandT = { relative: boolean, type: typeof SVGPathData.SMOOTH_QUAD_TO, x: number, y: number };
export type CommandC = {
relative: boolean,
type: typeof SVGPathData.CURVE_TO,
x1: number, y1: number,
x2: number, y2: number,
x: number, y: number };
export type CommandS = {
relative: boolean;
type: typeof SVGPathData.SMOOTH_CURVE_TO;
x2: number;
y2: number;
x: number;
y: number;
};
export type CommandA = {
relative: boolean,
type: typeof SVGPathData.ARC,
rX: number, rY: number,
xRot: number, sweepFlag: 0 | 1, lArcFlag: 0 | 1,
x: number, y: number
cX?: number, cY?: number, phi1?: number, phi2?: number};
export type SVGCommand = CommandM | CommandL | CommandH | CommandV | CommandZ | CommandQ |
CommandT | CommandC | CommandS | CommandA;
import { encodeSVGPath } from "./SVGPathDataEncoder";
import { SVGPathDataParser } from "./SVGPathDataParser";
import { SVGPathDataTransformer } from "./SVGPathDataTransformer";
import { TransformableSVG } from "./TransformableSVG";
import { SVGCommand } from "./types";
export type TransformFunction = (input: SVGCommand) => SVGCommand | SVGCommand[];
export class SVGPathData extends TransformableSVG {

@@ -110,5 +75,17 @@ commands: SVGCommand[];

import { encodeSVGPath } from "./SVGPathDataEncoder";
import {SVGPathDataParser} from "./SVGPathDataParser";
import {SVGPathDataTransformer} from "./SVGPathDataTransformer";
export { encodeSVGPath, SVGPathDataParser, SVGPathDataTransformer };
export const COMMAND_ARG_COUNTS = {
[SVGPathData.MOVE_TO]: 2,
[SVGPathData.LINE_TO]: 2,
[SVGPathData.HORIZ_LINE_TO]: 1,
[SVGPathData.VERT_LINE_TO]: 1,
[SVGPathData.CLOSE_PATH]: 0,
[SVGPathData.QUAD_TO]: 4,
[SVGPathData.SMOOTH_QUAD_TO]: 2,
[SVGPathData.CURVE_TO]: 6,
[SVGPathData.SMOOTH_CURVE_TO]: 4,
[SVGPathData.ARC]: 7,
};
export {encodeSVGPath} from "./SVGPathDataEncoder"
export {SVGPathDataParser} from "./SVGPathDataParser"
export {SVGPathDataTransformer} from "./SVGPathDataTransformer"

@@ -0,6 +1,7 @@

import { SVGPathData } from "./SVGPathData";
import { SVGCommand } from "./types";
// Encode SVG PathData
// http://www.w3.org/TR/SVG/paths.html#PathDataBNF
import {SVGCommand, SVGPathData} from "./SVGPathData";
// Private consts : Char groups

@@ -7,0 +8,0 @@ const WSP = " ";

// Parse SVG PathData
// http://www.w3.org/TR/SVG/paths.html#PathDataBNF
import { SVGCommand, SVGPathData, TransformFunction } from "./SVGPathData";
import { TransformableSVG } from "./TransformableSVG";
import { SVGPathData, COMMAND_ARG_COUNTS } from './SVGPathData';
import { TransformableSVG } from './TransformableSVG';
import { SVGCommand, TransformFunction } from './types';
// Private consts : Char groups
const isWhiteSpace = (c: string) => " " === c || "\t" === c || "\r" === c || "\n" === c;
const isWhiteSpace = (c: string) => ' ' === c || '\t' === c || '\r' === c || '\n' === c;
const isDigit = (c: string) =>
"0".charCodeAt(0) <= c.charCodeAt(0) && c.charCodeAt(0) <= "9".charCodeAt(0);
const COMMANDS = "mMzZlLhHvVcCsSqQtTaA";
// @ts-ignore
const COMMAND_ARG_COUNTS = {
[SVGPathData.MOVE_TO]: 2,
[SVGPathData.LINE_TO]: 2,
[SVGPathData.HORIZ_LINE_TO]: 1,
[SVGPathData.VERT_LINE_TO]: 1,
[SVGPathData.CLOSE_PATH]: 0,
[SVGPathData.QUAD_TO]: 4,
[SVGPathData.SMOOTH_QUAD_TO]: 2,
[SVGPathData.CURVE_TO]: 6,
[SVGPathData.SMOOTH_CURVE_TO]: 4,
[SVGPathData.ARC]: 7,
};
'0'.charCodeAt(0) <= c.charCodeAt(0) && c.charCodeAt(0) <= '9'.charCodeAt(0);
const COMMANDS = 'mMzZlLhHvVcCsSqQtTaA';
export class SVGPathDataParser extends TransformableSVG {
private curNumber: string = "";
private curCommandType: SVGCommand["type"] | -1 = -1;
private curNumber: string = '';
private curCommandType: SVGCommand['type'] | -1 = -1;
private curCommandRelative = false;

@@ -39,6 +27,6 @@ private canParseCommandOrComma = true;

finish(commands: SVGCommand[] = []) {
this.parse(" ", commands);
this.parse(' ', commands);
// Adding residual command
if (0 !== this.curArgs.length || !this.canParseCommandOrComma) {
throw new SyntaxError("Unterminated command at the path end.");
throw new SyntaxError('Unterminated command at the path end.');
}

@@ -64,3 +52,3 @@ return commands;

}
if ("e" === c || "E" === c) {
if ('e' === c || 'E' === c) {
this.curNumber += c;

@@ -70,3 +58,3 @@ this.curNumberHasExp = true;

}
if (("-" === c || "+" === c) && this.curNumberHasExp && !this.curNumberHasExpDigits) {
if (('-' === c || '+' === c) && this.curNumberHasExp && !this.curNumberHasExpDigits) {
this.curNumber += c;

@@ -76,3 +64,3 @@ continue;

// if we already have a ".", it means we are starting a new number
if ("." === c && !this.curNumberHasExp && !this.curNumberHasDecimal) {
if ('.' === c && !this.curNumberHasExp && !this.curNumberHasDecimal) {
this.curNumber += c;

@@ -95,3 +83,3 @@ this.curNumberHasDecimal = true;

} else if (3 === this.curArgs.length || 4 === this.curArgs.length) {
if ("0" !== this.curNumber && "1" !== this.curNumber) {
if ('0' !== this.curNumber && '1' !== this.curNumber) {
throw new SyntaxError(`Expected a flag, got "${this.curNumber}" at index "${i}"`);

@@ -174,3 +162,3 @@ }

}
this.curNumber = "";
this.curNumber = '';
this.curNumberHasExpDigits = false;

@@ -185,3 +173,3 @@ this.curNumberHasExp = false;

}
if ("," === c && this.canParseCommandOrComma) {
if (',' === c && this.canParseCommandOrComma) {
// L 0,0, H is not valid:

@@ -192,5 +180,5 @@ this.canParseCommandOrComma = false;

// if a sign is detected, then parse the new number
if ("+" === c || "-" === c || "." === c) {
if ('+' === c || '-' === c || '.' === c) {
this.curNumber = c;
this.curNumberHasDecimal = "." === c;
this.curNumberHasDecimal = '.' === c;
continue;

@@ -208,3 +196,3 @@ }

// Detecting the next command
if ("z" === c || "Z" === c) {
if ('z' === c || 'Z' === c) {
commands.push({

@@ -217,37 +205,37 @@ type: SVGPathData.CLOSE_PATH,

// Horizontal move to command
} else if ("h" === c || "H" === c) {
} else if ('h' === c || 'H' === c) {
this.curCommandType = SVGPathData.HORIZ_LINE_TO;
this.curCommandRelative = "h" === c;
this.curCommandRelative = 'h' === c;
// Vertical move to command
} else if ("v" === c || "V" === c) {
} else if ('v' === c || 'V' === c) {
this.curCommandType = SVGPathData.VERT_LINE_TO;
this.curCommandRelative = "v" === c;
this.curCommandRelative = 'v' === c;
// Move to command
} else if ("m" === c || "M" === c) {
} else if ('m' === c || 'M' === c) {
this.curCommandType = SVGPathData.MOVE_TO;
this.curCommandRelative = "m" === c;
this.curCommandRelative = 'm' === c;
// Line to command
} else if ("l" === c || "L" === c) {
} else if ('l' === c || 'L' === c) {
this.curCommandType = SVGPathData.LINE_TO;
this.curCommandRelative = "l" === c;
this.curCommandRelative = 'l' === c;
// Curve to command
} else if ("c" === c || "C" === c) {
} else if ('c' === c || 'C' === c) {
this.curCommandType = SVGPathData.CURVE_TO;
this.curCommandRelative = "c" === c;
this.curCommandRelative = 'c' === c;
// Smooth curve to command
} else if ("s" === c || "S" === c) {
} else if ('s' === c || 'S' === c) {
this.curCommandType = SVGPathData.SMOOTH_CURVE_TO;
this.curCommandRelative = "s" === c;
this.curCommandRelative = 's' === c;
// Quadratic bezier curve to command
} else if ("q" === c || "Q" === c) {
} else if ('q' === c || 'Q' === c) {
this.curCommandType = SVGPathData.QUAD_TO;
this.curCommandRelative = "q" === c;
this.curCommandRelative = 'q' === c;
// Smooth quadratic bezier curve to command
} else if ("t" === c || "T" === c) {
} else if ('t' === c || 'T' === c) {
this.curCommandType = SVGPathData.SMOOTH_QUAD_TO;
this.curCommandRelative = "t" === c;
this.curCommandRelative = 't' === c;
// Elliptic arc command
} else if ("a" === c || "A" === c) {
} else if ('a' === c || 'A' === c) {
this.curCommandType = SVGPathData.ARC;
this.curCommandRelative = "a" === c;
this.curCommandRelative = 'a' === c;
} else {

@@ -254,0 +242,0 @@ throw new SyntaxError(`Unexpected character "${c}" at index ${i}.`);

@@ -5,4 +5,5 @@ // Transform SVG PathData

import { a2c, annotateArcCommand, arcAt, assertNumbers, bezierAt, bezierRoot,
intersectionUnitCircleLine } from "./mathUtils.js";
import { SVGCommand, SVGPathData, TransformFunction } from "./SVGPathData";
intersectionUnitCircleLine } from "./mathUtils";
import { SVGPathData } from "./SVGPathData";
import { SVGCommand, TransformFunction } from "./types";

@@ -9,0 +10,0 @@ export namespace SVGPathDataTransformer {

@@ -1,3 +0,3 @@

import { TransformFunction } from "./SVGPathData";
import { SVGPathDataTransformer } from "./SVGPathDataTransformer";
import { TransformFunction } from "./types";

@@ -4,0 +4,0 @@ export abstract class TransformableSVG {

@@ -6,3 +6,3 @@ {

/* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
"module": "commonjs",
"module": "ESNEXT",
/* Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */

@@ -18,3 +18,3 @@ // "lib": [], /* Specify library files to be included in the compilation: */

// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./lib",
"outDir": "./out",
/* Redirect output structure to the directory. */

@@ -21,0 +21,0 @@ "rootDir": "./src",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc