# libp2p-spdy

> SPDY 3.1 implementation wrapper that is compatible with libp2p Stream Muxer expected interface

Latest version **0.13.3** (published 2019-03-25) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install libp2p-spdy
pnpm add libp2p-spdy
yarn add libp2p-spdy
bun add libp2p-spdy
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.13.3 |
| Published | 2019-03-25 |
| First published | 2015-09-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.0.0 |
| Dependencies | 8 |
| Unpacked size | 15.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | daviddias, dignifiedquire |
| Keywords | IPFS |

## Links

- npm: https://www.npmjs.com/package/libp2p-spdy
- Repository: https://github.com/libp2p/js-libp2p-spdy
- Issues: https://github.com/libp2p/js-libp2p-spdy/issues
- npm.io page: https://npm.io/package/libp2p-spdy

## Dependencies (8)

- [once](https://npm.io/package/once.md) ^1.4.0
- [debug](https://npm.io/package/debug.md) ^4.1.1
- [pull-catch](https://npm.io/package/pull-catch.md) ^1.0.1
- [pull-stream](https://npm.io/package/pull-stream.md) ^3.6.9
- [spdy-transport](https://npm.io/package/spdy-transport.md) ^3.0.0
- [interface-connection](https://npm.io/package/interface-connection.md) ~0.3.3
- [pull-stream-to-stream](https://npm.io/package/pull-stream-to-stream.md) ^1.3.4
- [stream-to-pull-stream](https://npm.io/package/stream-to-pull-stream.md) ^1.7.2

## Recent versions

- 0.13.3 (latest) — 2019-03-25
- 0.13.2 — 2019-03-18
- 0.13.1 — 2018-12-04
- 0.13.0 — 2018-11-14
- 0.12.1 — 2018-04-05
- 0.12.0 — 2018-04-05
- 0.11.0 — 2017-09-03
- 0.10.6 — 2017-03-21
- 0.10.4 — 2017-02-09
- 0.10.3 — 2017-01-21
- 0.10.2 — 2017-01-21
- 0.10.1 — 2016-12-18
- 0.10.0 — 2016-11-03
- 0.9.0 — 2016-09-06
- 0.8.1 — 2016-08-03
- … 17 more at https://npm.io/package/libp2p-spdy/versions

## README

js-libp2p-spdy
==============

[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
[![Coverage Status](https://coveralls.io/repos/github/libp2p/js-libp2p-spdy/badge.svg?branch=master)](https://coveralls.io/github/libp2p/js-libp2p-spdy?branch=master)
[![Dependency Status](https://david-dm.org/libp2p/js-libp2p-spdy.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-spdy)
[![Travis CI](https://travis-ci.org/libp2p/js-libp2p-spdy.svg?branch=master)](https://travis-ci.org/libp2p/js-libp2p-spdy)
[![Circle CI](https://circleci.com/gh/libp2p/js-libp2p-spdy.svg?style=svg)](https://circleci.com/gh/libp2p/js-libp2p-spdy)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
![](https://img.shields.io/badge/npm-%3E%3D3.0.0-orange.svg?style=flat-square)
![](https://img.shields.io/badge/Node.js-%3E%3D6.0.0-orange.svg?style=flat-square)

> SPDY 3.1 implementation wrapper that is compatible with libp2p Stream Muxer expected interface

[![](https://github.com/libp2p/interface-stream-muxer/raw/master/img/badge.png)](https://github.com/libp2p/interface-stream-muxer)

## Lead Maintainer

[Jacob Heun](https://github/jacobheun)

## Installation

### npm

```sh
> npm i libp2p-spdy
```

### Use in Node.js

```js
const spdy = require('libp2p-spdy')
```

### Use in a browser with browserify, webpack or any other bundler

The code published to npm that gets loaded on require is in fact a ES5 transpiled version with the right shims added. This means that you can require it and use with your favourite bundler without having to adjust asset management process.

```JavaScript
var spdy = require('libp2p-spdy')
```

### Use in a browser Using a script tag

Loading this module through a script tag will make the `Lip2pSpdy` obj available in the global namespace.

```html
<script src="https://unpkg.com/libp2p-spdy/dist/index.min.js"></script>
<!-- OR -->
<script src="https://unpkg.com/libp2p-spdy/dist/index.js"></script>
```

## Usage

### API

#### Attaching it to a socket (duplex stream)

**As a listener**

```JavaScript
const listener = spdy(conn, true)
```

**As a dialer**

```JavaScript
const dialer = spdy(conn, false)
```

#### Opening a multiplex duplex stream

```JavaScript
const conn = dialer.newStream((err, conn) => {})

conn.on('error', (err) => {})
```

note: Works the same on the listener side

#### Receiving incoming stream

```JavaScript
dialer.on('stream', (conn) => {})
```

note: Works the same on the listener side

#### Close

```JavaScript
dialer.close()
```

note: Works the same on the listener side

#### Other events

```JavaScript
dialer.on('close', () => {})
dialer.on('error', () => {})
```

note: Works the same on the listener side

### This module uses `pull-streams`

We expose a streaming interface based on `pull-streams`, rather then on the Node.js core streams implementation (aka Node.js streams). `pull-streams` offers us a better mechanism for error handling and flow control guarantees. If you would like to know more about why we did this, see the discussion at this [issue](https://github.com/ipfs/js-ipfs/issues/362).

You can learn more about pull-streams at:

- [The history of Node.js streams, nodebp April 2014](https://www.youtube.com/watch?v=g5ewQEuXjsQ)
- [The history of streams, 2016](http://dominictarr.com/post/145135293917/history-of-streams)
- [pull-streams, the simple streaming primitive](http://dominictarr.com/post/149248845122/pull-streams-pull-streams-are-a-very-simple)
- [pull-streams documentation](https://pull-stream.github.io/)

#### Converting `pull-streams` to Node.js Streams

If you are a Node.js streams user, you can convert a pull-stream to a Node.js stream using the module [`pull-stream-to-stream`](https://github.com/pull-stream/pull-stream-to-stream), giving you an instance of a Node.js stream that is linked to the pull-stream. For example:

```js
const pullToStream = require('pull-stream-to-stream')

const nodeStreamInstance = pullToStream(pullStreamInstance)
// nodeStreamInstance is an instance of a Node.js Stream
```

To learn more about this utility, visit https://pull-stream.github.io/#pull-stream-to-stream.

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