# buffer-graph

> Resolve a dependency graph for buffer creation

Latest version **4.1.0** (published 2018-03-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install buffer-graph
pnpm add buffer-graph
yarn add buffer-graph
bun add buffer-graph
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.1.0 |
| Published | 2018-03-11 |
| First published | 2017-08-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | yoshuawuyts |
| Keywords | graph, dependency, resolution |

## Links

- npm: https://www.npmjs.com/package/buffer-graph
- Repository: https://github.com/yoshuawuyts/buffer-graph
- Homepage: https://github.com/yoshuawuyts/buffer-graph#readme
- Issues: https://github.com/yoshuawuyts/buffer-graph/issues
- npm.io page: https://npm.io/package/buffer-graph

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 4.1.0 (latest) — 2018-03-11
- 4.0.0 — 2017-10-18
- 3.1.0 — 2017-10-02
- 3.0.1 — 2017-09-28
- 3.0.0 — 2017-09-27
- 2.0.1 — 2017-08-30
- 2.0.0 — 2017-08-30
- 1.0.4 — 2017-08-27
- 1.0.3 — 2017-08-13
- 1.0.2 — 2017-08-13
- 1.0.1 — 2017-08-13
- 1.0.0 — 2017-08-12

## README

# buffer-graph
[![npm version][2]][3] [![build status][4]][5]
[![downloads][8]][9] [![js-standard-style][10]][11]

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
```js
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](https://tldrlegal.com/license/mit-license)

[0]: https://img.shields.io/badge/stability-experimental-orange.svg?style=flat-square
[1]: https://nodejs.org/api/documentation.html#documentation_stability_index
[2]: https://img.shields.io/npm/v/buffer-graph.svg?style=flat-square
[3]: https://npmjs.org/package/buffer-graph
[4]: https://img.shields.io/travis/yoshuawuyts/buffer-graph/master.svg?style=flat-square
[5]: https://travis-ci.org/yoshuawuyts/buffer-graph
[6]: https://img.shields.io/codecov/c/github/yoshuawuyts/buffer-graph/master.svg?style=flat-square
[7]: https://codecov.io/github/yoshuawuyts/buffer-graph
[8]: http://img.shields.io/npm/dm/buffer-graph.svg?style=flat-square
[9]: https://npmjs.org/package/buffer-graph
[10]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[11]: https://github.com/feross/standard

---
_Source: https://npm.io/package/buffer-graph · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
