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

Return a new numeral on math operations #48

Closed
sobrinho opened this issue Feb 26, 2013 · 1 comment
Closed

Return a new numeral on math operations #48

sobrinho opened this issue Feb 26, 2013 · 1 comment

Comments

@sobrinho
Copy link

Hi,

Would be great to return a new numeral instance on math operations like this:

var value = numeral(100),
    discount = numeral(0);

return value.subtract(value.multiply(discount).divide(numeral(100)));

It will return 0 instead of 90 since the value.multiply(discount) will change the value instance to 0 instead of returning a new instance with 0.

The idea is to mutate the numeral instance only using numeral.fn.set instead of mutating the called instance.

WDYT?

@adamwdraper
Copy link
Owner

All other numeral functions manipulate the instance so I don't think these should act differently.

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