"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Code = void 0; /** * A class representation of the BSON Code type. * @public */ class Code { /** * @param code - a string or function. * @param scope - an optional scope for the function. */ constructor(code, scope) { this.code = code; this.scope = scope; } /** @internal */ toJSON() { return { code: this.code, scope: this.scope }; } /** @internal */ toExtendedJSON() { if (this.scope) { return { $code: this.code, $scope: this.scope }; } return { $code: this.code }; } /** @internal */ static fromExtendedJSON(doc) { return new Code(doc.$code, doc.$scope); } /** @internal */ [Symbol.for('nodejs.util.inspect.custom')]() { return this.inspect(); } inspect() { const codeJson = this.toJSON(); return `Code("${codeJson.code}"${codeJson.scope ? `, ${JSON.stringify(codeJson.scope)}` : ''})`; } } exports.Code = Code; Object.defineProperty(Code.prototype, '_bsontype', { value: 'Code' }); //# sourceMappingURL=code.js.map