Skip to content

Instantly share code, notes, and snippets.

@coodoo
Last active June 27, 2016 22:27
Show Gist options
  • Save coodoo/c3df4b5b746d76cda2524ec7ffab99e5 to your computer and use it in GitHub Desktop.
Save coodoo/c3df4b5b746d76cda2524ec7ffab99e5 to your computer and use it in GitHub Desktop.
import hyperarray from 'hyper-array'
import memdb from 'memdb'
const dag = hyperarray( memdb() )
// step 1
// api: array.insert(value, [before], [after], [cb=function (err, entry) {}])
dag.insert( 'abc', null, null, ( err, node ) => {
conole.log( node )
})
// step 2
// how to insert z between b and c?
// Pseudo code should look like below but how do one get the id of 'b' and 'c'?
dag.insert( 'z', 'b', 'c', cb )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment