Nostalgic Piano Music

    buffer-graph

    4.1.0 • Public • Published

    buffer-graph

    npm version build status downloads js-standard-style

    Resolve a dependency graph of buffers.

    Useful to manage multiple functions that rely on each other, and can recreate assets on the fly through means such as observing filesystem events.

    Usage

    var bufferGraph = require('buffer-graph')
     
    var key = Buffer.from('my very cool graphing key')
     
    var graph = bufferGraph(key)
    graph.on('change', function (name, data) {
      console.log(`${nodeName}:${edgeName} changed to ${data[name].hash}`)
    })
     
    // Triggers when graph.start() is called
    graph.node('first', function (data, edge) {
      console.log('initial data is', data.metadata)
      edge('foo', Buffer.from('beep'))
      setTimeout(function () {
        edge('bar', Buffer.from('boop'))
      }, 100)
    })
     
    // Triggers once first:foo and first:bar have been created. Retriggers if
    // either dependency changes, and the data has a different hash.
    graph.node('second', [ 'first:foo', 'first:bar' ], function (data, edge) {
      console.log('first:foo', data.first.foo)
      console.log('first:bar', data.first.bar)
      edge('baz', Buffer.from('berp'))
    })
     
    graph.start({ hi: 'kittens' })

    Events

    graph.on('change', name, state)

    Emitted whenever an edge in the graph is updated.

    API

    graph = bufferGraph()

    Create a new buffer-graph instance. Inherits from Node's events.EventEmitter module.

    graph.node(name, [dependencies], fn(state, edge, metadata))

    Create a new node in the buffer graph.

    graph.start([metadata])

    Start the graph. Can be passed metadata which is set as state.metadata.

    graph.data

    Read out the data from the graph.

    graph.metadata

    Read out the metadata from the graph.

    License

    MIT

    Install

    npm i buffer-graph

    DownloadsWeekly Downloads

    14

    Version

    4.1.0

    License

    MIT

    Unpacked Size

    12.9 kB

    Total Files

    6

    Last publish

    Collaborators

    • yoshuawuyts