Simple way of trimming all numbers types in an object to the given number of decimal places. Defaults to 4 decimal places.
//your data with lots of decimal places
var bigDataSet = {
foo: 'foo', // non-number types are ignored
bar: 23.142145124,
foobar: 12.14123123,
//... etc
};
//trimmed to N places
var trimmed = require('number-trimmer')(bigDataSet, 2);
trim( data, numPlaces )
If data is a number, it will be trimmed as per usual. Otherwise, we will assume it's an object or array, and traverse it entirely to trim all number types in it. If numPlaces is not specified, it defaults to 4.
MIT, see LICENSE.md for details.