UNPKG

pubchem

Version:

pubchem simplifies the data retrieval from the PubChem API.

20 lines 732 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.compoundDataFromCID = compoundDataFromCID; const CompoundData_js_1 = require("../CompoundData.js"); 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_js_1.CompoundData(compoundData); } //# sourceMappingURL=compoundDataFromCID.js.map