long.js 504 B

123456789101112131415161718192021
  1. 'use strict';
  2. const Long = require('long');
  3. /**
  4. * @ignore
  5. */
  6. Long.prototype.toExtendedJSON = function(options) {
  7. if (options && options.relaxed) return this.toNumber();
  8. return { $numberLong: this.toString() };
  9. };
  10. /**
  11. * @ignore
  12. */
  13. Long.fromExtendedJSON = function(doc, options) {
  14. const result = Long.fromString(doc.$numberLong);
  15. return options && options.relaxed ? result.toNumber() : result;
  16. };
  17. Object.defineProperty(Long.prototype, '_bsontype', { value: 'Long' });
  18. module.exports = Long;