Append only binary data file store.
Each block consists of a sequence
(index), a length
(length) and a
chunk of variable length of data. Because of this, only the sequence and
length need to be read, making it possible to "skip" through the file to
find a specific sequence. Both sequence and length are encoded as varints.
[SEQUENCE][LENGTH][DATA...]...
The constructor accepts an options object. { filename: path }
specifies the
target file to read and write to.
const { err, handle } = await new Skipfile()
Instance methods do not throw, they return an object which may contain { err }
.
Appends a value to the file specified in the constructor.
const { err, bytesWritten } = await handle.append(Buffer.from('Hello, world'))
Iterate forward.
while (true) {
const { err, buffer, index } = await handle.next()
if (err || !buffer) {
break
}
console.log(buffer.toString())
}
TODO
const { err, buffer } = await handle.seek(index)
Closes the file descriptor opened by the constructor.
await skip.close()
Tracks the size of the file opened by the constructor.