minimatch 9.0.5 → 9.0.7
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/dist/commonjs/assert-valid-pattern.js.map +1 -1
- package/dist/commonjs/ast.d.ts.map +1 -1
- package/dist/commonjs/ast.js +179 -24
- package/dist/commonjs/ast.js.map +1 -1
- package/dist/commonjs/brace-expressions.d.ts.map +1 -1
- package/dist/commonjs/brace-expressions.js.map +1 -1
- package/dist/commonjs/escape.d.ts +1 -1
- package/dist/commonjs/escape.d.ts.map +1 -1
- package/dist/commonjs/index.d.ts +4 -0
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +122 -123
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/unescape.d.ts +1 -1
- package/dist/commonjs/unescape.d.ts.map +1 -1
- package/dist/esm/assert-valid-pattern.js.map +1 -1
- package/dist/esm/ast.d.ts.map +1 -1
- package/dist/esm/ast.js +179 -24
- package/dist/esm/ast.js.map +1 -1
- package/dist/esm/brace-expressions.d.ts.map +1 -1
- package/dist/esm/brace-expressions.js.map +1 -1
- package/dist/esm/escape.d.ts +1 -1
- package/dist/esm/escape.d.ts.map +1 -1
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +121 -119
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/unescape.d.ts +1 -1
- package/dist/esm/unescape.d.ts.map +1 -1
- package/package.json +13 -14
|
@@ -8,5 +8,5 @@ import { MinimatchOptions } from './index.js';
|
|
|
8
8
|
* that exact character. In this mode, `\` is _not_ escaped, because it is
|
|
9
9
|
* not interpreted as a magic character, but instead as a path separator.
|
|
10
10
|
*/
|
|
11
|
-
export declare const escape: (s: string, { windowsPathsNoEscape, }?: Pick<MinimatchOptions,
|
|
11
|
+
export declare const escape: (s: string, { windowsPathsNoEscape, }?: Pick<MinimatchOptions, "windowsPathsNoEscape">) => string;
|
|
12
12
|
//# sourceMappingURL=escape.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escape.d.ts","sourceRoot":"","sources":["../../src/escape.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC7C;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"escape.d.ts","sourceRoot":"","sources":["../../src/escape.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC7C;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM,GACjB,GAAG,MAAM,EACT,4BAEG,IAAI,CAAC,gBAAgB,EAAE,sBAAsB,CAAM,WAQvD,CAAA"}
|
package/dist/commonjs/index.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export interface MinimatchOptions {
|
|
|
21
21
|
optimizationLevel?: number;
|
|
22
22
|
platform?: Platform;
|
|
23
23
|
windowsNoMagicRoot?: boolean;
|
|
24
|
+
maxGlobstarRecursion?: number;
|
|
25
|
+
maxExtglobRecursion?: number;
|
|
24
26
|
}
|
|
25
27
|
export declare const minimatch: {
|
|
26
28
|
(p: string, pattern: string, options?: MinimatchOptions): boolean;
|
|
@@ -51,6 +53,7 @@ export type MMRegExp = RegExp & {
|
|
|
51
53
|
export type ParseReturnFiltered = string | MMRegExp | typeof GLOBSTAR;
|
|
52
54
|
export type ParseReturn = ParseReturnFiltered | false;
|
|
53
55
|
export declare class Minimatch {
|
|
56
|
+
#private;
|
|
54
57
|
options: MinimatchOptions;
|
|
55
58
|
set: ParseReturnFiltered[][];
|
|
56
59
|
pattern: string;
|
|
@@ -67,6 +70,7 @@ export declare class Minimatch {
|
|
|
67
70
|
isWindows: boolean;
|
|
68
71
|
platform: Platform;
|
|
69
72
|
windowsNoMagicRoot: boolean;
|
|
73
|
+
maxGlobstarRecursion: number;
|
|
70
74
|
regexp: false | null | MMRegExp;
|
|
71
75
|
constructor(pattern: string, options?: MinimatchOptions);
|
|
72
76
|
hasMagic(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAe,MAAM,UAAU,CAAA;AAI3C,KAAK,QAAQ,GACT,KAAK,GACL,SAAS,GACT,QAAQ,GACR,SAAS,GACT,OAAO,GACP,OAAO,GACP,SAAS,GACT,OAAO,GACP,OAAO,GACP,QAAQ,GACR,QAAQ,CAAA;AAEZ,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,uBAAuB,CAAC,EAAE,OAAO,CAAA;IACjC,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B;AAED,eAAO,MAAM,SAAS;QACjB,MAAM,WACA,MAAM,YACN,gBAAgB;;;sBAuGf,MAAM,YAAW,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.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M,EAAE,OAAO,UAAe;IAiEvC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,gBAAgB;CAGtC;AAED,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA"}
|
package/dist/commonjs/index.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.unescape = exports.escape = exports.AST = exports.Minimatch = exports.match = exports.makeRe = exports.braceExpand = exports.defaults = exports.filter = exports.GLOBSTAR = exports.sep = exports.minimatch = void 0;
|
|
7
|
-
const brace_expansion_1 =
|
|
4
|
+
const brace_expansion_1 = require("brace-expansion");
|
|
8
5
|
const assert_valid_pattern_js_1 = require("./assert-valid-pattern.js");
|
|
9
6
|
const ast_js_1 = require("./ast.js");
|
|
10
7
|
const escape_js_1 = require("./escape.js");
|
|
@@ -157,7 +154,7 @@ const braceExpand = (pattern, options = {}) => {
|
|
|
157
154
|
// shortcut. no need to expand.
|
|
158
155
|
return [pattern];
|
|
159
156
|
}
|
|
160
|
-
return (0, brace_expansion_1.
|
|
157
|
+
return (0, brace_expansion_1.expand)(pattern);
|
|
161
158
|
};
|
|
162
159
|
exports.braceExpand = braceExpand;
|
|
163
160
|
exports.minimatch.braceExpand = exports.braceExpand;
|
|
@@ -205,11 +202,13 @@ class Minimatch {
|
|
|
205
202
|
isWindows;
|
|
206
203
|
platform;
|
|
207
204
|
windowsNoMagicRoot;
|
|
205
|
+
maxGlobstarRecursion;
|
|
208
206
|
regexp;
|
|
209
207
|
constructor(pattern, options = {}) {
|
|
210
208
|
(0, assert_valid_pattern_js_1.assertValidPattern)(pattern);
|
|
211
209
|
options = options || {};
|
|
212
210
|
this.options = options;
|
|
211
|
+
this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? 200;
|
|
213
212
|
this.pattern = pattern;
|
|
214
213
|
this.platform = options.platform || defaultPlatform;
|
|
215
214
|
this.isWindows = this.platform === 'win32';
|
|
@@ -609,7 +608,8 @@ class Minimatch {
|
|
|
609
608
|
// out of pattern, then that's fine, as long as all
|
|
610
609
|
// the parts match.
|
|
611
610
|
matchOne(file, pattern, partial = false) {
|
|
612
|
-
|
|
611
|
+
let fileStartIndex = 0;
|
|
612
|
+
let patternStartIndex = 0;
|
|
613
613
|
// UNC paths like //?/X:/... can match X:/... and vice versa
|
|
614
614
|
// Drive letters in absolute drive or unc paths are always compared
|
|
615
615
|
// case-insensitively.
|
|
@@ -630,15 +630,14 @@ class Minimatch {
|
|
|
630
630
|
const fdi = fileUNC ? 3 : fileDrive ? 0 : undefined;
|
|
631
631
|
const pdi = patternUNC ? 3 : patternDrive ? 0 : undefined;
|
|
632
632
|
if (typeof fdi === 'number' && typeof pdi === 'number') {
|
|
633
|
-
const [fd, pd] = [
|
|
633
|
+
const [fd, pd] = [
|
|
634
|
+
file[fdi],
|
|
635
|
+
pattern[pdi],
|
|
636
|
+
];
|
|
634
637
|
if (fd.toLowerCase() === pd.toLowerCase()) {
|
|
635
638
|
pattern[pdi] = fd;
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
}
|
|
639
|
-
else if (fdi > pdi) {
|
|
640
|
-
file = file.slice(fdi);
|
|
641
|
-
}
|
|
639
|
+
patternStartIndex = pdi;
|
|
640
|
+
fileStartIndex = fdi;
|
|
642
641
|
}
|
|
643
642
|
}
|
|
644
643
|
}
|
|
@@ -648,102 +647,123 @@ class Minimatch {
|
|
|
648
647
|
if (optimizationLevel >= 2) {
|
|
649
648
|
file = this.levelTwoFileOptimize(file);
|
|
650
649
|
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
650
|
+
if (pattern.includes(exports.GLOBSTAR)) {
|
|
651
|
+
return this.#matchGlobstar(file, pattern, partial, fileStartIndex, patternStartIndex);
|
|
652
|
+
}
|
|
653
|
+
return this.#matchOne(file, pattern, partial, fileStartIndex, patternStartIndex);
|
|
654
|
+
}
|
|
655
|
+
#matchGlobstar(file, pattern, partial, fileIndex, patternIndex) {
|
|
656
|
+
const firstgs = pattern.indexOf(exports.GLOBSTAR, patternIndex);
|
|
657
|
+
const lastgs = pattern.lastIndexOf(exports.GLOBSTAR);
|
|
658
|
+
const [head, body, tail] = [
|
|
659
|
+
pattern.slice(patternIndex, firstgs),
|
|
660
|
+
pattern.slice(firstgs + 1, lastgs),
|
|
661
|
+
pattern.slice(lastgs + 1),
|
|
662
|
+
];
|
|
663
|
+
if (head.length) {
|
|
664
|
+
const fileHead = file.slice(fileIndex, fileIndex + head.length);
|
|
665
|
+
if (!this.#matchOne(fileHead, head, partial, 0, 0))
|
|
666
|
+
return false;
|
|
667
|
+
fileIndex += head.length;
|
|
668
|
+
}
|
|
669
|
+
let fileTailMatch = 0;
|
|
670
|
+
if (tail.length) {
|
|
671
|
+
if (tail.length + fileIndex > file.length)
|
|
662
672
|
return false;
|
|
673
|
+
let tailStart = file.length - tail.length;
|
|
674
|
+
if (this.#matchOne(file, tail, partial, tailStart, 0)) {
|
|
675
|
+
fileTailMatch = tail.length;
|
|
663
676
|
}
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
// a/**/b/**/c would match the following:
|
|
669
|
-
// a/b/x/y/z/c
|
|
670
|
-
// a/x/y/z/b/c
|
|
671
|
-
// a/b/x/b/x/c
|
|
672
|
-
// a/b/c
|
|
673
|
-
// To do this, take the rest of the pattern after
|
|
674
|
-
// the **, and see if it would match the file remainder.
|
|
675
|
-
// If so, return success.
|
|
676
|
-
// If not, the ** "swallows" a segment, and try again.
|
|
677
|
-
// This is recursively awful.
|
|
678
|
-
//
|
|
679
|
-
// a/**/b/**/c matching a/b/x/y/z/c
|
|
680
|
-
// - a matches a
|
|
681
|
-
// - doublestar
|
|
682
|
-
// - matchOne(b/x/y/z/c, b/**/c)
|
|
683
|
-
// - b matches b
|
|
684
|
-
// - doublestar
|
|
685
|
-
// - matchOne(x/y/z/c, c) -> no
|
|
686
|
-
// - matchOne(y/z/c, c) -> no
|
|
687
|
-
// - matchOne(z/c, c) -> no
|
|
688
|
-
// - matchOne(c, c) yes, hit
|
|
689
|
-
var fr = fi;
|
|
690
|
-
var pr = pi + 1;
|
|
691
|
-
if (pr === pl) {
|
|
692
|
-
this.debug('** at the end');
|
|
693
|
-
// a ** at the end will just swallow the rest.
|
|
694
|
-
// We have found a match.
|
|
695
|
-
// however, it will not swallow /.x, unless
|
|
696
|
-
// options.dot is set.
|
|
697
|
-
// . and .. are *never* matched by **, for explosively
|
|
698
|
-
// exponential reasons.
|
|
699
|
-
for (; fi < fl; fi++) {
|
|
700
|
-
if (file[fi] === '.' ||
|
|
701
|
-
file[fi] === '..' ||
|
|
702
|
-
(!options.dot && file[fi].charAt(0) === '.'))
|
|
703
|
-
return false;
|
|
704
|
-
}
|
|
705
|
-
return true;
|
|
677
|
+
else {
|
|
678
|
+
if (file[file.length - 1] !== '' ||
|
|
679
|
+
fileIndex + tail.length === file.length) {
|
|
680
|
+
return false;
|
|
706
681
|
}
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
swallowee === '..' ||
|
|
722
|
-
(!options.dot && swallowee.charAt(0) === '.')) {
|
|
723
|
-
this.debug('dot detected!', file, fr, pattern, pr);
|
|
724
|
-
break;
|
|
725
|
-
}
|
|
726
|
-
// ** swallows a segment, and continue.
|
|
727
|
-
this.debug('globstar swallow a segment, and continue');
|
|
728
|
-
fr++;
|
|
729
|
-
}
|
|
682
|
+
tailStart--;
|
|
683
|
+
if (!this.#matchOne(file, tail, partial, tailStart, 0))
|
|
684
|
+
return false;
|
|
685
|
+
fileTailMatch = tail.length + 1;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
if (!body.length) {
|
|
689
|
+
let sawSome = !!fileTailMatch;
|
|
690
|
+
for (let i = fileIndex; i < file.length - fileTailMatch; i++) {
|
|
691
|
+
const f = String(file[i]);
|
|
692
|
+
sawSome = true;
|
|
693
|
+
if (f === '.' || f === '..' ||
|
|
694
|
+
(!this.options.dot && f.startsWith('.'))) {
|
|
695
|
+
return false;
|
|
730
696
|
}
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
697
|
+
}
|
|
698
|
+
return sawSome;
|
|
699
|
+
}
|
|
700
|
+
const bodySegments = [[[], 0]];
|
|
701
|
+
let currentBody = bodySegments[0];
|
|
702
|
+
let nonGsParts = 0;
|
|
703
|
+
const nonGsPartsSums = [0];
|
|
704
|
+
for (const b of body) {
|
|
705
|
+
if (b === exports.GLOBSTAR) {
|
|
706
|
+
nonGsPartsSums.push(nonGsParts);
|
|
707
|
+
currentBody = [[], 0];
|
|
708
|
+
bodySegments.push(currentBody);
|
|
709
|
+
}
|
|
710
|
+
else {
|
|
711
|
+
currentBody[0].push(b);
|
|
712
|
+
nonGsParts++;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
let i = bodySegments.length - 1;
|
|
716
|
+
const fileLength = file.length - fileTailMatch;
|
|
717
|
+
for (const b of bodySegments) {
|
|
718
|
+
b[1] = fileLength - (nonGsPartsSums[i--] + b[0].length);
|
|
719
|
+
}
|
|
720
|
+
return !!this.#matchGlobStarBodySections(file, bodySegments, fileIndex, 0, partial, 0, !!fileTailMatch);
|
|
721
|
+
}
|
|
722
|
+
#matchGlobStarBodySections(file, bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
|
|
723
|
+
const bs = bodySegments[bodyIndex];
|
|
724
|
+
if (!bs) {
|
|
725
|
+
for (let i = fileIndex; i < file.length; i++) {
|
|
726
|
+
sawTail = true;
|
|
727
|
+
const f = file[i];
|
|
728
|
+
if (f === '.' || f === '..' ||
|
|
729
|
+
(!this.options.dot && f.startsWith('.'))) {
|
|
730
|
+
return false;
|
|
740
731
|
}
|
|
741
|
-
|
|
732
|
+
}
|
|
733
|
+
return sawTail;
|
|
734
|
+
}
|
|
735
|
+
const [body, after] = bs;
|
|
736
|
+
while (fileIndex <= after) {
|
|
737
|
+
const m = this.#matchOne(file.slice(0, fileIndex + body.length), body, partial, fileIndex, 0);
|
|
738
|
+
if (m && globStarDepth < this.maxGlobstarRecursion) {
|
|
739
|
+
const sub = this.#matchGlobStarBodySections(file, bodySegments, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail);
|
|
740
|
+
if (sub !== false)
|
|
741
|
+
return sub;
|
|
742
|
+
}
|
|
743
|
+
const f = file[fileIndex];
|
|
744
|
+
if (f === '.' || f === '..' ||
|
|
745
|
+
(!this.options.dot && f.startsWith('.'))) {
|
|
742
746
|
return false;
|
|
743
747
|
}
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
748
|
+
fileIndex++;
|
|
749
|
+
}
|
|
750
|
+
return null;
|
|
751
|
+
}
|
|
752
|
+
#matchOne(file, pattern, partial, fileIndex, patternIndex) {
|
|
753
|
+
let fi;
|
|
754
|
+
let pi;
|
|
755
|
+
let pl;
|
|
756
|
+
let fl;
|
|
757
|
+
for (fi = fileIndex, pi = patternIndex,
|
|
758
|
+
fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
|
|
759
|
+
this.debug('matchOne loop');
|
|
760
|
+
let p = pattern[pi];
|
|
761
|
+
let f = file[fi];
|
|
762
|
+
this.debug(pattern, p, f);
|
|
763
|
+
/* c8 ignore start */
|
|
764
|
+
if (p === false || p === exports.GLOBSTAR)
|
|
765
|
+
return false;
|
|
766
|
+
/* c8 ignore stop */
|
|
747
767
|
let hit;
|
|
748
768
|
if (typeof p === 'string') {
|
|
749
769
|
hit = f === p;
|
|
@@ -756,38 +776,17 @@ class Minimatch {
|
|
|
756
776
|
if (!hit)
|
|
757
777
|
return false;
|
|
758
778
|
}
|
|
759
|
-
// Note: ending in / means that we'll get a final ""
|
|
760
|
-
// at the end of the pattern. This can only match a
|
|
761
|
-
// corresponding "" at the end of the file.
|
|
762
|
-
// If the file ends in /, then it can only match a
|
|
763
|
-
// a pattern that ends in /, unless the pattern just
|
|
764
|
-
// doesn't have any more for it. But, a/b/ should *not*
|
|
765
|
-
// match "a/b/*", even though "" matches against the
|
|
766
|
-
// [^/]*? pattern, except in partial mode, where it might
|
|
767
|
-
// simply not be reached yet.
|
|
768
|
-
// However, a/b/ should still satisfy a/*
|
|
769
|
-
// now either we fell off the end of the pattern, or we're done.
|
|
770
779
|
if (fi === fl && pi === pl) {
|
|
771
|
-
// ran out of pattern and filename at the same time.
|
|
772
|
-
// an exact hit!
|
|
773
780
|
return true;
|
|
774
781
|
}
|
|
775
782
|
else if (fi === fl) {
|
|
776
|
-
// ran out of file, but still had pattern left.
|
|
777
|
-
// this is ok if we're doing the match as part of
|
|
778
|
-
// a glob fs traversal.
|
|
779
783
|
return partial;
|
|
780
784
|
}
|
|
781
785
|
else if (pi === pl) {
|
|
782
|
-
// ran out of pattern, still have file left.
|
|
783
|
-
// this is only acceptable if we're on the very last
|
|
784
|
-
// empty segment of a file with a trailing slash.
|
|
785
|
-
// a/* should match a/b/
|
|
786
786
|
return fi === fl - 1 && file[fi] === '';
|
|
787
787
|
/* c8 ignore start */
|
|
788
788
|
}
|
|
789
789
|
else {
|
|
790
|
-
// should be unreachable.
|
|
791
790
|
throw new Error('wtf?');
|
|
792
791
|
}
|
|
793
792
|
/* c8 ignore stop */
|