-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(NODE-6086): add Double.fromString() method #671
Conversation
* | ||
* @param value - the string we want to represent as an double. | ||
*/ | ||
static fromString(value: string): Double { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment here as on the Int32.fromString()
PR: can we throw descriptive errors for each case we're checking for in the if
statement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, on it
test/node/double.test.ts
Outdated
|
||
for (const [testName, value, expectedDouble] of acceptedInputs) { | ||
context(`when case is ${testName}`, () => { | ||
it(`should return Double that matches expected value`, () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here about test titles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just changed them, going to push after my tests run!
Description
Add static
Double.fromString()
method.What is changing?
Is there new documentation needed for these changes?
Yes, there are new API docs.
What is the motivation for this change?
NODE-3660 user ticket, our validation in the Double is lacking. In V7, we will add
Double.fromString(value)
validation call into theDouble
constructor'sstring
case.Release Highlight
Add static
Double.fromString
methodThis method attempts to create an
Double
type from a string, and will throw aBSONError
on any string input that is not representable as aIEEE-754 64-bit double
.Notably, this method will also throw on the following string formats:
'Infinity'
,'-Infinity'
, and'NaN'
input strings are still allowed)Strings with leading zeros, however, are also allowed.
Double check the following
npm run check:lint
scripttype(NODE-xxxx)[!]: description
feat(NODE-1234)!: rewriting everything in coffeescript