| 1010 | } while (++n); |
| 1011 | } |
| 1012 | inc(e, t, n) { |
| 1013 | switch (e) { |
| 1014 | case "premajor": |
| 1015 | ((this.prerelease.length = 0), |
| 1016 | (this.patch = 0), |
| 1017 | (this.minor = 0), |
| 1018 | this.major++, |
| 1019 | this.inc("pre", t, n)); |
| 1020 | break; |
| 1021 | case "preminor": |
| 1022 | ((this.prerelease.length = 0), |
| 1023 | (this.patch = 0), |
| 1024 | this.minor++, |
| 1025 | this.inc("pre", t, n)); |
| 1026 | break; |
| 1027 | case "prepatch": |
| 1028 | ((this.prerelease.length = 0), |
| 1029 | this.inc("patch", t, n), |
| 1030 | this.inc("pre", t, n)); |
| 1031 | break; |
| 1032 | case "prerelease": |
| 1033 | (0 === this.prerelease.length && this.inc("patch", t, n), |
| 1034 | this.inc("pre", t, n)); |
| 1035 | break; |
| 1036 | case "major": |
| 1037 | ((0 === this.minor && |
| 1038 | 0 === this.patch && |
| 1039 | 0 !== this.prerelease.length) || |
| 1040 | this.major++, |
| 1041 | (this.minor = 0), |
| 1042 | (this.patch = 0), |
| 1043 | (this.prerelease = [])); |
| 1044 | break; |
| 1045 | case "minor": |
| 1046 | ((0 === this.patch && 0 !== this.prerelease.length) || this.minor++, |
| 1047 | (this.patch = 0), |
| 1048 | (this.prerelease = [])); |
| 1049 | break; |
| 1050 | case "patch": |
| 1051 | (0 === this.prerelease.length && this.patch++, |
| 1052 | (this.prerelease = [])); |
| 1053 | break; |
| 1054 | case "pre": { |
| 1055 | const e = Number(n) ? 1 : 0; |
| 1056 | if (!t && !1 === n) |
| 1057 | throw new Error( |
| 1058 | "invalid increment argument: identifier is empty", |
| 1059 | ); |
| 1060 | if (0 === this.prerelease.length) this.prerelease = [e]; |
| 1061 | else { |
| 1062 | let r = this.prerelease.length; |
| 1063 | for (; --r >= 0; ) |
| 1064 | "number" == typeof this.prerelease[r] && |
| 1065 | (this.prerelease[r]++, (r = -2)); |
| 1066 | if (-1 === r) { |
| 1067 | if (t === this.prerelease.join(".") && !1 === n) |
| 1068 | throw new Error( |
| 1069 | "invalid increment argument: identifier already exists", |