11cb0ef41Sopenharmony_ciconst eq = require('./eq')
21cb0ef41Sopenharmony_ciconst neq = require('./neq')
31cb0ef41Sopenharmony_ciconst gt = require('./gt')
41cb0ef41Sopenharmony_ciconst gte = require('./gte')
51cb0ef41Sopenharmony_ciconst lt = require('./lt')
61cb0ef41Sopenharmony_ciconst lte = require('./lte')
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciconst cmp = (a, op, b, loose) => {
91cb0ef41Sopenharmony_ci  switch (op) {
101cb0ef41Sopenharmony_ci    case '===':
111cb0ef41Sopenharmony_ci      if (typeof a === 'object') {
121cb0ef41Sopenharmony_ci        a = a.version
131cb0ef41Sopenharmony_ci      }
141cb0ef41Sopenharmony_ci      if (typeof b === 'object') {
151cb0ef41Sopenharmony_ci        b = b.version
161cb0ef41Sopenharmony_ci      }
171cb0ef41Sopenharmony_ci      return a === b
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ci    case '!==':
201cb0ef41Sopenharmony_ci      if (typeof a === 'object') {
211cb0ef41Sopenharmony_ci        a = a.version
221cb0ef41Sopenharmony_ci      }
231cb0ef41Sopenharmony_ci      if (typeof b === 'object') {
241cb0ef41Sopenharmony_ci        b = b.version
251cb0ef41Sopenharmony_ci      }
261cb0ef41Sopenharmony_ci      return a !== b
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ci    case '':
291cb0ef41Sopenharmony_ci    case '=':
301cb0ef41Sopenharmony_ci    case '==':
311cb0ef41Sopenharmony_ci      return eq(a, b, loose)
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_ci    case '!=':
341cb0ef41Sopenharmony_ci      return neq(a, b, loose)
351cb0ef41Sopenharmony_ci
361cb0ef41Sopenharmony_ci    case '>':
371cb0ef41Sopenharmony_ci      return gt(a, b, loose)
381cb0ef41Sopenharmony_ci
391cb0ef41Sopenharmony_ci    case '>=':
401cb0ef41Sopenharmony_ci      return gte(a, b, loose)
411cb0ef41Sopenharmony_ci
421cb0ef41Sopenharmony_ci    case '<':
431cb0ef41Sopenharmony_ci      return lt(a, b, loose)
441cb0ef41Sopenharmony_ci
451cb0ef41Sopenharmony_ci    case '<=':
461cb0ef41Sopenharmony_ci      return lte(a, b, loose)
471cb0ef41Sopenharmony_ci
481cb0ef41Sopenharmony_ci    default:
491cb0ef41Sopenharmony_ci      throw new TypeError(`Invalid operator: ${op}`)
501cb0ef41Sopenharmony_ci  }
511cb0ef41Sopenharmony_ci}
521cb0ef41Sopenharmony_cimodule.exports = cmp
53