ChemPal Documentation - v1.6.0
    Preparing search index...

    Function purityGradeToPercentage

    • Converts a purity grade to a representative percentage.

      NOTE: chemical grades are specifications, not fixed purities — the real assay minimum for a given grade varies by chemical, and the lower grades (lab/pure/practical/technical) have no formally defined standard at all. These values are therefore representative figures chosen to rank grades in the correct order, intended only for sorting/comparison — not as assays. Ties within a tier are intentional (e.g. USP/BP/JP/NF are ~equivalent).

      Ordering follows the standard hierarchy (highest→lowest): HPLC > ACS > Reagent ≈ AR ≈ Guaranteed > USP ≈ BP ≈ JP ≈ NF > Pharma ≈ FCC > Cosmetic ≈ Extraction ≈ Lab > Pure ≈ Practical > Technical ≈ Industrial > Low > Impure

      Note "Impure" maps to 0, which is a value, not a miss — only "Ungraded" and unrecognised labels return undefined.

      Parameters

      • grade: string

        The grade label (as returned by parseGrade, e.g. "ACS Grade")

      Returns undefined | number

      A representative purity %, or undefined if unrecognised

      purityGradeToPercentage("ACS Grade")       // 99.8
      purityGradeToPercentage("USP Grade") // 99.5
      purityGradeToPercentage("Technical Grade") // 90
      purityGradeToPercentage("Impure") // 0
      purityGradeToPercentage("Ungraded") // undefined
      export const purityGradeToPercentage = (grade: string): number | undefined => {
      switch (grade) {
      // ── Instrumental / analytical: highest purity ──
      case 'HPLC Grade': // low interfering impurities; solvents typically ≥99.9%
      return 99.9;
      case 'ACS Grade': // meets/exceeds ACS reagent specs — top of the standard hierarchy
      return 99.8;
      case 'AR Grade': // Analytical Reagent — high purity, ≈ ACS
      case 'Guaranteed Grade': // "Guaranteed Reagent" (GR) — high purity, ≈ ACS
      case 'Reagent Grade': // almost as stringent as ACS
      return 99.7;

      // ── Pharmacopeia (food/drug-acceptable) ──
      case 'USP Grade': // meets US Pharmacopeia; equivalent to ACS for many drugs
      case 'BP Grade': // British Pharmacopoeia
      case 'JP Grade': // Japanese Pharmacopoeia
      case 'NF Grade': // National Formulary
      return 99.5;
      case 'Pharma Grade': // generic pharmaceutical
      case 'FCC Grade': // Food Chemicals Codex — food-safe
      return 99.0;

      // ── Intermediate: good quality, no strict assay floor ──
      case 'Cosmetic Grade':
      case 'Extraction Grade': // rough guess — not part of a formal purity hierarchy
      case 'Lab Grade': // high quality, exact impurities unknown; education use
      return 98.0;

      // ── No official standard ──
      case 'Pure Grade': // "pure"/"purified" — good quality, meets no official standard
      case 'Practical Grade': // same tier as purified
      return 95.0;

      // ── Commercial / industrial: lowest ──
      case 'Technical Grade': // industrial/processing use; not for food/drug
      case 'Industrial Grade':
      return 90.0;

      case 'Low Grade':
      return 50.0;

      case 'Impure':
      return 0.0;
      // "Ungraded" and anything unrecognised fall through to undefined.
      default:
      return undefined;
      }
      };