-
-
Notifications
You must be signed in to change notification settings - Fork 120
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
float is not parsed properly #97
Comments
Could you clarify how you think that the JS representation of the value |
we have a web page, users can edit their config then push it to target path |
The answer I was intending to give here was to use |
Actually, I'll need to refactor the tag object a bit to accommodate this. |
With the most recent change, we get this: const doc = YAML.parseDocument('foo: !!float 3.0')
String(doc) === 'foo: !!float 3\n' Effectively, I've made it so that explicit tags in the source correspond to explicit tags in the AST nodes, both when parsing as well as stringifying. I'm considering what -- if anything -- to do about the |
Closing this as fixed. When a non-scientific float is now parsed, if its value has const doc = YAML.parseDocument('foo: !!float 3.0\nbar: 4.20e3')
// In order to keep the explicit tag & minFractionDigits we need to fetch and
// modify the original node, rather than using set() to overwrite its value.
const float = doc.get('foo', true)
float.value = 30
String(doc)
// foo: !!float 30.0
// bar: 4.2e+3 Setting Exponential values now keep that form, but their fraction digits aren't remembered. This is due to needing to use Number#toExponential() to stringify them, as Intl.NumberFormat doesn't yet support them. |
my local version is 1.4.0
the case like this
YAML.parse("foo: !!float 3.0")
YAML.parse("foo: 3.0")
the result always is
{ foo: 3 }
the right result is not
{ foo: 3.0 }
?The text was updated successfully, but these errors were encountered: