ChemPal Documentation - v1.6.0
    Preparing search index...
    • Type guard to validate if a value is a PubChem Compound ID (a positive integer). Numeric strings are accepted and coerced before validation.

      Parameters

      • value: unknown

        The value to validate

      Returns value is PubChemCID

      Type predicate indicating if the value is a valid PubChem CID

      isPubChemCID(11413) // Returns true
      isPubChemCID("11413") // Returns true
      isPubChemCID(0) // Returns false
      isPubChemCID("abc") // Returns false
      export function isPubChemCID(value: unknown): value is PubChemCID {
      if (typeof value !== 'number' && typeof value !== 'string') return false;
      const num = typeof value === 'string' ? Number(value) : value;
      return Number.isInteger(num) && num > 0;
      }