ES6 longitud conversor de unidades-convertir-longitud

Tiempo de ejecución: 30 minutos. Empezar

Autor: mattdesl
Views Total: 387
Sitio oficial: Ir a la web
Actualizado: August 10, 2018
Licencia: MIT

Vista prévia

ES6 longitud conversor de unidades-convertir-longitud

Descripción

Convert-length es un converso de unidad de longitud rápida escrito en ES6 que hace que sea fácil convertir entre unidades de longitud como mm, cm, m, PC, PT, in, ft, PX.

Funcionamiento

Instale la longitud de conversión con NPM.

# NPM
$ npm install convert-length --save

Importar & inicializar la longitud de conversión.

const convert = require('convert-length');

La sintaxis para convertir la unidad de longitud a otra:

result = convert(value, fromUnit, toUnit, options)

Opciones disponibles con valores predeterminados.

{


 // the number of pixels in one inch

// used when converting to and from "px" units

pixelsPerInch: 96,


// precision: 3 will round to 0.001

precision: null,


//
If enabled, when converting to a "px" unit the return value will be rounded to a whole pixel.

 // If disabled, the conversion will instead round to the specified Nth precision decimal (or no rounding if precision is not specified).

roundPixel: false

}

Te puede interesar: