All files / tcb-admin-node/src/database regexp.ts

25% Statements 2/8
0% Branches 0/2
0% Functions 0/3
25% Lines 2/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 254x                                         4x      
export class RegExp {
  regexp: string;
  options: string;
  constructor({ regexp, options }) {
    if (!regexp) {
      throw new TypeError("regexp must be a string");
    }
    this.regexp = regexp;
    this.options = options;
  }
 
  parse(key) {
    return {
      [key]: {
        $regex: this.regexp,
        $options: this.options
      }
    };
  }
}
 
export function RegExpConstructor(param) {
  return new RegExp(param);
}