remove-trailing-zeros

1.0.3 • Public • Published

Remove Trailing Zeros

NPM Version License Downloads

Remove extra zeros from the end of a string or number.

Performance benchmark: https://jsperf.com/remove-trailing-zeros

Installation

yarn add remove-trailing-zeros

Usage

import removeTrailingZeros from 'remove-trailing-zeros'

console.log('Are the same:', removeTrailingZeros('1,230.4000'')) // -> 1,230.4

Examples

1 -> 1
10 -> 10
100. -> 100
100.0 -> 100
100.1 -> 100.1
100.10 -> 100.1
100.01 -> 100.01
100.010 -> 100.01
'1.2304000' -> 1.2304
'1,000.000' -> 1,000

License

ISC

Changelog

  • 1.0.3 - Manually put in an AMD build - TODO: generate this
  • 1.0.2 - Removed let and used var instead, to stop build errors
  • 1.0.0 - Initial release

Package Sidebar

Install

npm i remove-trailing-zeros

Weekly Downloads

91

Version

1.0.3

License

ISC

Unpacked Size

9 kB

Total Files

7

Last publish

Collaborators

  • rekarnar