@gladney/convert
v1.0.4
Published
Library to perform common conversion operations
Downloads
1
Maintainers
Readme
:left_right_arrow: @gladney/convert
Utility library that performs commonly needed conversions.
Helpful tips
- All methods that return numerical values can accept
{float: n}
as a parameter in the last method of the chain, where n is the number of float places. Example:
convertLength(2).miles().toKilometers() // 3.218688
convertLength(2).miles().toKilometers({ float: 2 }) // 3.22
convertLength(2).miles().toKilometers({ float: 0 }) // 3
Methods
convertString
String from one casing to another. Starting case is detected automatically.
Example:
convertCase("helloWorld").toPascalCase() // "HelloWorld"
convertTemperature
Temperature from/to Celsius/Fahrenheit Example:
convertTemperature(100).celsius().toFahrenheit() // 212
convertTemperature(32).fahrenheit().toCelsius() // 0
convertLength
Length from one unit to another (metric or imperial)
Example:
convertLength(2).miles().toKilometers() // 3.218688
convertTime
Length from one unit to another (metric or imperial)
Example:
convertTime(2).weeks().toMinutes() // 20160