Skip to content

Main content

Convert Area Source Code

Browse the implementation files for Convert Area.
@tool.io/tools/convert/area source ↗
tool.ts typescript
import { convertArea as convertPortableArea } from '@tool.io/tools/convert/area';
import { measureFactorOptions } from '../tool';
import { measureFactors } from './factors';

// Tool: convert/area

export const convertArea = (
	fromValue: number,
	from: string,
	to: string
) => convertPortableArea(fromValue, from, to) ?? '';

export const Tool: TypeTool = {
	name: 'Convert Area',
	slug: 'convert/area',
	tool: convertArea,
	intro:
		'Convert area values such as square meters to square inches (sqm to sqin).',
	i: [
		{
			example: '1',
			label: 'Value',
			placeholder: '1',
			type: 'number'
		},
		{
			example: 'sqft',
			label: 'From',
			options: measureFactorOptions(measureFactors, 'sqft'),
			placeholder: 'Select the source area unit',
			type: 'select',
			value: 'sqft'
		},
		{
			example: 'sqm',
			label: 'To',
			options: measureFactorOptions(measureFactors, 'sqm'),
			placeholder: 'Select the destination area unit',
			type: 'select',
			value: 'sqm'
		}
	],
	o: [
		{
			example: '100',
			label: 'Area',
			placeholder: 'Area in sqm',
			render: 'textarea',
			type: 'number'
		}
	],
	swap: {
		inputs: [1, 2],
		name: 'Swap area units',
		state: false
	},
	alternative: [
		{
			title: 'Convert length',
			url: '/convert/length'
		},
		{
			title: 'Convert measure',
			url: '/convert'
		}
	],
	cite: [
		{
			title: 'Area - Wikipedia',
			url: 'https://en.wikipedia.org/wiki/Area'
		}
	]
};

export default Tool;

Description

Browse the implementation files for Convert Area.

References

  1. Tool.io on GitHub
  2. Tool.io TypeScript tools library

Similar or alternative tools