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