-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(toFloat): verify the string can be safely converted to a float (#…
…1226) This is needed because parseFloat('2020-01-06T14:31:00.135Z') will return 2020, even though it should return NaN. This fixes an issue checking isDivisibleBy('2020-01-06T14:31:00.135Z', 2).
- Loading branch information
1 parent
ea39867
commit a77f767
Showing
3 changed files
with
7 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import assertString from './util/assertString'; | ||
import isFloat from './isFloat'; | ||
|
||
export default function toFloat(str) { | ||
assertString(str); | ||
if (!isFloat(str)) return NaN; | ||
|
||
return parseFloat(str); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters