MCPcopy
hub / github.com/npm/node-semver / constructor

Method constructor

classes/comparator.js:10–34  ·  view source on GitHub ↗
(comp, options)

Source from the content-addressed store, hash-verified

8 }
9
10 constructor (comp, options) {
11 options = parseOptions(options)
12
13 if (comp instanceof Comparator) {
14 if (comp.loose === !!options.loose) {
15 return comp
16 } else {
17 comp = comp.value
18 }
19 }
20
21 comp = comp.trim().split(/\s+/).join(' ')
22 debug('comparator', comp, options)
23 this.options = options
24 this.loose = !!options.loose
25 this.parse(comp)
26
27 if (this.semver === ANY) {
28 this.value = ''
29 } else {
30 this.value = this.operator + this.semver.version
31 }
32
33 debug('comp', this)
34 }
35
36 parse (comp) {
37 const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]

Callers

nothing calls this directly

Calls 2

parseMethod · 0.95
parseOptionsFunction · 0.85

Tested by

no test coverage detected