Skip to content

Main content

Convert Data Rate Source Code

Browse the implementation files for Convert Data Rate.
@tool.io/tools/convert/data-rate source ↗
tool.ts typescript
import { convertDataRate as convertPortableDataRate } from '@tool.io/tools/convert/data-rate';
import { measureFactorOptions } from '../tool';
import { measureFactors } from './factors';

export const convertDataRate = (
	value: number,
	from: string,
	to: string
) => convertPortableDataRate(value, from, to) ?? '';

export const Tool: TypeTool = {
	name: 'Convert Data Rate',
	slug: 'convert/data-rate',
	tool: convertDataRate,
	intro:
		'Convert transfer rates between bits and bytes per second using distinct decimal SI and binary IEC units.',
	i: [
		{
			example: '100',
			label: 'Value',
			placeholder: '100',
			type: 'number'
		},
		{
			example: 'Mb/s',
			label: 'From',
			placeholder: 'Select the source data-rate unit',
			options: measureFactorOptions(measureFactors, 'Mb/s'),
			type: 'select',
			value: 'Mb/s'
		},
		{
			example: 'MB/s',
			label: 'To',
			placeholder: 'Select the destination data-rate unit',
			options: measureFactorOptions(measureFactors, 'MB/s'),
			type: 'select',
			value: 'MB/s'
		}
	],
	o: [
		{
			example: '12.5',
			label: 'Data rate',
			placeholder: 'Converted data rate',
			render: 'textarea',
			type: 'number'
		}
	],
	swap: {
		inputs: [1, 2],
		name: 'Swap data-rate units',
		state: false
	},
	alternative: [
		{
			title: 'Convert digital storage',
			url: '/convert/digital-storage'
		},
		{ title: 'Convert time', url: '/convert/time' }
	],
	cite: [
		{
			title: 'SI Brochure — BIPM',
			url: 'https://www.bipm.org/en/publications/si-brochure'
		},
		{
			title: 'Binary prefixes — IEC',
			url: 'https://www.iec.ch/prefixes-binary-multiples'
		}
	]
};

export default Tool;

Description

Browse the implementation files for Convert Data Rate.

References

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

Similar or alternative tools