double.js 611 B

123456789101112131415161718192021222324252627282930313233
  1. /**
  2. * A class representation of the BSON Double type.
  3. *
  4. * @class
  5. * @param {number} value the number we want to represent as a double.
  6. * @return {Double}
  7. */
  8. function Double(value) {
  9. if (!(this instanceof Double)) return new Double(value);
  10. this._bsontype = 'Double';
  11. this.value = value;
  12. }
  13. /**
  14. * Access the number value.
  15. *
  16. * @method
  17. * @return {number} returns the wrapped double number.
  18. */
  19. Double.prototype.valueOf = function() {
  20. return this.value;
  21. };
  22. /**
  23. * @ignore
  24. */
  25. Double.prototype.toJSON = function() {
  26. return this.value;
  27. };
  28. module.exports = Double;
  29. module.exports.Double = Double;