-
Notifications
You must be signed in to change notification settings - Fork 103
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
format: stop relying on array properties #131
base: master
Are you sure you want to change the base?
format: stop relying on array properties #131
Conversation
There are numerous libraries out there (sugarjs, prototypejs) that extend the `Array` prototype. The `simplify` function in js-quantities relies on setting/checking properties on an array instance, which means that it's incompatible with such libraries. Add compatibility by using a separate object for keeping track of the counters instead of using properties on array instances. Fix gentooboontoo#130. Signed-off-by: Kyle Fazzari <[email protected]>
@@ -454,7 +454,9 @@ var UNITS = { | |||
"<dozen>" : [["doz","dz","dozen"],12.0,"prefix_only", ["<each>"]], | |||
"<percent>": [["%","percent"], 0.01, "prefix_only", ["<1>"]], | |||
"<ppm>" : [["ppm"],1e-6, "prefix_only", ["<1>"]], | |||
"<ppt>" : [["ppt"],1e-9, "prefix_only", ["<1>"]], | |||
"<ppb>" : [["ppb"],1e-9, "prefix_only", ["<1>"]], |
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.
These (beyond million) only make sense in the places like the US where 1 billion == 1 thousand million, not in places like the UK where 1 billion == 1 million million.
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.
Please ignore the generated files. I did not write this code, but they weren't .gitignored so I felt like I should include them. If you think there are issues here, you might consider logging one since these things were already here.
@@ -454,7 +454,9 @@ var UNITS = { | |||
"<dozen>" : [["doz","dz","dozen"],12.0,"prefix_only", ["<each>"]], | |||
"<percent>": [["%","percent"], 0.01, "prefix_only", ["<1>"]], | |||
"<ppm>" : [["ppm"],1e-6, "prefix_only", ["<1>"]], | |||
"<ppt>" : [["ppt"],1e-9, "prefix_only", ["<1>"]], | |||
"<ppb>" : [["ppb"],1e-9, "prefix_only", ["<1>"]], | |||
"<ppt>" : [["ppt"],1e-12, "prefix_only", ["<1>"]], |
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.
Another ambiguous term: parts per trillion or parts per thousand? (and if trillion: US trillion or UK trillion)
"<ppt>" : [["ppt"],1e-9, "prefix_only", ["<1>"]], | ||
"<ppb>" : [["ppb"],1e-9, "prefix_only", ["<1>"]], | ||
"<ppt>" : [["ppt"],1e-12, "prefix_only", ["<1>"]], | ||
"<ppq>" : [["ppq"],1e-15, "prefix_only", ["<1>"]], |
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.
quad? quint?
There are numerous libraries out there (sugarjs, prototypejs) that extend the
Array
prototype. Thesimplify
function in js-quantities relies on setting/checking properties on an array instance, which means that it's incompatible with such libraries. This PR fixes #130, adding compatibility by using a separate object for keeping track of the counters instead of using properties on array instances.Note: It was unclear whether I should be including changes to generated files. Please let me know if I should only be changing the src/spec files and I can update this PR.