Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kyrofa
Copy link

@kyrofa kyrofa commented Jan 21, 2022

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. 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.

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>"]],
Copy link
Contributor

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.

Copy link
Author

@kyrofa kyrofa Mar 18, 2022

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>"]],
Copy link
Contributor

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>"]],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quad? quint?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

js-quantities is incompatible with sugarjs and prototypejs
2 participants