333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
 * A class representation of the BSON RegExp type.
 *
 * @class
 * @return {BSONRegExp} A MinKey instance
 */
function BSONRegExp(pattern, options) {
  if (!(this instanceof BSONRegExp)) return new BSONRegExp();
 
  // Execute
  this._bsontype = 'BSONRegExp';
  this.pattern = pattern || '';
  this.options = options || '';
 
  // Validate options
  for (var i = 0; i < this.options.length; i++) {
    if (
      !(
        this.options[i] === 'i' ||
        this.options[i] === 'm' ||
        this.options[i] === 'x' ||
        this.options[i] === 'l' ||
        this.options[i] === 's' ||
        this.options[i] === 'u'
      )
    ) {
      throw new Error('the regular expression options [' + this.options[i] + '] is not supported');
    }
  }
}
 
module.exports = BSONRegExp;
module.exports.BSONRegExp = BSONRegExp;