{"version":3,"file":"sdf-creator.umd.min.js","sources":["../lib/index.js"],"sourcesContent":["/**\n * Converts an array of objects containing molfile to a SDF string.\n * @param molecules - Array of molecule objects with molfile and properties.\n * @param options - Options to create the SDF.\n * @returns An object with the generated SDF string and the time taken.\n */\nexport function create(molecules, options = {}) {\n    const { molfilePropertyName = 'molfile', eol = '\\n', filter = /.*/, strict = false, } = options;\n    const emptyMolfile = 'empty.mol\\n  Spectrum generator\\n\\n  0  0  0  0  0  0  0  0  0  0999 V2000\\nM  END\\n';\n    const start = Date.now();\n    function normaliseMolfile(molfile) {\n        if (!molfile) {\n            if (strict)\n                throw new Error('Array containing emtpy molfiles');\n            molfile = emptyMolfile;\n        }\n        let molfileEOL = '\\n';\n        if (molfile.includes('\\r\\n')) {\n            molfileEOL = '\\r\\n';\n        }\n        else if (molfile.includes('\\r')) {\n            molfileEOL = '\\r';\n        }\n        const lines = molfile.replace(/[\\r\\n]+$/, '').split(molfileEOL);\n        return lines.join(eol);\n    }\n    const result = [];\n    for (const molecule of molecules) {\n        result.push(normaliseMolfile(molecule[molfilePropertyName]));\n        for (const key in molecule) {\n            const value = molecule[key];\n            if (key !== molfilePropertyName &&\n                (!filter || key.match(filter)) &&\n                value) {\n                result.push(`>  <${key}>`, value + eol);\n            }\n        }\n        result.push('$$$$');\n    }\n    const sdf = result.join(eol);\n    return {\n        time: Date.now() - start,\n        sdf,\n    };\n}\n//# sourceMappingURL=index.js.map"],"names":["molecules","options","molfilePropertyName","eol","filter","strict","start","Date","now","normaliseMolfile","molfile","Error","molfileEOL","includes","replace","split","join","result","molecule","push","key","value","match","sdf","time"],"mappings":";0PAoCM,SACJA,EACAC,EAAyB,IAEzB,MAAMC,oBACJA,EAAsB,UAASC,IAC/BA,EAAM,KAAIC,OACVA,EAAS,KAAIC,OACbA,GAAS,GACPJ,EAKEK,EAAQC,KAAKC,MAEnB,SAASC,EAAiBC,GACxB,IAAKA,EAAS,CACZ,GAAIL,EAAQ,MAAM,IAAIM,MAAM,mCAC5BD,EAPF,sFAQA,CACA,IAAIE,EAAa,KACbF,EAAQG,SAAS,QACnBD,EAAa,OACJF,EAAQG,SAAS,QAC1BD,EAAa,MAGf,OADcF,EAAQI,QAAQ,WAAY,IAAIC,MAAMH,GACvCI,KAAKb,EACpB,CAEA,MAAMc,EAAmB,GACzB,IAAK,MAAMC,KAAYlB,EAAW,CAChCiB,EAAOE,KAAKV,EAAiBS,EAAShB,KACtC,IAAK,MAAMkB,KAAOF,EAAU,CAC1B,MAAMG,EAAQH,EAASE,GAErBA,IAAQlB,GACNE,IAAUgB,EAAIE,MAAMlB,KACtBiB,GAEAJ,EAAOE,KAAK,OAAOC,KAAQC,EAAQlB,EAEvC,CACAc,EAAOE,KAAK,OACd,CACA,MAAMI,EAAMN,EAAOD,KAAKb,GAExB,MAAO,CACLqB,KAAMjB,KAAKC,MAAQF,EACnBiB,MAEJ"}