Created
July 1, 2016 10:36
-
-
Save ljank/9e3cb8552c97d511f1bc68d67f178b23 to your computer and use it in GitHub Desktop.
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
JSON.stringify(JSON.parse('{"int":1,"float1":1.1,"float2":2.0}')) | |
// '{"int":1,"float1":1.1,"float2":2}' | |
// ^ not float anymore :( | |
// even potentially useful npm packages are useless: | |
require("is-float")(1.0) // false | |
require("number-is-float")(1.0) // false | |
require('is-funcs/is-float')(1.0) // false | |
Number.isInteger(1.0) // true | |
// the reason is known: there's no Integer/Float class, only Number. | |
// But is there a way to avoid losing types, especially when there | |
// are other non-node.js services that expect to find floats in incoming | |
// JSON strings after node.js service have "touched" them? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment