code: function valueMatches(match, value) {
    if (isValue(match)) {
      return Tyr.isEqual(match, value);
    }
  
    for (const op in match) {
      if (!op.startsWith('$')) {
        if (!value || !valueMatches(match[op], value[op])) {
          return false;
        }
      } else {
        switch (op) {
          case '$eq':
            if (!Tyr.isEqual(match.$eq, value)) {
              return false;
            }
            break;
  
          case '$in':
            if (
              !value ||
              !match.$in.length ||
              !arrayIntersection(match.$in, value).length
            ) {
              return false;
            }
            break;
  
          case '$bitsAllClear':
            if ((value & match.$bitsAllClear) !== 0x0) {
              return false;
            }
  
            break;
  
          case '$bitsAllSet': {
            const v = match.$bitsAllSet;
            if ((value & v) !== v) {
              return false;
            }
  
            break;
          }
  
          case '$bitsAnyClear': {
            const v = match.$bitsAnyClear;
            if ((value & v) === v) {
              return false;
            }
  
            break;
          }
  
          case '$bitsAnySet': {
            const v = match.$bitsAnySet;
            if ((value & v) === 0x0) {
              return false;
            }
  
            break;
          }
  
          default:
            throw new Error('op ' + op + ' not supported (yet)');
        }
      }
    }
  
    return true;
  }
docs: Query Matching