symbol.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.BSONSymbol = void 0;
  4. /**
  5. * A class representation of the BSON Symbol type.
  6. * @public
  7. */
  8. var BSONSymbol = /** @class */ (function () {
  9. /**
  10. * @param value - the string representing the symbol.
  11. */
  12. function BSONSymbol(value) {
  13. if (!(this instanceof BSONSymbol))
  14. return new BSONSymbol(value);
  15. this.value = value;
  16. }
  17. /** Access the wrapped string value. */
  18. BSONSymbol.prototype.valueOf = function () {
  19. return this.value;
  20. };
  21. BSONSymbol.prototype.toString = function () {
  22. return this.value;
  23. };
  24. /** @internal */
  25. BSONSymbol.prototype.inspect = function () {
  26. return "new BSONSymbol(\"" + this.value + "\")";
  27. };
  28. BSONSymbol.prototype.toJSON = function () {
  29. return this.value;
  30. };
  31. /** @internal */
  32. BSONSymbol.prototype.toExtendedJSON = function () {
  33. return { $symbol: this.value };
  34. };
  35. /** @internal */
  36. BSONSymbol.fromExtendedJSON = function (doc) {
  37. return new BSONSymbol(doc.$symbol);
  38. };
  39. /** @internal */
  40. BSONSymbol.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () {
  41. return this.inspect();
  42. };
  43. return BSONSymbol;
  44. }());
  45. exports.BSONSymbol = BSONSymbol;
  46. Object.defineProperty(BSONSymbol.prototype, '_bsontype', { value: 'Symbol' });
  47. //# sourceMappingURL=symbol.js.map