| 34 | } |
| 35 | |
| 36 | parse (comp) { |
| 37 | const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] |
| 38 | const m = comp.match(r) |
| 39 | |
| 40 | if (!m) { |
| 41 | throw new TypeError(`Invalid comparator: ${comp}`) |
| 42 | } |
| 43 | |
| 44 | this.operator = m[1] !== undefined ? m[1] : '' |
| 45 | if (this.operator === '=') { |
| 46 | this.operator = '' |
| 47 | } |
| 48 | |
| 49 | // if it literally is just '>' or '' then allow anything. |
| 50 | if (!m[2]) { |
| 51 | this.semver = ANY |
| 52 | } else { |
| 53 | this.semver = new SemVer(m[2], this.options.loose) |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | toString () { |
| 58 | return this.value |