# SYNOPSIS [![NPM Package](https://img.shields.io/npm/v/buffer-pipe.svg?style=flat-square)](https://www.npmjs.org/package/buffer-pipe) [![Build Status](https://img.shields.io/travis/wanderer/buffer-pipe.svg?branch=master&style=flat-square)](https://travis-ci.org/wanderer/buffer-pipe) [![Coverage Status](https://img.shields.io/coveralls/wanderer/buffer-pipe.svg?style=flat-square)](https://coveralls.io/r/wanderer/buffer-pipe) [![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard) A simple pipe for buffers. Write data to one end and read data off the other end. # INSTALL `npm install buffer-pipe` # USAGE ```javascript const pipe = require('buffer-pipe') const p = new Pipe() p.write(Buffer.from([1,2,3,4])) const buf = p.read(2) // <1, 2> ``` # API ## constructor [index.js:8-10](https://github.com/wanderer/buffer-pipe/blob/54caadc458ca1ac4c3d5d42c945f09165d3f15cd/index.js#L8-L10 "Source code on GitHub") Creates a new instance of a pipe **Parameters** - `buf` **[Buffer](https://nodejs.org/api/buffer.html)** an optional buffer to start with (optional, default `Buffer.from([])`) ## read [index.js:17-21](https://github.com/wanderer/buffer-pipe/blob/54caadc458ca1ac4c3d5d42c945f09165d3f15cd/index.js#L17-L21 "Source code on GitHub") read `num` number of bytes from the pipe **Parameters** - `num` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** Returns **[Buffer](https://nodejs.org/api/buffer.html)** ## write [index.js:27-30](https://github.com/wanderer/buffer-pipe/blob/54caadc458ca1ac4c3d5d42c945f09165d3f15cd/index.js#L27-L30 "Source code on GitHub") Wites a buffer to the pipe **Parameters** - `buf` **[Buffer](https://nodejs.org/api/buffer.html)** ## end [index.js:36-38](https://github.com/wanderer/buffer-pipe/blob/54caadc458ca1ac4c3d5d42c945f09165d3f15cd/index.js#L36-L38 "Source code on GitHub") Whether or not there is more data to read from the buffer returns {Boolean} # LICENSE [MPL-2.0][LICENSE] [LICENSE]: https://tldrlegal.com/license/mozilla-public-license-2.0-(mpl-2)