<commit_before>import fs from "fs"
import path from "path"
import eachOf from "async/eachOf"
import readJson from "read-package-json"

function readDir(dirName)
{
  try
  {
    return fs.readdirSync(dirName)
  }
  catch (e)
  {
    return []
  }
}

const root = "node_modules"
const nodeModules = readDir(root).filter((dirname) => dirname.charAt(0) !== ".")

const modules = {}
eachOf(nodeModules, (pkg, pos, callback) =>
{
  readJson(path.resolve(root, pkg, "package.json"), function(err, json)
  {
    if (err)
    {
      callback()
    }
    else if (json["jsnext:main"] || json["module"])
    {
      modules[pkg] = true
      callback();
    }
    else
    {
      callback();
    }
  })
},
function(err, results) {
  console.log("Packages with ES Modules:", modules)
})

export default modules<commit_msg>Massively simplified es2015 module collector<commit_after>import fs from "fs"
import path from "path"
import { readJsonSync } from "fs-extra"

const root = "node_modules"
const modules = new Set

const nodePackages = fs.readdirSync(root).filter((dirname) => dirname.charAt(0) !== ".")

nodePackages.forEach(function(pkg)
{
  var json = readJsonSync(path.resolve(root, pkg, "package.json"))
  if (json["jsnext:main"] || json["module"])
    modules.add(pkg)
})

export default modules
{'fraction_non_alphanumeric': 0.15146831530139104, 'fraction_numerical': 0.00463678516228748, 'mean_word_length': 3.850187265917603, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '4516925', 'n_tokens_mistral': 441, 'n_tokens_neox': 435, 'n_words': 103}