🚀 Launch Week Day 3:Introducing Supply Chain Attack Campaigns Tracking.Learn More →
Socket
Book a DemoInstallSign in
Socket

subgraph

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

subgraph

Content addressable graph where every node has at most a single link to another node

Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
2
-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

subgraph

Content addressable graph where every node has at most a single link to another node

npm install subgraph

build status

Usage

var subgraph = require('subgraph')
var sg = subgraph(levelupInstance)

var ws = sg.createAppendStream()

ws.write('hello')
ws.write('world')

ws.end(function () {
  var rs = sg.createReadStream(ws.key)

  rs.on('data', function (node) {
    console.log(node) // first {value: 'world'} then {value: 'hello'}
  })
})

API

var sg = subgraph(levelupInstance)

Create a new subgraph instance

Create an append stream. The values you write to it will be linked together. When the stream emits finish it will have a .key property that contains the latest link and a .length property that contains the number of nodes written

Optionally you can provide a link in the constructor for the first node to append to.

Create a read stream from a link. Will read out values in reverse order of writes to the append stream.

Create a write stream from a link. Will verify that the values written matches the link when hashed.

Shorthand for only adding a single value

Shorthand for getting a single value

If the write stream is destroyed/ended before all values are written to it will be resumable. This method returns the latest missing link of a write stream.

License

MIT

FAQs

Package last updated on 03 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts