<commit_before>import axios from "axios";
import Feedparser from "feedparser";
import stringToStream from "string-to-stream";

export default function feedParse(url) {
  var feedparser = new Feedparser();
  return axios({ method: "get", url: url, timeout: 3000 })
    .then(res => {
      // res.data.pipe(feedparser);
      stringToStream(res.data).pipe(feedparser);
    })
    .then(() => {
      var promise = new Promise((resolve, reject) => {
        let items = [];
        feedparser.on("readable", function() {
          var stream = this;
          var item;
          while ((item = stream.read())) {
            items.push(item);
          }
        });

        feedparser.on("end", () => {
          resolve(items);
        });

        feedparser.on("error", err => {
          reject(err);
        });
      });

      return Promise.all([promise])
        .then(feed => {
          return feed[0];
        })
        .catch(err => {
          throw err;
        });
    })
    .catch(e => {
      throw new Error();
    });
}
<commit_msg>fix feedParseUtil test<commit_after>import axios from "axios";
import Feedparser from "feedparser";
import stringToStream from "string-to-stream";

export default function feedParse(url) {
  var feedparser = new Feedparser();
  return axios({ method: "get", url: url, timeout: 3000 })
    .then(res => {
      stringToStream(res.data).pipe(feedparser);
    })
    .then(() => {
      var promise = new Promise((resolve, reject) => {
        let items = [];
        feedparser.on("readable", function() {
          var stream = this;
          var item;
          while ((item = stream.read())) {
            items.push(item);
          }
        });

        feedparser.on("end", () => {
          resolve(items);
        });

        feedparser.on("error", err => {
          reject(err);
        });
      });

      return Promise.all([promise])
        .then(feed => {
          return feed[0];
        })
        .catch(err => {
          throw err;
        });
    })
    .catch(e => {
      throw new Error();
    });
}

{'fraction_non_alphanumeric': 0.16098029793368573, 'fraction_numerical': 0.004805382027871216, 'mean_word_length': 1.824966078697422, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6521601', 'n_tokens_mistral': 621, 'n_tokens_neox': 600, 'n_words': 135}