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

[Rquest feature] Static methods for comparison #137

Closed
fspezi opened this issue Apr 2, 2020 · 2 comments
Closed

[Rquest feature] Static methods for comparison #137

fspezi opened this issue Apr 2, 2020 · 2 comments

Comments

@fspezi
Copy link

fspezi commented Apr 2, 2020

The library allow to execute a comparison between 2 Big values using the method of first one, and put the second as argument of method:

var a = Big(100);
var b = Big(5);
var areEquals = a.eq(b);

There are circustances where a and/or b can be nothing. Then a static comparison method versions are very useful.
Then instead of do this:

var areEquals = !a && !b
  ? true
  : !a || !b
    ? false
    : a.eq(b);

...it is possible to do this:

var areEquals = Big.eq(a, b);
@MikeMcl
Copy link
Owner

MikeMcl commented Apr 3, 2020

Yes, that could be useful.

I would probably go with

Big.eq = (a, b) => { try { return Big(a).eq(b) } catch { return false } };

But I don't want to add any further methods, thanks, static or otherwise.

@fspezi
Copy link
Author

fspezi commented Apr 4, 2020

Perfect, good!

Maybe, can a and b to be "equals" when they are "null" / "nothing" together?

@MikeMcl MikeMcl closed this as completed Aug 2, 2020
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

No branches or pull requests

2 participants