<commit_before>module.exports = function (platform) {

  return fsDb;

  function fsDb(fs) {
    var inflate = platform.inflate;
    var deflate = platform.deflate;

    return {
      load: load,
      save: save,
      remove: remove,
      read: read,
      write: write,
      unlink: unlink,
      readdir: readdir
    };

    function load(hash, callback) {
      if (!callback) return load.bind(this, hash);
      return fs.read(hashToPath(hash), function (err, deflated) {
        if (err) return callback(err);
        return inflate(deflated, callback);
      });
    }

    function save(hash, buffer, callback) {
      if (!callback) return save.bind(this, hash, buffer);
      return deflate(buffer, function (err, deflated) {
        if (err) return callback(err);
        return write(hashToPath(hash), deflated, callback);
      });
    }

    function remove(hash, callback) {
      if (!callback) return remove.bind(this, hash);
      return unlink(hashToPath(hash), callback);
    }

    function read(path, callback) {
      if (!callback) return fs.read(path, "ascii");
      return fs.read(path, "ascii")(callback);
    }<commit_msg>Add has to db interface<commit_after>module.exports = function (platform) {

  return fsDb;

  function fsDb(fs) {
    var inflate = platform.inflate;
    var deflate = platform.deflate;

    return {
      load: load,
      save: save,
      remove: remove,
      has: has,
      read: read,
      write: write,
      unlink: unlink,
      readdir: readdir
    };

    function load(hash, callback) {
      if (!callback) return load.bind(this, hash);
      return fs.read(hashToPath(hash), function (err, deflated) {
        if (err) return callback(err);
        return inflate(deflated, callback);
      });
    }

    function save(hash, buffer, callback) {
      if (!callback) return save.bind(this, hash, buffer);
      return deflate(buffer, function (err, deflated) {
        if (err) return callback(err);
        return write(hashToPath(hash), deflated, callback);
      });
    }

    function remove(hash, callback) {
      if (!callback) return remove.bind(this, hash);
      return unlink(hashToPath(hash), callback);
    }

    function has(hash, callback) {
      if (!callback) return has.bind(this, hash);
      return fs.stat(hashToPath(hash), function (err) {
        if (err) {
          if (err.code === "ENOENT") return callback();
          return callback(err);
        }
        return callback(null, true);
      });
    }

    function read(path, callback) {
      if (!callback) return fs.read(path, "ascii");
      return fs.read(path, "ascii")(callback);
    }
{'fraction_non_alphanumeric': 0.12915407854984895, 'fraction_numerical': 0.0, 'mean_word_length': 2.560483870967742, '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': '6373807', 'n_tokens_mistral': 822, 'n_tokens_neox': 791, 'n_words': 216}