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

js-quantities is incompatible with sugarjs and prototypejs #130

Open
kyrofa opened this issue Jan 21, 2022 · 0 comments · May be fixed by #131
Open

js-quantities is incompatible with sugarjs and prototypejs #130

kyrofa opened this issue Jan 21, 2022 · 0 comments · May be fixed by #131

Comments

@kyrofa
Copy link

kyrofa commented Jan 21, 2022

When simplifying numerators/denominators, js-quantities uses an array as both an array and an object, setting properties on it. This makes js-quantities incompatible with libraries that extend Array.prototype, like sugarjs and prototypejs, in very surprising ways. For example:

> q = Qty('100 gal/min');
> q.scalar
100
> q.units()
'gal/'
kyrofa added a commit to kyrofa/js-quantities that referenced this issue 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. 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]>
@kyrofa kyrofa linked a pull request Jan 21, 2022 that will close this issue
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 a pull request may close this issue.

1 participant