<commit_before>
var os = require('os')
var fs = require('mz/fs')
var path = require('path')
var lru = require('lru-cache')
var debug = require('debug')('polyfills')
var _polyfills = require('polyfills-db').polyfills.polyfills
var tmpdir = os.tmpdir
  ? os.tmpdir()
  : os.tmpDir()

var proto = require('./prototype')

var folder = path.resolve(tmpdir, 'polyfills')
debug('saving polyfills to folder: %s', folder)
require('mkdirp').sync(folder)

module.exports = function (options) {
  options = options || {}

  Polyfill.prototype = Object.create(proto)
  Polyfill.prototype.constructor = Polyfill

  // useragent -> build lookup
  Polyfill.prototype.dir = path.join(__dirname, '..', 'polyfills')
  Polyfill.prototype.cache = lru(({
    max: 1000,
    maxAge: 1000 * 60 * 60, // 1 hour just because
  }))

  // setup which polyfills to use
  var polyfills
  if (Array.isArray(options.include)) {
    polyfills = _polyfills.filter(function (polyfill) {
      return ~options.include.indexOf(polyfill.name)
        || ~options.include.indexOf(polyfill.shortName)<commit_msg>create a cache folder based on the current version<commit_after>
var os = require('os')
var fs = require('mz/fs')
var path = require('path')
var lru = require('lru-cache')
var debug = require('debug')('polyfills')
var _polyfills = require('polyfills-db').polyfills.polyfills
var tmpdir = os.tmpdir
  ? os.tmpdir()
  : os.tmpDir()

var proto = require('./prototype')

var folder = path.resolve(tmpdir, 'polyfills-' + require('../package.json').version)
debug('saving polyfills to folder: %s', folder)
require('mkdirp').sync(folder)

module.exports = function (options) {
  options = options || {}

  Polyfill.prototype = Object.create(proto)
  Polyfill.prototype.constructor = Polyfill

  // useragent -> build lookup
  Polyfill.prototype.dir = path.join(__dirname, '..', 'polyfills')
  Polyfill.prototype.cache = lru(({
    max: 1000,
    maxAge: 1000 * 60 * 60, // 1 hour just because
  }))

  // setup which polyfills to use
  var polyfills
  if (Array.isArray(options.include)) {
    polyfills = _polyfills.filter(function (polyfill) {
      return ~options.include.indexOf(polyfill.name)
        || ~options.include.indexOf(polyfill.shortName)
{'fraction_non_alphanumeric': 0.1509689049121226, 'fraction_numerical': 0.011716989634970707, 'mean_word_length': 4.150812064965197, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5722978', 'n_tokens_mistral': 756, 'n_tokens_neox': 691, 'n_words': 168}