<commit_before>var clone = require('clone')

  , Sets = function (db) {
      if (!(this instanceof Sets))
        return new Sets(db)

      this.db = db
    }

Sets.prototype.put = function (key, value, callback) {
  var self = this

  this.get(key, function (err, array) {

    if (err) return callback(err)

    if (array.indexOf(value) !== -1) return callback()

    array.push(value)

    self.db.put(key, JSON.stringify(array), callback)
  })
}

Sets.prototype.get = function (key, callback) {
  this.db.get(key, function (err, array) {
    if (err) {
      if (err.notFound){
        callback(null, [])
      } else{
        callback(err)
      }
    } else {
      callback(null, JSON.parse(array))
    }
  })
}

Sets.prototype.del = function (key,value, callback) {
  var self = this

  this.get(key, function (err, array) {
    if (err) return callback(err)

    if (array.indexOf(value) === -1) return callback()

    array.splice(array.indexOf(value), 1)

    if (array.length === 0)
      self.db.del(key, callback)
    else
      self.db.put(key, JSON.stringify(array), callback)
  })
}

Sets.prototype.createReadStream = function (opts) {<commit_msg>use valueEncoding: 'json' when applicable<commit_after>var clone = require('clone')

  , Sets = function (db) {
      if (!(this instanceof Sets))
        return new Sets(db)

      this.db = db
    }

Sets.prototype.put = function (key, value, callback) {
  var self = this

  this.get(key, function (err, array) {

    if (err) return callback(err)

    if (array.indexOf(value) !== -1) return callback()

    array.push(value)

    self.db.put(key, array, { valueEncoding: 'json' }, callback)
  })
}

Sets.prototype.get = function (key, callback) {
  this.db.get(key, { valueEncoding: 'json' }, function (err, array) {
    if (err) {
      if (err.notFound){
        callback(null, [])
      } else{
        callback(err)
      }
    } else {
      callback(null, array)
    }
  })
}

Sets.prototype.del = function (key,value, callback) {
  var self = this

  this.get(key, function (err, array) {
    if (err) return callback(err)

    if (array.indexOf(value) === -1) return callback()

    array.splice(array.indexOf(value), 1)

    if (array.length === 0)
      self.db.del(key, callback)
    else
      self.db.put(key, array, { valueEncoding: 'json' }, callback)
  })
}

Sets.prototype.createReadStream = function (opts) {
{'fraction_non_alphanumeric': 0.15519399249061328, 'fraction_numerical': 0.003337505214851898, 'mean_word_length': 2.735202492211838, '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': '6209946', 'n_tokens_mistral': 821, 'n_tokens_neox': 794, 'n_words': 194}