Bookmark this: tool.io/convert/amount-of-substance/source-code
Convert Amount of Substance Source Code
Browse the implementation files for Convert Amount of Substance.tool.ts typescript
import { convertAmountOfSubstance as convertPortableAmountOfSubstance } from '@tool.io/tools/convert/amount-of-substance';
import { measureFactorOptions } from '../tool';
import { measureFactors } from './factors';
export const convertAmountOfSubstance = (
value: number,
from: string,
to: string
) => convertPortableAmountOfSubstance(value, from, to) ?? '';
export const Tool: TypeTool = {
name: 'Convert Amount of Substance',
slug: 'convert/amount-of-substance',
tool: convertAmountOfSubstance,
intro:
'Convert amount of substance across every current SI prefix for the mole.',
i: [
{
example: '1',
label: 'Value',
placeholder: '1',
type: 'number'
},
{
example: 'mol',
label: 'From',
placeholder: 'Select the source amount unit',
options: measureFactorOptions(measureFactors, 'mol'),
type: 'select',
value: 'mol'
},
{
example: 'mmol',
label: 'To',
placeholder: 'Select the destination amount unit',
options: measureFactorOptions(measureFactors, 'mmol'),
type: 'select',
value: 'mmol'
}
],
o: [
{
example: '1000',
label: 'Amount of substance',
placeholder: 'Converted amount',
render: 'textarea',
type: 'number'
}
],
swap: {
inputs: [1, 2],
name: 'Swap amount units',
state: false
},
alternative: [
{ title: 'Convert mass', url: '/convert/mass' }
],
cite: [
{
title: 'SI base units — BIPM',
url: 'https://www.bipm.org/en/measurement-units/si-base-units'
}
]
};
export default Tool;
Description
Browse the implementation files for Convert Amount of Substance.