Bookmark this: tool.io/convert/volume/source-code
Convert Volume Source Code
Browse the implementation files for Convert Volume.tool.ts typescript
import { convertVolume as convertPortableVolume } from '@tool.io/tools/convert/volume';
import { measureFactorOptions } from '../tool';
import { measureFactors } from './factors';
// Tool: convert/volume
export const convertVolume = (
fromValue: number,
from: string,
to: string
) => convertPortableVolume(fromValue, from, to) ?? '';
export const Tool: TypeTool = {
name: 'Convert Volume',
slug: 'convert/volume',
tool: convertVolume,
intro:
'Convert volume values such as liter to pint (US) or gallon (Imperial) (l to pt, pt to imppt).',
i: [
{
example: '10',
label: 'Value',
placeholder: '10',
type: 'number'
},
{
example: 'pt',
label: 'From',
options: measureFactorOptions(measureFactors, 'pt'),
placeholder: 'Select the source volume unit',
type: 'select',
value: 'pt'
},
{
example: 'l',
label: 'To',
options: measureFactorOptions(measureFactors, 'l'),
placeholder: 'Select the destination volume unit',
type: 'select',
value: 'l'
}
],
o: [
{
example: '4.73176473',
label: 'Volume',
placeholder: 'Volume in liter',
render: 'textarea',
type: 'number'
}
],
swap: {
inputs: [1, 2],
name: 'Swap volume units',
state: false
},
alternative: [
{
title: 'Convert area',
url: '/convert/area'
},
{
title: 'Convert length',
url: '/convert/length'
}
],
cite: [
{
title: 'Volume - Wikipedia',
url: 'https://en.wikipedia.org/wiki/Volume'
}
]
};
export default Tool;
Description
Browse the implementation files for Convert Volume.