<commit_before>(function () {

  'use strict';

  const exports = (module && module.exports) || (window.isopod = {});

  // utilities

  function each (obj, fn) {
    Object.keys(obj).forEach(function (k) {
      fn(k, obj[k]);
    });
  }

  // serialization

  function objectType (obj) {
    if (typeof obj === 'symbol') return 'Symbol';
    if (typeof obj === 'function') return 'Function';
    if (obj instanceof Set) return 'Set';
    if (obj instanceof Map) return 'Map';
    if (Array.isArray(obj)) return 'Array';
    return 'Object';
  }

  const parensPattern = /\(.+\)/;
  function getSymbolString (sym) {
    return sym.toString().match(parensPattern)[0].slice(1,-1);
  }

  const nativeConstructors = new Set([
    Object,
    Function,
    Set,
    Symbol,
    Array,
    Map
  ]);

  const nativePrototypes = new Set([
    Object.prototype,
    Function.prototype,
    Set.prototype,
    Symbol.prototype,
    Array.prototype,
    Map.prototype
  ]);

  exports.serialize = function (root) {
    const result = [];
    const map = new Map();
    function setValues (entry, obj) {
      const type = entry.type = objectType(obj);
      if (type === 'Symbol') {
        entry.source = getSymbolString(obj);
      } else if (type === 'Function') {
        entry.source = Function.prototype.toString.call(obj);
      } else if (type === 'Set') {
        entry.source = [];
        for (let elem of obj) {
          entry.source.push(assoc(elem));
        }
      } else if (type === 'Map') {
        entry.source = [];
        for (let kv of obj) {
          entry.source.push(kv.map(assoc));
        }
      } else if (type === 'Array') {
        entry.source = [];
        Array.prototype.forEach.call(obj, function (elem, idx) {
          entry.source[idx] = assoc(elem);
        });
      }
      entry.keys = {};
      const proto = Object.getPrototypeOf(obj);
      if (!nativePrototypes.has(proto)) {
        Object.defineProperty(entry.keys, '__proto__', {
          value: assoc(proto),
          enumerable: true
        });
      }
      if (Object.prototype.hasOwnProperty.call(obj, 'constructor') && !nativeConstructors.has(obj.constructor)) {
        entry.keys.constructor = assoc(obj.constructor);
      }
      each(obj, function (k, v) {
        if (!entry.source || !entry.source.hasOwnProperty(k)) {
          entry.keys[k] = assoc(v);
        }
      });
    }
    function assoc (thing) {
      if (map.has(thing)) {
        return [map.get(thing)];
      }
      if (thing instanceof Object || typeof thing === 'symbol') {
        const entry = {};
        const id = result.push(entry)-1;
        map.set(thing, id);
        setValues(entry, thing);
        return [id];
      }
      return thing;
    }
    assoc(root);
    return result;
  }

  // deserialization

  function typedFromRaw (raw) {
    if (raw.type === 'Symbol') {
      return Symbol(raw.source);
    } else if (raw.type === 'Function') {
      // TODO: alternative to eval
      return eval(`(${raw.source})`);
    } else if (raw.type === 'Set') {
      return new Set();
    } else if (raw.type === 'Map') {
      return new Map();
    } else if (raw.type === 'Array') {
      return [];
    } else if (raw.type === 'Object') {
      return {};
    }
  }

  function hydrateOne (obj, raw, refs) {
    function possibleRef (v) {
      return Array.isArray(v) ? refs[v[0]] : v;
    }
    if (raw.type === 'Set') {
      raw.source.forEach(function (elem) {
        obj.add(possibleRef(elem));
      });
    } else if (raw.type === 'Map') {
      raw.source.forEach(function ([k, v]) {
        obj.set(possibleRef(k), possibleRef(v));
      });
    } else if (raw.type === 'Array') {
      raw.source.forEach(function (elem) {
        obj.push(possibleRef(elem));
      });
    }
    each(raw.keys, function (k, v) {
      obj[k] = possibleRef(v);
    });
  }

  exports.deserialize = function (rawRoot) {
    const mapping = new Map();
    const refs = rawRoot.map(function (raw) {
      const typedObj = typedFromRaw(raw);
      mapping.set(typedObj, raw);
      return typedObj;
    });
    for (let [actual, raw] of mapping) {
      hydrateOne(actual, raw, refs);
    }
    return refs[0];
  }

})()<commit_msg>Fix exporting bug and get rid of destructuring<commit_after>(function () {

  'use strict';

  const glob = (typeof global === 'object') ? global : window;
  const exports = (typeof module === 'object' && typeof module.exports === 'object') ? module.exports : (glob.isopod = {});

  // utilities

  function each (obj, fn) {
    Object.keys(obj).forEach(function (k) {
      fn(k, obj[k]);
    });
  }

  // serialization

  function objectType (obj) {
    if (typeof obj === 'symbol') return 'Symbol';
    if (typeof obj === 'function') return 'Function';
    if (obj instanceof Set) return 'Set';
    if (obj instanceof Map) return 'Map';
    if (Array.isArray(obj)) return 'Array';
    return 'Object';
  }

  const parensPattern = /\(.+\)/;
  function getSymbolString (sym) {
    return sym.toString().match(parensPattern)[0].slice(1,-1);
  }

  const nativeConstructors = new Set([
    Object,
    Function,
    Set,
    Symbol,
    Array,
    Map
  ]);

  const nativePrototypes = new Set([
    Object.prototype,
    Function.prototype,
    Set.prototype,
    Symbol.prototype,
    Array.prototype,
    Map.prototype
  ]);

  exports.serialize = function (root) {
    const result = [];
    const map = new Map();
    function setValues (entry, obj) {
      const type = entry.type = objectType(obj);
      if (type === 'Symbol') {
        entry.source = getSymbolString(obj);
      } else if (type === 'Function') {
        entry.source = Function.prototype.toString.call(obj);
      } else if (type === 'Set') {
        entry.source = [];
        for (let elem of obj) {
          entry.source.push(assoc(elem));
        }
      } else if (type === 'Map') {
        entry.source = [];
        for (let kv of obj) {
          entry.source.push(kv.map(assoc));
        }
      } else if (type === 'Array') {
        entry.source = [];
        Array.prototype.forEach.call(obj, function (elem, idx) {
          entry.source[idx] = assoc(elem);
        });
      }
      entry.keys = {};
      const proto = Object.getPrototypeOf(obj);
      if (!nativePrototypes.has(proto)) {
        Object.defineProperty(entry.keys, '__proto__', {
          value: assoc(proto),
          enumerable: true
        });
      }
      if (Object.prototype.hasOwnProperty.call(obj, 'constructor') && !nativeConstructors.has(obj.constructor)) {
        entry.keys.constructor = assoc(obj.constructor);
      }
      each(obj, function (k, v) {
        if (!entry.source || !entry.source.hasOwnProperty(k)) {
          entry.keys[k] = assoc(v);
        }
      });
    }
    function assoc (thing) {
      if (map.has(thing)) {
        return [map.get(thing)];
      }
      if (thing instanceof Object || typeof thing === 'symbol') {
        const entry = {};
        const id = result.push(entry)-1;
        map.set(thing, id);
        setValues(entry, thing);
        return [id];
      }
      return thing;
    }
    assoc(root);
    return result;
  }

  // deserialization

  function typedFromRaw (raw) {
    if (raw.type === 'Symbol') {
      return Symbol(raw.source);
    } else if (raw.type === 'Function') {
      // TODO: alternative to eval
      return eval(`(${raw.source})`);
    } else if (raw.type === 'Set') {
      return new Set();
    } else if (raw.type === 'Map') {
      return new Map();
    } else if (raw.type === 'Array') {
      return [];
    } else if (raw.type === 'Object') {
      return {};
    }
  }

  function hydrateOne (obj, raw, refs) {
    function possibleRef (v) {
      return Array.isArray(v) ? refs[v[0]] : v;
    }
    if (raw.type === 'Set') {
      raw.source.forEach(function (elem) {
        obj.add(possibleRef(elem));
      });
    } else if (raw.type === 'Map') {
      raw.source.forEach(function (mapEntry) {
        let k = mapEntry[0]; // TODO: could replace with destructuring
        let v = mapEntry[1]; // TODO: could replace with destructuring
        obj.set(possibleRef(k), possibleRef(v));
      });
    } else if (raw.type === 'Array') {
      raw.source.forEach(function (elem) {
        obj.push(possibleRef(elem));
      });
    }
    each(raw.keys, function (k, v) {
      obj[k] = possibleRef(v);
    });
  }

  exports.deserialize = function (rawRoot) {
    const mapping = new Map();
    const refs = rawRoot.map(function (raw) {
      const typedObj = typedFromRaw(raw);
      mapping.set(typedObj, raw);
      return typedObj;
    });
    for (let mapEntry of mapping) {
      let actual = mapEntry[0]; // TODO: could replace with destructuring
      let raw = mapEntry[1]; // TODO: could replace with destructuring
      hydrateOne(actual, raw, refs);
    }
    return refs[0];
  }

})();
{'fraction_non_alphanumeric': 0.16217739208835794, 'fraction_numerical': 0.0018032232615800743, 'mean_word_length': 2.2434210526315788, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2024745', 'n_tokens_mistral': 2801, 'n_tokens_neox': 2771, 'n_words': 665}