JSPM

round-to-decimal

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7
  • Score
    100M100P100Q35174F
  • License ISC

A small javascript library to convert value to fixed decimal points if necessary

Package Exports

  • round-to-decimal

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (round-to-decimal) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

round-to-decimal

A small javascript library to round a number to dynamic decimal points

This is to overcome a corner case in javascript toFixed() method which always have decimal points even if number is rounded off with no decimal point. e.g. 2.toFixed(2) => 2.00

installation

npm i --save round-to-decimal

Usage

const toDecimals = require('round-to-decimal');

const num = toDecimals(1.00, 2)); // num is 1 const num = toDecimals(1.13412, 3)); // num is 1.134

About

toDecimals function takes two arguments -> toDecimals(value, decimalPoint)