Skip to content

Main content

Range Calculator Source Code

Browse the implementation files for Range Calculator.
@tool.io/tools/statistics/range source ↗
tool.ts typescript
import { runRange } from '@tool.io/tools/statistics/range';
import { parseFiniteNumberList } from '../../parse/numeric-dataset/tool';

export const range = (input: unknown): string => {
  const values = parseFiniteNumberList(input);
  if (!values) return '';
  const result = runRange({ values });
  return result.ok ? String(result.output.range) : '';
};

export const Tool = {
  name: 'Range',
  slug: 'statistics/range',
  intro: 'Calculate the range of a list of numbers (max - min).',
  tool: range,
  i: [
    {
      example: '2,10,21,23,23,38,38',
      help: 'Enter comma separated numbers.',
      label: 'Numbers',
      placeholder: 'e.g., 1,2,3',
      type: 'text',
      render: 'textarea'
    }
  ],
  o: [
    {
      example: '36',
      help: 'Range value.',
      label: 'Range',
      placeholder: 'Result will appear here...',
      type: 'text',
      render: 'textarea'
    }
  ],
  equation: '$$ Range(\{numbers}) = max - min $$',
};

export default Tool;

Description

Browse the implementation files for Range Calculator.

References

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

Similar or alternative tools