pubchem
Version:
pubchem simplifies the data retrieval from the PubChem API.
17 lines • 587 B
JavaScript
import { CompoundData } from '../CompoundData.js';
export async function compoundDataFromCID(cid, options = {}) {
const { cache } = options;
let compoundData;
if (cache?.(cid)) {
compoundData = cache(cid);
}
else {
const dataResponse = await fetch(`https://pubchem.ncbi.nlm.nih.gov/rest/pug_view/data/compound/${cid}/JSON`);
compoundData = (await dataResponse.json()).Record;
if (cache) {
cache(cid, compoundData);
}
}
return new CompoundData(compoundData);
}
//# sourceMappingURL=compoundDataFromCID.js.map