File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
2+
23/**
34 * A class representation of the BSON Double type.
45 */
@@ -41,16 +42,22 @@ class Double {
4142 if ( options && ( options . legacy || ( options . relaxed && isFinite ( this . value ) ) ) ) {
4243 return this . value ;
4344 }
44- return { $numberDouble : this . value . toString ( ) } ;
45+
46+ if ( Object . is ( Math . sign ( this . value ) , - 0 ) ) {
47+ return { $numberDouble : `-${ this . value . toFixed ( 1 ) } ` } ;
48+ }
49+
50+ return {
51+ $numberDouble : Number . isInteger ( this . value ) ? this . value . toFixed ( 1 ) : this . value . toString ( )
52+ } ;
4553 }
4654
4755 /**
4856 * @ignore
4957 */
5058 static fromExtendedJSON ( doc , options ) {
51- return options && options . relaxed
52- ? parseFloat ( doc . $numberDouble )
53- : new Double ( parseFloat ( doc . $numberDouble ) ) ;
59+ const doubleValue = parseFloat ( doc . $numberDouble ) ;
60+ return options && options . relaxed ? doubleValue : new Double ( doubleValue ) ;
5461 }
5562}
5663
You can’t perform that action at this time.
0 commit comments