pretty-imperial

3.0.1 • Public • Published

pretty-imperial Build Status

Parse, convert, and humanize imperial sizes

Install

$ npm install pretty-imperial

Usage

const prettyImperial = require('pretty-imperial')

prettyImperial(15000).humanize()
// => 2.84mi

prettyImperial(.5).humanize()
// => 6in

// Using input types
prettyImperial(120).input('in').humanize()
// => 10ft

Functions

.mi(), .ft(), .in()

Converts the input measurement to the corresponding output

Default input measurement type is foot. It can be changed with .input()

prettyImperial(1).in()
// => 0.12ft

humanize()

Converts the input value to a more human recognizable size

prettyImperial(120).humanize()
// => 120ft

input()

Sets the input value to a particular imperial type

This can be chained with humanize()

prettyImperial(1500).input('in').ft()
// => 125ft

Supported sizes

mi: mile  - 5280ft
ft: foot - 12in
in: inch - 1/12ft

License (MIT)

Package Sidebar

Install

npm i pretty-imperial

Weekly Downloads

4

Version

3.0.1

License

MIT

Unpacked Size

9.28 kB

Total Files

7

Last publish

Collaborators

  • stevelacy
  • yocontra