svg-path-commander 1.0.2 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,16 +1,16 @@
1
1
  # SVGPathCommander
2
2
  [![Coverage Status](https://coveralls.io/repos/github/thednp/svg-path-commander/badge.svg)](https://coveralls.io/github/thednp/svg-path-commander)
3
- ![cypress version](https://img.shields.io/badge/cypress-9.6.0-brightgreen)
4
- ![typescript version](https://img.shields.io/badge/typescript-4.5.2-brightgreen)
5
3
  [![ci](https://github.com/thednp/svg-path-commander/actions/workflows/ci.yml/badge.svg)](https://github.com/thednp/svg-path-commander/actions/workflows/ci.yml)
4
+ [![NPM Version](https://img.shields.io/npm/v/svg-path-commander.svg)](https://www.npmjs.com/package/svg-path-commander)
5
+ [![NPM Downloads](https://img.shields.io/npm/dm/svg-path-commander.svg)](http://npm-stat.com/charts.html?svg-path-commander)
6
+ [![jsDeliver](https://img.shields.io/jsdelivr/npm/hw/svg-path-commander)](https://www.jsdelivr.com/package/npm/svg-path-commander)
7
+ ![cypress version](https://img.shields.io/badge/cypress-9.6.1-brightgreen)
8
+ ![typescript version](https://img.shields.io/badge/typescript-4.5.2-brightgreen)
6
9
 
7
10
  ![image](./docs/assets/SVGPathCommander.svg)
8
11
 
9
12
  A modern set of ES6+ JavaScript tools for manipulating the `d` (description) attribute for *SVGPathElement* items. The library is implementing modern JavaScript API to produce reusable path strings with lossless quality. In addition, you also have a powerful tool to convert other SVG shapes like `<circle>` or `<rect>` to `<path>`.
10
13
 
11
- [![NPM Version](https://img.shields.io/npm/v/svg-path-commander.svg?style=flat-square)](https://www.npmjs.com/package/svg-path-commander)
12
- [![NPM Downloads](https://img.shields.io/npm/dm/svg-path-commander.svg?style=flat-square)](http://npm-stat.com/charts.html?svg-path-commander)
13
- [![jsDeliver](https://data.jsdelivr.com/v1/package/npm/svg-path-commander/badge)](https://www.jsdelivr.com/package/npm/svg-path-commander)
14
14
 
15
15
  While you may find familiar tools inside, this library brings ***new additions***:
16
16
  * the build in `getBBox`, `getPointAtLength` and `getTotalLength` are more reliable and much more accurate than the native methods, not to mention their world class performance ratings;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * SVGPathCommander v1.0.2 (http://thednp.github.io/svg-path-commander)
2
+ * SVGPathCommander v1.0.5 (http://thednp.github.io/svg-path-commander)
3
3
  * Copyright 2022 © thednp
4
4
  * Licensed under MIT (https://github.com/thednp/svg-path-commander/blob/master/LICENSE)
5
5
  */
@@ -37,7 +37,16 @@
37
37
  var data = path.data;
38
38
 
39
39
  while (data.length >= paramsCount[LK]) {
40
- path.segments.push([pathCommand ].concat( data.splice(0, paramsCount[LK])));
40
+ // overloaded `moveTo`
41
+ // https://github.com/rveciana/svg-path-properties/blob/master/src/parse.ts
42
+ if (LK === 'm' && data.length > 2) {
43
+ path.segments.push([pathCommand ].concat( data.splice(0, 2)));
44
+ LK = 'l';
45
+ pathCommand = pathCommand === 'm' ? 'l' : 'L';
46
+ } else {
47
+ path.segments.push([pathCommand ].concat( data.splice(0, paramsCount[LK])));
48
+ }
49
+
41
50
  if (!paramsCount[LK]) {
42
51
  break;
43
52
  }
@@ -348,7 +357,6 @@
348
357
  */
349
358
  function PathParser(pathString) {
350
359
  /** @type {SVGPath.pathArray} */
351
- // @ts-ignore
352
360
  this.segments = [];
353
361
  /** @type {string} */
354
362
  this.pathValue = pathString;
@@ -384,7 +392,7 @@
384
392
  * of segments we like to call `pathArray`.
385
393
  *
386
394
  * @param {SVGPath.pathArray | string} pathInput the string to be parsed
387
- * @returns {SVGPath.pathArray | string} the resulted `pathArray`
395
+ * @returns {SVGPath.pathArray | string} the resulted `pathArray` or error string
388
396
  */
389
397
  function parsePathString(pathInput) {
390
398
  if (isPathArray(pathInput)) {
@@ -411,7 +419,7 @@
411
419
  */
412
420
  function isAbsoluteArray(path) {
413
421
  return isPathArray(path)
414
- // @ts-ignore -- `isPathArray` also checks if it's `Array`
422
+ // `isPathArray` also checks if it's `Array`
415
423
  && path.every(function (ref) {
416
424
  var x = ref[0];
417
425
 
@@ -429,7 +437,7 @@
429
437
  function pathToAbsolute(pathInput) {
430
438
  /* istanbul ignore else */
431
439
  if (isAbsoluteArray(pathInput)) {
432
- // @ts-ignore -- `isAbsoluteArray` checks if it's `pathArray`
440
+ // `isAbsoluteArray` checks if it's `pathArray`
433
441
  return clonePath(pathInput);
434
442
  }
435
443
 
@@ -437,14 +445,13 @@
437
445
  var x = 0; var y = 0;
438
446
  var mx = 0; var my = 0;
439
447
 
440
- // @ts-ignore -- the `absoluteSegment[]` is for sure an `absolutePath`
448
+ // the `absoluteSegment[]` is for sure an `absolutePath`
441
449
  return path.map(function (segment) {
442
450
  var assign, assign$1, assign$2;
443
451
 
444
452
  var values = segment.slice(1).map(Number);
445
453
  var pathCommand = segment[0];
446
454
  /** @type {SVGPath.absoluteCommand} */
447
- // @ts-ignore
448
455
  var absCommand = pathCommand.toUpperCase();
449
456
 
450
457
  if (pathCommand === 'M') {
@@ -454,7 +461,6 @@
454
461
  return ['M', x, y];
455
462
  }
456
463
  /** @type {SVGPath.absoluteSegment} */
457
- // @ts-ignore
458
464
  var absoluteSegment = [];
459
465
 
460
466
  if (pathCommand !== absCommand) {
@@ -474,12 +480,11 @@
474
480
  // use brakets for `eslint: no-case-declaration`
475
481
  // https://stackoverflow.com/a/50753272/803358
476
482
  var absValues = values.map(function (n, j) { return n + (j % 2 ? y : x); });
477
- // @ts-ignore for n, l, c, s, q, t
483
+ // for n, l, c, s, q, t
478
484
  absoluteSegment = [absCommand ].concat( absValues);
479
485
  }
480
486
  }
481
487
  } else {
482
- // @ts-ignore
483
488
  absoluteSegment = [absCommand ].concat( values);
484
489
  }
485
490
 
@@ -490,17 +495,13 @@
490
495
  y = my;
491
496
  break;
492
497
  case 'H':
493
- // @ts-ignore
494
498
  (assign$1 = absoluteSegment, x = assign$1[1]);
495
499
  break;
496
500
  case 'V':
497
- // @ts-ignore
498
501
  (assign$2 = absoluteSegment, y = assign$2[1]);
499
502
  break;
500
503
  default:
501
- // @ts-ignore
502
504
  x = absoluteSegment[segLength - 2];
503
- // @ts-ignore
504
505
  y = absoluteSegment[segLength - 1];
505
506
 
506
507
  if (absCommand === 'M') {
@@ -521,7 +522,7 @@
521
522
  */
522
523
  function isRelativeArray(path) {
523
524
  return isPathArray(path)
524
- // @ts-ignore -- `isPathArray` checks if it's `Array`
525
+ // `isPathArray` checks if it's `Array`
525
526
  && path.slice(1).every(function (ref) {
526
527
  var pc = ref[0];
527
528
 
@@ -628,13 +629,45 @@
628
629
  while (segment.length) {
629
630
  // if created multiple C:s, their original seg is saved
630
631
  allPathCommands[i] = 'A';
631
- // @ts-ignore
632
632
  path.splice(ni += 1, 0, ['C' ].concat( segment.splice(0, 6)));
633
633
  }
634
634
  path.splice(i, 1);
635
635
  }
636
636
  }
637
637
 
638
+ /**
639
+ * Iterates an array to check if it's a `pathArray`
640
+ * with all segments are in non-shorthand notation
641
+ * with absolute values.
642
+ *
643
+ * @param {string | SVGPath.pathArray} path the `pathArray` to be checked
644
+ * @returns {boolean} iteration result
645
+ */
646
+ function isNormalizedArray(path) {
647
+ // `isAbsoluteArray` also checks if it's `Array`
648
+ return isAbsoluteArray(path) && path.every(function (ref) {
649
+ var pc = ref[0];
650
+
651
+ return 'ACLMQZ'.includes(pc);
652
+ });
653
+ }
654
+
655
+ /**
656
+ * Iterates an array to check if it's a `pathArray`
657
+ * with all C (cubic bezier) segments.
658
+ *
659
+ * @param {string | SVGPath.pathArray} path the `Array` to be checked
660
+ * @returns {boolean} iteration result
661
+ */
662
+ function isCurveArray(path) {
663
+ // `isPathArray` also checks if it's `Array`
664
+ return isNormalizedArray(path) && path.every(function (ref) {
665
+ var pc = ref[0];
666
+
667
+ return 'MC'.includes(pc);
668
+ });
669
+ }
670
+
638
671
  /**
639
672
  * Normalizes a single segment of a `pathArray` object.
640
673
  *
@@ -683,23 +716,6 @@
683
716
  return result;
684
717
  }
685
718
 
686
- /**
687
- * Iterates an array to check if it's a `pathArray`
688
- * with all segments are in non-shorthand notation
689
- * with absolute values.
690
- *
691
- * @param {string | SVGPath.pathArray} path the `pathArray` to be checked
692
- * @returns {boolean} iteration result
693
- */
694
- function isNormalizedArray(path) {
695
- // @ts-ignore -- `isAbsoluteArray` also checks if it's `Array`
696
- return isAbsoluteArray(path) && path.every(function (ref) {
697
- var pc = ref[0];
698
-
699
- return 'ACLMQZ'.includes(pc);
700
- });
701
- }
702
-
703
719
  /**
704
720
  * @type {SVGPath.parserParams}
705
721
  */
@@ -748,55 +764,6 @@
748
764
  return path;
749
765
  }
750
766
 
751
- /**
752
- * Checks a `pathArray` for an unnecessary `Z` segment
753
- * and returns a new `pathArray` without it.
754
- *
755
- * The `pathInput` must be a single path, without
756
- * sub-paths. For multi-path `<path>` elements,
757
- * use `splitPath` first and apply this utility on each
758
- * sub-path separately.
759
- *
760
- * @param {SVGPath.pathArray | string} pathInput the `pathArray` source
761
- * @return {SVGPath.pathArray} a fixed `pathArray`
762
- */
763
- function fixPath(pathInput) {
764
- var pathArray = parsePathString(pathInput);
765
- var normalArray = normalizePath(pathArray);
766
- var length = pathArray.length;
767
- var isClosed = normalArray.slice(-1)[0][0] === 'Z';
768
- var segBeforeZ = isClosed ? length - 2 : length - 1;
769
-
770
- var ref = normalArray[0].slice(1);
771
- var mx = ref[0];
772
- var my = ref[1];
773
- var ref$1 = normalArray[segBeforeZ].slice(-2);
774
- var x = ref$1[0];
775
- var y = ref$1[1];
776
-
777
- /* istanbul ignore else */
778
- if (isClosed && mx === x && my === y) {
779
- return pathArray.slice(0, -1);
780
- }
781
- return pathArray;
782
- }
783
-
784
- /**
785
- * Iterates an array to check if it's a `pathArray`
786
- * with all C (cubic bezier) segments.
787
- *
788
- * @param {string | SVGPath.pathArray} path the `Array` to be checked
789
- * @returns {boolean} iteration result
790
- */
791
- function isCurveArray(path) {
792
- // @ts-ignore -- `isPathArray` also checks if it's `Array`
793
- return isNormalizedArray(path) && path.every(function (ref) {
794
- var pc = ref[0];
795
-
796
- return 'MC'.includes(pc);
797
- });
798
- }
799
-
800
767
  /**
801
768
  * Returns an {x,y} vector rotated by a given
802
769
  * angle in radian.
@@ -873,9 +840,9 @@
873
840
  cx = ((k * rx * y) / ry) + ((x1 + x2) / 2);
874
841
  cy = ((k * -ry * x) / rx) + ((y1 + y2) / 2);
875
842
  // eslint-disable-next-line no-bitwise -- Impossible to satisfy no-bitwise
876
- f1 = (Math.asin((((y1 - cy) / ry))) * (Math.pow( 10, 9 )) >> 0) / (Math.pow( 10, 9 ));
843
+ f1 = Math.asin((((y1 - cy) / ry) * (Math.pow( 10, 9 )) >> 0) / (Math.pow( 10, 9 )));
877
844
  // eslint-disable-next-line no-bitwise -- Impossible to satisfy no-bitwise
878
- f2 = (Math.asin((((y2 - cy) / ry))) * (Math.pow( 10, 9 )) >> 0) / (Math.pow( 10, 9 ));
845
+ f2 = Math.asin((((y2 - cy) / ry) * (Math.pow( 10, 9 )) >> 0) / (Math.pow( 10, 9 )));
879
846
 
880
847
  f1 = x1 < cx ? Math.PI - f1 : f1;
881
848
  f2 = x2 < cx ? Math.PI - f2 : f2;
@@ -997,7 +964,7 @@
997
964
 
998
965
  /* istanbul ignore else */
999
966
  if (typeof distance === 'number') {
1000
- if (distance === 0) {
967
+ if (distance <= 0) {
1001
968
  point = { x: x1, y: y1 };
1002
969
  } else if (distance >= length) {
1003
970
  point = { x: x2, y: y2 };
@@ -1044,13 +1011,10 @@
1044
1011
  var p5 = midPoint(p3, p4, t);
1045
1012
  var p6 = midPoint(p4, p5, t);
1046
1013
  var seg1 = p0.concat( p2, p4, p6, [t]);
1047
- // @ts-ignore
1048
1014
  var cp1 = segmentLineFactory.apply(void 0, seg1).point;
1049
1015
  var seg2 = p6.concat( p5, p3, p1, [0]);
1050
- // @ts-ignore
1051
1016
  var cp2 = segmentLineFactory.apply(void 0, seg2).point;
1052
1017
 
1053
- // @ts-ignore
1054
1018
  return [cp1.x, cp1.y, cp2.x, cp2.y, x2, y2];
1055
1019
  }
1056
1020
 
@@ -1113,11 +1077,12 @@
1113
1077
 
1114
1078
  /* istanbul ignore else */
1115
1079
  if (isCurveArray(pathInput)) {
1116
- // @ts-ignore -- `isCurveArray` checks if it's `pathArray`
1080
+ // `isCurveArray` checks if it's `pathArray`
1117
1081
  return clonePath(pathInput);
1118
1082
  }
1119
1083
 
1120
- var path = fixPath(normalizePath(pathInput));
1084
+ // const path = fixPath(normalizePath(pathInput));
1085
+ var path = normalizePath(pathInput);
1121
1086
  var params = Object.assign({}, paramsParser);
1122
1087
  var allPathCommands = [];
1123
1088
  var pathCommand = ''; // ts-lint
@@ -1140,7 +1105,6 @@
1140
1105
  params.y2 = +(segment[seglen - 3]) || params.y1;
1141
1106
  }
1142
1107
 
1143
- // @ts-ignore
1144
1108
  return path;
1145
1109
  }
1146
1110
 
@@ -1207,7 +1171,7 @@
1207
1171
  var segment = seg.seg;
1208
1172
  var data = seg.n;
1209
1173
  var prevSeg = i && path[i - 1];
1210
- var nextSeg = path[i + 1] && path[i + 1];
1174
+ var nextSeg = path[i + 1];
1211
1175
  var pathCommand = seg.c;
1212
1176
  var pLen = path.length;
1213
1177
  /** @type {number} */
@@ -1231,7 +1195,7 @@
1231
1195
  }
1232
1196
  break;
1233
1197
  case 'S':
1234
- if ((prevSeg && 'CS'.includes(prevSeg.c)) && (!nextSeg || (nextSeg && nextSeg.c !== 'S'))) {
1198
+ if ((prevSeg && 'CS'.includes(prevSeg.c)) && (!nextSeg || nextSeg.c !== 'S')) {
1235
1199
  result = ['C', data[3], data[4], data[1], data[2], x, y];
1236
1200
  } else {
1237
1201
  result = [pathCommand, data[1], data[2], x, y];
@@ -1245,7 +1209,7 @@
1245
1209
  }
1246
1210
  break;
1247
1211
  case 'T':
1248
- if ((prevSeg && 'QT'.includes(prevSeg.c)) && (!nextSeg || (nextSeg && nextSeg.c !== 'T'))) {
1212
+ if ((prevSeg && 'QT'.includes(prevSeg.c)) && (!nextSeg || nextSeg.c !== 'T')) {
1249
1213
  result = ['Q', data[1], data[2], x, y];
1250
1214
  } else {
1251
1215
  result = [pathCommand, x, y];
@@ -1964,7 +1928,7 @@
1964
1928
  m.m31 = 0; m.m32 = 0; m.m33 = 1; m.m34 = 0;
1965
1929
  m.m41 = 0; m.m42 = 0; m.m43 = 0; m.m44 = 1;
1966
1930
 
1967
- if (args && args.length) {
1931
+ if (args.length) {
1968
1932
  var ARGS = [16, 6].some(function (l) { return l === args.length; }) ? args : args[0];
1969
1933
 
1970
1934
  return m.setMatrixValue(ARGS);
@@ -2268,9 +2232,7 @@
2268
2232
  toArray: toArray,
2269
2233
  });
2270
2234
 
2271
- var version$1 = "1.0.2";
2272
-
2273
- // @ts-ignore
2235
+ var version$1 = "1.0.3";
2274
2236
 
2275
2237
  /**
2276
2238
  * A global namespace for library version.
@@ -2278,6 +2240,8 @@
2278
2240
  */
2279
2241
  var Version$1 = version$1;
2280
2242
 
2243
+ /** @typedef {import('../types/index')} */
2244
+
2281
2245
  Object.assign(CSSMatrix, { Version: Version$1 });
2282
2246
 
2283
2247
  /**
@@ -2677,7 +2641,7 @@
2677
2641
  var POINT = { x: 0, y: 0 };
2678
2642
  var POINTS = [{ x: x, y: y }];
2679
2643
 
2680
- if (distanceIsNumber && distance === 0) {
2644
+ if (distanceIsNumber && distance <= 0) {
2681
2645
  POINT = { x: x, y: y };
2682
2646
  }
2683
2647
 
@@ -2775,7 +2739,7 @@
2775
2739
  var POINT = { x: 0, y: 0 };
2776
2740
  var POINTS = [{ x: x, y: y }];
2777
2741
 
2778
- if (distanceIsNumber && distance === 0) {
2742
+ if (distanceIsNumber && distance <= 0) {
2779
2743
  POINT = { x: x, y: y };
2780
2744
  }
2781
2745
 
@@ -2869,7 +2833,7 @@
2869
2833
  var POINT = { x: 0, y: 0 };
2870
2834
  var POINTS = [{ x: x, y: y }];
2871
2835
 
2872
- if (distanceIsNumber && distance === 0) {
2836
+ if (distanceIsNumber && distance <= 0) {
2873
2837
  POINT = { x: x, y: y };
2874
2838
  }
2875
2839
 
@@ -2926,10 +2890,9 @@
2926
2890
 
2927
2891
  var path = normalizePath(pathInput);
2928
2892
  var distanceIsNumber = typeof distance === 'number';
2929
- var isM = true;
2930
- /** @type {number[]} */
2893
+ var isM;
2931
2894
  var data = [];
2932
- var pathCommand = 'M';
2895
+ var pathCommand;
2933
2896
  var x = 0;
2934
2897
  var y = 0;
2935
2898
  var mx = 0;
@@ -3079,6 +3042,8 @@
3079
3042
  * @returns {SVGPathCommander} a new SVGPathCommander instance
3080
3043
  */
3081
3044
  var SVGPathCommander = function SVGPathCommander(pathValue, config) {
3045
+ var assign;
3046
+
3082
3047
  var instanceOptions = config || {};
3083
3048
 
3084
3049
  var undefPath = typeof pathValue === 'undefined';
@@ -3105,19 +3070,22 @@
3105
3070
  var cz = ref.cz;
3106
3071
 
3107
3072
  // set instance options.round
3108
- var round = defaultOptions.round;
3109
- var origin = defaultOptions.origin;
3110
3073
  var roundOption = instanceOptions.round;
3111
3074
  var originOption = instanceOptions.origin;
3075
+ var round;
3112
3076
 
3113
3077
  if (roundOption === 'auto') {
3114
3078
  var pathScale = (("" + (Math.floor(Math.max(width, height))))).length;
3115
3079
  round = pathScale >= 4 ? 0 : 4 - pathScale;
3116
3080
  } else if (Number.isInteger(roundOption) || roundOption === 'off') {
3117
3081
  round = roundOption;
3082
+ } else {
3083
+ ((assign = defaultOptions, round = assign.round));
3118
3084
  }
3119
3085
 
3120
3086
  // set instance options.origin
3087
+ // the SVGPathCommander class will always override the default origin
3088
+ var origin;
3121
3089
  if (Array.isArray(originOption) && originOption.length >= 2) {
3122
3090
  var ref$1 = originOption.map(Number);
3123
3091
  var originX = ref$1[0];
@@ -3131,10 +3099,9 @@
3131
3099
  origin = [cx, cy, cz];
3132
3100
  }
3133
3101
 
3134
- /**
3135
- * @type {number | 'off'}
3136
- */
3102
+ /** @type {number | 'off'} */
3137
3103
  this.round = round;
3104
+ /** @type {[number, number, number=]} */
3138
3105
  this.origin = origin;
3139
3106
 
3140
3107
  return this;
@@ -3218,7 +3185,6 @@
3218
3185
  var split = splitPath(segments);
3219
3186
  var subPath = split.length > 1 ? split : 0;
3220
3187
 
3221
- // @ts-ignore
3222
3188
  var absoluteMultiPath = subPath && clonePath(subPath).map(function (x, i) {
3223
3189
  if (onlySubpath) {
3224
3190
  return i ? reversePath(x) : parsePathString(x);
@@ -3478,9 +3444,9 @@
3478
3444
  return dx * dx + dy * dy;
3479
3445
  };
3480
3446
  var precision = 8;
3481
- var scan = { x: 0, y: 0 };
3447
+ var scan;
3482
3448
  var scanDistance = 0;
3483
- var closest = scan;
3449
+ var closest;
3484
3450
  var bestLength = 0;
3485
3451
  var bestDistance = Infinity;
3486
3452
 
@@ -3497,8 +3463,8 @@
3497
3463
 
3498
3464
  // binary search for precise estimate
3499
3465
  precision /= 2;
3500
- var before = { x: 0, y: 0 };
3501
- var after = before;
3466
+ var before;
3467
+ var after;
3502
3468
  var beforeLength = 0;
3503
3469
  var afterLength = 0;
3504
3470
  var beforeDistance = 0;
@@ -3818,10 +3784,37 @@
3818
3784
  }
3819
3785
 
3820
3786
  /**
3821
- * Must have at least one import of the main namespace.
3822
- * @typedef {import('../../types/index')}
3823
- * @typedef {import('../types/index')}
3787
+ * Checks a `pathArray` for an unnecessary `Z` segment
3788
+ * and returns a new `pathArray` without it.
3789
+ *
3790
+ * The `pathInput` must be a single path, without
3791
+ * sub-paths. For multi-path `<path>` elements,
3792
+ * use `splitPath` first and apply this utility on each
3793
+ * sub-path separately.
3794
+ *
3795
+ * @param {SVGPath.pathArray | string} pathInput the `pathArray` source
3796
+ * @return {SVGPath.pathArray} a fixed `pathArray`
3824
3797
  */
3798
+ function fixPath(pathInput) {
3799
+ var pathArray = parsePathString(pathInput);
3800
+ var normalArray = normalizePath(pathArray);
3801
+ var length = pathArray.length;
3802
+ var isClosed = normalArray.slice(-1)[0][0] === 'Z';
3803
+ var segBeforeZ = isClosed ? length - 2 : length - 1;
3804
+
3805
+ var ref = normalArray[0].slice(1);
3806
+ var mx = ref[0];
3807
+ var my = ref[1];
3808
+ var ref$1 = normalArray[segBeforeZ].slice(-2);
3809
+ var x = ref$1[0];
3810
+ var y = ref$1[1];
3811
+
3812
+ /* istanbul ignore else */
3813
+ if (isClosed && mx === x && my === y) {
3814
+ return pathArray.slice(0, -1);
3815
+ }
3816
+ return pathArray;
3817
+ }
3825
3818
 
3826
3819
  /**
3827
3820
  * @interface
@@ -3864,7 +3857,7 @@
3864
3857
  options: defaultOptions,
3865
3858
  };
3866
3859
 
3867
- var version = "1.0.2";
3860
+ var version = "1.0.5";
3868
3861
 
3869
3862
  /**
3870
3863
  * A global namespace for library version.
@@ -3872,6 +3865,8 @@
3872
3865
  */
3873
3866
  var Version = version;
3874
3867
 
3868
+ /** @typedef {import('../types/index')} */
3869
+
3875
3870
  // Export to global
3876
3871
  Object.assign(SVGPathCommander, Util, { Version: Version });
3877
3872