UNPKG

pubchem

Version:

pubchem simplifies the data retrieval from the PubChem API.

36 lines 1.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Compound = void 0; const compoundDataFromCID_1 = require("../compoundData/from/compoundDataFromCID"); const compoundFromInchiKey_1 = require("./from/compoundFromInchiKey"); const compoundFromName_1 = require("./from/compoundFromName"); const compoundFromSmiles_1 = require("./from/compoundFromSmiles"); class Compound { constructor(data, options = {}) { this.data = data; this.cache = options.cache; } getCID() { return this.data?.id?.id?.cid; } getData() { const cid = this.getCID(); const cd = (0, compoundDataFromCID_1.compoundDataFromCID)(cid, { cache: this.cache }); return cd; } toJSON() { const methods = Object.entries(Object.getOwnPropertyDescriptors(Compound.prototype)) .filter(([, descriptor]) => typeof descriptor.get === 'function') .map(([key]) => key); const result = {}; for (const method of methods) { result[method] = this[method]; } return result; } } exports.Compound = Compound; Compound.fromSmiles = compoundFromSmiles_1.compoundFromSmiles; Compound.fromName = compoundFromName_1.compoundFromName; Compound.fromInchiKey = compoundFromInchiKey_1.compoundFromInchiKey; //# sourceMappingURL=Compound.js.map