diff --git a/README.md b/README.md index cbb030a3..f4dc8098 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ The [smallest](https://bundlephobia.com/result?p=convert) & [fastest](https://github.com/pizzafox/js-unit-conversion-benchmarks) library for really easy, totally type-safe unit conversions in TypeScript & JavaScript. -[![bundlephobia](https://bundlephobia.com/api/stats-image?name=convert&version=1.1.2&wide=true)](https://bundlephobia.com/result?p=convert) +[![bundlephobia](https://bundlephobia.com/api/stats-image?name=convert&version=1.1.4&wide=true)](https://bundlephobia.com/result?p=convert) [![Codecov](https://img.shields.io/codecov/c/gh/pizzafox/convert)](https://codecov.io/gh/pizzafox/convert) ```sh diff --git a/src/conversions/volume.ts b/src/conversions/volume.ts index 3412d227..4bdf57d1 100644 --- a/src/conversions/volume.ts +++ b/src/conversions/volume.ts @@ -41,13 +41,13 @@ export const volume = { 'dm³': ratioer(1e-1), dm3: ratioer(1e-1), - 'cubic centimeter': ratioer(1e-2), - 'cubic centimetre': ratioer(1e-2), - 'cubic centimeters': ratioer(1e-2), - 'cubic centimetres': ratioer(1e-2), - 'cm³': ratioer(1e-2), - cc: ratioer(1e-2), - cm3: ratioer(1e-2), + 'cubic centimeter': ratioer(1e-6), + 'cubic centimetre': ratioer(1e-6), + 'cubic centimeters': ratioer(1e-6), + 'cubic centimetres': ratioer(1e-6), + 'cm³': ratioer(1e-6), + cc: ratioer(1e-6), + cm3: ratioer(1e-6), 'cubic millimeter': ratioer(1e-3), 'cubic millimetre': ratioer(1e-3), @@ -65,61 +65,61 @@ export const volume = { Gl: ratioer(1e6), GL: ratioer(1e6), - megaliter: ratioer(1e6), - megalitre: ratioer(1e6), - megaliters: ratioer(1e6), - megalitres: ratioer(1e6), - Ml: ratioer(1e6), - ML: ratioer(1e6), - - kiloliter: ratioer(1e3), - kilolitre: ratioer(1e3), - kiloliters: ratioer(1e3), - kilolitres: ratioer(1e3), - kl: ratioer(1e3), - kL: ratioer(1e3), - - hectoliter: ratioer(1e5), - hectolitre: ratioer(1e5), - hectoliters: ratioer(1e5), - hectolitres: ratioer(1e5), - hl: ratioer(1e5), - hL: ratioer(1e5), - - decaliter: ratioer(1e4), - decalitre: ratioer(1e4), - decaliters: ratioer(1e4), - decalitres: ratioer(1e4), - dal: ratioer(1e4), - daL: ratioer(1e4), - - liter: ratioer(0.001), - litre: ratioer(0.001), - liters: ratioer(0.001), - litres: ratioer(0.001), - l: ratioer(0.001), - L: ratioer(0.001), - - deciliter: ratioer(0.0001), - decilitre: ratioer(0.0001), - deciliters: ratioer(0.0001), - decilitres: ratioer(0.0001), - dl: ratioer(0.0001), - dL: ratioer(0.0001), - - centiliter: ratioer(1e5), - centilitre: ratioer(1e5), - centiliters: ratioer(1e5), - centilitres: ratioer(1e5), - cl: ratioer(1e5), - cL: ratioer(1e5), - - milliliter: ratioer(1e6), - millilitre: ratioer(1e6), - milliliters: ratioer(1e6), - millilitres: ratioer(1e6), - ml: ratioer(1e6), - mL: ratioer(1e6), + megaliter: ratioer(1e3), + megalitre: ratioer(1e3), + megaliters: ratioer(1e3), + megalitres: ratioer(1e3), + Ml: ratioer(1e3), + ML: ratioer(1e3), + + kiloliter: ratioer(1), + kilolitre: ratioer(1), + kiloliters: ratioer(1), + kilolitres: ratioer(1), + kl: ratioer(1), + kL: ratioer(1), + + hectoliter: ratioer(1e-1), + hectolitre: ratioer(1e-1), + hectoliters: ratioer(1e-1), + hectolitres: ratioer(1e-1), + hl: ratioer(1e-1), + hL: ratioer(1e-1), + + decaliter: ratioer(1e-2), + decalitre: ratioer(1e-2), + decaliters: ratioer(1e-2), + decalitres: ratioer(1e-2), + dal: ratioer(1e-2), + daL: ratioer(1e-2), + + liter: ratioer(1e-3), + litre: ratioer(1e-3), + liters: ratioer(1e-3), + litres: ratioer(1e-3), + l: ratioer(1e-3), + L: ratioer(1e-3), + + deciliter: ratioer(1e-4), + decilitre: ratioer(1e-4), + deciliters: ratioer(1e-4), + decilitres: ratioer(1e-4), + dl: ratioer(1e-4), + dL: ratioer(1e-4), + + centiliter: ratioer(1e-5), + centilitre: ratioer(1e-5), + centiliters: ratioer(1e-5), + centilitres: ratioer(1e-5), + cl: ratioer(1e-5), + cL: ratioer(1e-5), + + milliliter: ratioer(1e-6), + millilitre: ratioer(1e-6), + milliliters: ratioer(1e-6), + millilitres: ratioer(1e-6), + ml: ratioer(1e-6), + mL: ratioer(1e-6), microliter: ratioer(1e9), microlitre: ratioer(1e9), @@ -161,11 +161,11 @@ export const volume = { 'board foot': ratioer(0.002359737), 'board feet': ratioer(0.002359737), - 'cubic inch': ratioer(1.6e-1), - 'cubic inches': ratioer(1.6e-1), - 'cu in': ratioer(1.6e-1), - cuin: ratioer(1.6e-1), - in3: ratioer(1.6e-1), + 'cubic inch': ratioer(0.000016387064), + 'cubic inches': ratioer(0.000016387064), + 'cu in': ratioer(0.000016387064), + cuin: ratioer(0.000016387064), + in3: ratioer(0.000016387064), 'measurement ton': ratioer(1.133), 'measurement tons': ratioer(1.133), @@ -197,30 +197,30 @@ export const volume = { pk: ratioer(0.00909218), imppk: ratioer(0.00909218), - 'imperial quart': ratioer(0.0011365225e12), - 'imperial quarts': ratioer(0.0011365225e12), - 'imp qt': ratioer(0.0011365225e12), - impqt: ratioer(0.0011365225e12), - - 'imperial gallon': ratioer(0.00454609e12), - 'imperial gallons': ratioer(0.00454609e12), - 'imp gal': ratioer(0.00454609e12), - impgal: ratioer(0.00454609e12), - - 'imperial pint': ratioer(0.00056826125e12), - 'imperial pints': ratioer(0.00056826125e12), - 'imp pt': ratioer(0.00056826125e12), - imppt: ratioer(0.00056826125e12), - - gill: ratioer(0.0001420653125e12), - gills: ratioer(0.0001420653125e12), - gi: ratioer(0.0001420653125e12), - impgi: ratioer(0.0001420653125e12), - - 'imperial fluid ounce': ratioer(2.84130625e7), - 'imperial fluid ounces': ratioer(2.84130625e7), - 'imp fl oz': ratioer(2.84130625e7), - impoz: ratioer(2.84130625e7), + 'imperial quart': ratioer(0.0011365225), + 'imperial quarts': ratioer(0.0011365225), + 'imp qt': ratioer(0.0011365225), + impqt: ratioer(0.0011365225), + + 'imperial gallon': ratioer(0.00454609), + 'imperial gallons': ratioer(0.00454609), + 'imp gal': ratioer(0.00454609), + impgal: ratioer(0.00454609), + + 'imperial pint': ratioer(0.00056826125), + 'imperial pints': ratioer(0.00056826125), + 'imp pt': ratioer(0.00056826125), + imppt: ratioer(0.00056826125), + + gill: ratioer(0.0001420653125), + gills: ratioer(0.0001420653125), + gi: ratioer(0.0001420653125), + impgi: ratioer(0.0001420653125), + + 'imperial fluid ounce': ratioer(2.84130625e-5), + 'imperial fluid ounces': ratioer(2.84130625e-5), + 'imp fl oz': ratioer(2.84130625e-5), + impoz: ratioer(2.84130625e-5), //#endregion //#region US customary liquid measure @@ -259,29 +259,29 @@ export const volume = { usqt: ratioer(9.46352946e-4), 'U.S.qt': ratioer(9.46352946e-4), - 'US pint': ratioer(4.73176473e8), - 'US pints': ratioer(4.73176473e8), - 'US pt': ratioer(4.73176473e8), - 'U.S. pt': ratioer(4.73176473e8), - USpt: ratioer(4.73176473e8), - uspt: ratioer(4.73176473e8), - 'U.S.pt': ratioer(4.73176473e8), - - 'US gill': ratioer(1.18e8), - 'US gills': ratioer(1.18e8), - USgi: ratioer(1.18e8), - usgi: ratioer(1.18e8), - 'U.S.gi': ratioer(1.18e8), - - 'US fluid ounce': ratioer(29.5735295625e6), - 'US fluid ounces': ratioer(29.5735295625e6), - 'US fl oz': ratioer(29.5735295625e6), - USoz: ratioer(29.5735295625e6), - USflox: ratioer(29.5735295625e6), - usoz: ratioer(29.5735295625e6), - usfloz: ratioer(29.5735295625e6), - 'U.S.oz': ratioer(29.5735295625e6), - 'U.S.floz': ratioer(29.5735295625e6), + 'US pint': ratioer(4.73176473e-4), + 'US pints': ratioer(4.73176473e-4), + 'US pt': ratioer(4.73176473e-4), + 'U.S. pt': ratioer(4.73176473e-4), + USpt: ratioer(4.73176473e-4), + uspt: ratioer(4.73176473e-4), + 'U.S.pt': ratioer(4.73176473e-4), + + 'US gill': ratioer(1.18e-4), + 'US gills': ratioer(1.18e-4), + USgi: ratioer(1.18e-4), + usgi: ratioer(1.18e-4), + 'U.S.gi': ratioer(1.18e-4), + + 'US fluid ounce': ratioer(29.5735295625e-6), + 'US fluid ounces': ratioer(29.5735295625e-6), + 'US fl oz': ratioer(29.5735295625e-6), + USoz: ratioer(29.5735295625e-6), + USflox: ratioer(29.5735295625e-6), + usoz: ratioer(29.5735295625e-6), + usfloz: ratioer(29.5735295625e-6), + 'U.S.oz': ratioer(29.5735295625e-6), + 'U.S.floz': ratioer(29.5735295625e-6), //#endregion //#region US customary dry measure diff --git a/test/conversions/volume.test.ts b/test/conversions/volume.test.ts index 1cb24310..cebeab77 100644 --- a/test/conversions/volume.test.ts +++ b/test/conversions/volume.test.ts @@ -1,18 +1,27 @@ import {convertAssert} from '../util'; describe('volume', () => { + convertAssert(1, 'gigaliter', 1e9, 'liter'); + convertAssert(1, 'megaliter', 1e6, 'liter'); + convertAssert(1, 'kiloliter', 1e3, 'liter'); + convertAssert(1, 'hectoliter', 1e2, 'liter'); + convertAssert(1, 'decaliter', 1e1, 'liter'); + convertAssert(1, 'liter', 1e-3, 'm3'); + convertAssert(1, 'deciliter', 1e-1, 'liter'); + convertAssert(1, 'centiliter', 1e-2, 'liter'); + convertAssert(1, 'milliliter', 1e-3, 'liter'); + convertAssert(1, 'cubic kilometre', 0.24, 'cu mi', true); convertAssert(1, 'cubic metre', 1, 'cubic metre'); convertAssert(1, 'acre-foot', 1233.48183754752, 'm3', true); convertAssert(1, 'cubic mile', 4.2, 'km3'); - convertAssert(1, 'gigalitre', 1e9, 'liter'); - convertAssert(1000, 'liter', 1, 'm3'); - convertAssert(1, 'liter', 10, 'deciliters'); convertAssert(1, 'stere', 1, 'm3'); convertAssert(1, 'cubic yard', 0.76, 'm3'); convertAssert(1, 'cubic foot', 0.028, 'm3'); convertAssert(1, 'board foot', 0.002359737, 'm3'); - convertAssert(1, 'cubic inch', 16, 'cm3'); + convertAssert(1, 'liter', 61.0237440947323, 'in3', true); + convertAssert(1, 'cubic meter', 1e6, 'cm3'); + convertAssert(1, 'cubic inch', 16.387064, 'ml'); convertAssert(1, 'measurement ton', 1.133, 'm3'); convertAssert(6.2898, 'oilbbl', 1, 'm3', true); @@ -20,9 +29,9 @@ describe('volume', () => { convertAssert(1, 'US beer barrel', 117, 'liter'); convertAssert(264.1721, 'US gallons', 1, 'm3'); convertAssert(1, 'US quart', 0.946352946, 'l'); - convertAssert(1, 'US pint', 473.176473, 'ml'); + convertAssert(1, 'US pint', 473.176473, 'ml', true); convertAssert(1, 'US gill', 118, 'ml'); - convertAssert(1, 'US fluid ounce', 29.5735295625, 'ml'); + convertAssert(1, 'US fluid ounce', 29.5735295625, 'ml', true); convertAssert(1, 'US dry barrel', 0.12, 'm3'); convertAssert(1, 'US bushel', 35.2391, 'liters'); @@ -31,7 +40,7 @@ describe('volume', () => { convertAssert(1, 'US dry quart', 0.946352946, 'liters'); convertAssert(1, 'US dry pint', 33.6003125, 'm3'); - convertAssert(1, 'imperial fluid ounces', 28.4130625, 'ml'); + convertAssert(1, 'imperial fluid ounces', 28.4130625, 'ml', true); convertAssert(1, 'gill', 142.0653125, 'ml'); convertAssert(1, 'imperial pints', 568.26125, 'ml'); convertAssert(1, 'imperial quarts', 1136.5225, 'ml');