pretty-imperial
Parse, convert, and humanize imperial sizes
Last updated 6 months ago by stevelacy .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install pretty-imperial 
SYNC missed versions from official npm registry.

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)

Current Tags

  • 2.0.0                                ...           latest (6 months ago)

3 Versions

  • 2.0.0                                ...           6 months ago
  • 1.0.1                                ...           8 months ago
  • 1.0.0                                ...           9 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |