number-trimmer

1.0.1 • Public • Published

browser support

number-trimmer

experimental

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);

Usage

NPM

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.

Package Sidebar

Install

npm i number-trimmer

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • mattdesl