m-list
An experiment with append only logs (or lists), adhering to the append only log abstract interface and developer API. Currently stores the entire list in memory! Custom storage providers have not been implemented.
usage
var List = require('@yaus/m-list')
// objectMode is true by default
var list = List()
list.append({
hello: 'world'
}, console.log)
list.append(11)
list.append('hello world!')
list.append([1, 2, 3])
// the sequence number just is the array index plus 1
// so this gets the first item from the list
// async
list.get(1, console.log)
// or syncronously
console.log(list.get(1))
var stream = list.createReadStream()
stream.on('data', console.log)
stream.on('end', console.log)
var list2 = List({ objectMode: false })
list2.append(Buffer.from('stream in binary mode!'))
extra methods
- toArray()
- fromArray(array)
install
npm i @yaus/m-list --save
todo
status:: in development
- allow storage facility to be passed in (RAM, localstorage or custom)
- toggle cryptographic integrity using a hashchain