<commit_before>'use strict';

import API from 'src/util/api';

module.exports = async function loadZips(zipURLs, options = {}) {
    const JSZip = await API.require('jszip');
    const superagent = await API.require('superagent');
    const SD = await API.require('https://www.lactame.com/lib/spectra-data/3.0.7/spectra-data.min.js');
    var jszip = new JSZip();
    var spectraDataSet = [];
    for (let zipURL of zipURLs) {
        let zipFiles = await superagent.get(zipURL)
            .withCredentials()
            .responseType('blob');
        var zip = await jszip.loadAsync(zipFiles.body);
        let filesToProcess = Object.keys(zip.files).filter( filename => filename.match(/jdx$/));
        for (const filename of filesToProcess) {
            let jcamp = await zip.files[filename].async('string');
            let sd = SD.NMR.fromJcamp(jcamp, {});
            sd.sd.filename = filename.replace(/.jdx$/,'');
            if (options.filter) options.filter(spectrum.sd);
            spectraDataSet.push(spectrum);
        }
    }
    return spectraDataSet;
}<commit_msg>fix loadJcampZip<commit_after>'use strict';

import API from 'src/util/api';

module.exports = async function loadZips(zipURLs, options = {}) {
    const JSZip = await API.require('jszip');
    const superagent = await API.require('superagent');
    const SD = await API.require('https://www.lactame.com/lib/spectra-data/3.0.7/spectra-data.min.js');
    var jszip = new JSZip();
    var spectraDataSet = [];
    for (let zipURL of zipURLs) {
        let zipFiles = await superagent.get(zipURL)
            .withCredentials()
            .responseType('blob');
        var zip = await jszip.loadAsync(zipFiles.body);
        let filesToProcess = Object.keys(zip.files).filter( filename => filename.match(/jdx$/));
        for (const filename of filesToProcess) {
            let jcamp = await zip.files[filename].async('string');
            let spectrum = SD.NMR.fromJcamp(jcamp, {});
            spectrum.sd.filename = filename.replace(/.jdx$/,'');
            if (options.filter) options.filter(spectrum.sd);
            spectraDataSet.push(spectrum);
        }
    }
    return spectraDataSet;
}
{'fraction_non_alphanumeric': 0.14213663457129758, 'fraction_numerical': 0.002751031636863824, 'mean_word_length': 2.698305084745763, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4984124', 'n_tokens_mistral': 664, 'n_tokens_neox': 653, 'n_words': 139}