symbol.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. /** @internal */
  22. BSONSymbol.prototype.toString = function () {
  23. return this.value;
  24. };
  25. /** @internal */
  26. BSONSymbol.prototype.inspect = function () {
  27. return "new BSONSymbol(\"" + this.value + "\")";
  28. };
  29. /** @internal */
  30. BSONSymbol.prototype.toJSON = function () {
  31. return this.value;
  32. };
  33. /** @internal */
  34. BSONSymbol.prototype.toExtendedJSON = function () {
  35. return { $symbol: this.value };
  36. };
  37. /** @internal */
  38. BSONSymbol.fromExtendedJSON = function (doc) {
  39. return new BSONSymbol(doc.$symbol);
  40. };
  41. /** @internal */
  42. BSONSymbol.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () {
  43. return this.inspect();
  44. };
  45. return BSONSymbol;
  46. }());
  47. exports.BSONSymbol = BSONSymbol;
  48. Object.defineProperty(BSONSymbol.prototype, '_bsontype', { value: 'Symbol' });
  49. //# sourceMappingURL=symbol.js.map