symbol.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. * @category BSONType
  8. */
  9. var BSONSymbol = /** @class */ (function () {
  10. /**
  11. * @param value - the string representing the symbol.
  12. */
  13. function BSONSymbol(value) {
  14. if (!(this instanceof BSONSymbol))
  15. return new BSONSymbol(value);
  16. this.value = value;
  17. }
  18. /** Access the wrapped string value. */
  19. BSONSymbol.prototype.valueOf = function () {
  20. return this.value;
  21. };
  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. BSONSymbol.prototype.toJSON = function () {
  30. return this.value;
  31. };
  32. /** @internal */
  33. BSONSymbol.prototype.toExtendedJSON = function () {
  34. return { $symbol: this.value };
  35. };
  36. /** @internal */
  37. BSONSymbol.fromExtendedJSON = function (doc) {
  38. return new BSONSymbol(doc.$symbol);
  39. };
  40. /** @internal */
  41. BSONSymbol.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () {
  42. return this.inspect();
  43. };
  44. return BSONSymbol;
  45. }());
  46. exports.BSONSymbol = BSONSymbol;
  47. Object.defineProperty(BSONSymbol.prototype, '_bsontype', { value: 'Symbol' });
  48. //# sourceMappingURL=symbol.js.map