code: function (_data, cb) {
        if(!db.data) return cb(new Error('kiddb not open'))
        if(writing) throw new Error('currently writing!')
        writing = true
        db._data = _data
  
        fs.writeFile(_filename, JSON.stringify(_data, null, 2)+'\n', function (err) {
          if(err) return cb(err)
          fs.rename(_filename, filename, function (err) {
            db.data = _data
            db._data = null
            writing = false
            if(onWrote) onWrote()
            cb(err)
          })
        })
      }
docs: the classic way to do a atomic fs writes. write to a tmp file, and then mv to desired name (which is atomic) if there is power loss before mv succeeds, then you still have the old data! there is only one file, so there cannot be concurrent writes, throw if they try to write concurrently.