number-trimmer
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 placesvar bigDataSet = foo: 'foo' // non-number types are ignored bar: 23142145124 foobar: 1214123123 //... etc; //trimmed to N placesvar trimmed = bigDataSet 2;
Usage
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.
License
MIT, see LICENSE.md for details.