UNPKG

pubchem

Version:

pubchem simplifies the data retrieval from the PubChem API.

12 lines (11 loc) 337 B
export function checkCompoundsResult(compounds: any[]) { if (!Array.isArray(compounds) || compounds.length === 0) { throw new Error('No compound found'); } if (compounds.length !== 1) { throw new Error('More than one compound found'); } if (!('id' in compounds[0].id)) { throw new Error('No compound found'); } }