journalize icon indicating copy to clipboard operation
journalize copied to clipboard

Support for a precision-based round/floor/ceil function

Open rdmurphy opened this issue 4 years ago • 0 comments

JavaScript has built-in functions for doing rounding calculations via the Math object. But what is missing is a way to supply a precision value to control where the rounding takes place in a number.

Lodash's version makes it possible to pass in a second parameter declaring the precision. Jinja2's filters also include a round() function that accepts a precision value and a flag for which rounding logic to use. And because Jinja2 does it, so does Nunjucks. (This does mean that Nunjucks doesn't technically need this enhancement.)

And while the logic to do this isn't complicated it's maybe just annoying enough to re-find/copy in that this would be helpful.

rdmurphy avatar Jun 30 '20 19:06 rdmurphy