bc80ce5f44590344344ea6410ed6a3473d0105a9
[aai/esr-gui.git] /
1 /**
2  * A class representation of the BSON Code type.
3  *
4  * @class
5  * @param {(string|function)} code a string or function.
6  * @param {Object} [scope] an optional scope for the function.
7  * @return {Code}
8  */
9 var Code = function Code(code, scope) {
10   if(!(this instanceof Code)) return new Code(code, scope);
11   this._bsontype = 'Code';
12   this.code = code;
13   this.scope = scope;
14 };
15
16 /**
17  * @ignore
18  */
19 Code.prototype.toJSON = function() {
20   return {scope:this.scope, code:this.code};
21 }
22
23 module.exports = Code;
24 module.exports.Code = Code;