<commit_before>/*!
 * image-size-promise | MIT (c) <NAME>
 * https://github.com/shinnn/image-size-stream
*/
'use strict';

var got = require('got');
var imageSizeStream = require('image-size-stream');
var wrapPromise = require('wrap-promise');

module.exports = function httpImageSizePromise(url, options) {
  var size = imageSizeStream(options);

  return wrapPromise(function(resolve, reject) {
    size
      .on('error', reject)
      .on('size', resolve);

    got(url, options)
      .on('error', reject)
      .pipe(size);
  });
};<commit_msg>explicitly destroy the streams<commit_after>/*!
 * image-size-promise | MIT (c) <NAME>
 * https://github.com/shinnn/image-size-stream
*/
'use strict';

var got = require('got');
var imageSizeStream = require('image-size-stream');
var wrapPromise = require('wrap-promise');

module.exports = function httpImageSizePromise(url, options) {
  var proxy;
  var size = imageSizeStream(options);

  return wrapPromise(function(resolve, reject) {
    size
      .on('error', function(err) {
        proxy.destroy();
        reject(err);
      })
      .on('size', function(dimensions) {
        proxy.destroy();
        resolve(dimensions);
      });

    proxy = got(url, options)
      .on('error', reject)
      .pipe(size);
  });
};
{'fraction_non_alphanumeric': 0.1674491392801252, 'fraction_numerical': 0.0, 'mean_word_length': 3.4409722222222223, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '5051295', 'n_tokens_mistral': 405, 'n_tokens_neox': 400, 'n_words': 84}