Unit of Measure Conversion Library

前端 未结 8 2172
面向向阳花
面向向阳花 2020-12-07 15:15

What is the best/most elegant way to abstract out the conversion of units of measures in the client, based on a user-preferred unit of measure setting?

For example,

8条回答
  •  无人及你
    2020-12-07 15:35

    A popular utility that lets you convert between different units: convert-units

    Usage example, converting imperial inches to metric cm:

    var convert = require('convert-units')
    convert(1).from('in').to('cm') // 2.54 
    

    To install:

    npm install convert-units
    

提交回复
热议问题