# iframe-stream

> Create a stream around an iframe via [post-message-stream](https://github.com/kumavis/post-message-stream)

Latest version **3.0.0** (published 2017-07-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install iframe-stream
pnpm add iframe-stream
yarn add iframe-stream
bun add iframe-stream
```

## 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 | 3.0.0 |
| Published | 2017-07-13 |
| First published | 2015-12-22 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | kumavis |
| Maintainers | kumavis |
| Keywords | iframe, stream, postMessage |

## Links

- npm: https://www.npmjs.com/package/iframe-stream
- Repository: https://github.com/kumavis/iframe-stream
- Homepage: https://github.com/kumavis/iframe-stream#readme
- Issues: https://github.com/kumavis/iframe-stream/issues
- npm.io page: https://npm.io/package/iframe-stream

## Dependencies (1)

- [post-message-stream](https://npm.io/package/post-message-stream.md) ^3.0.0

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2017-07-13
- 2.0.2 — 2017-07-09
- 2.0.1 — 2017-01-17
- 2.0.0 — 2017-01-17
- 1.0.2 — 2016-05-23
- 1.0.1 — 2015-12-22
- 1.0.0 — 2015-12-22

## README

# iframe-stream

Create a stream around an iframe via [post-message-stream](https://github.com/kumavis/post-message-stream)

```js
const IframeStream = require('iframe-stream').IframeStream

var iframe = createIframe()
var iframeStream = IframeStream(iframe)
```

### Note

* Setup the stream immediately, so we don't miss the iframe's `load` event.
* The IframeStream will buffer all input until the childstream is ready.
* This is an object stream, and buffers will not be handled gracefully.

### Example

Here is an example using [dnode](https://github.com/substack/dnode) to create a callback based API with a javascript context inside an iframe.

Parent:
```js
const IframeStream = require('iframe-stream').IframeStream
const Dnode = require('dnode')

var iframe = createIframe()
var iframeStream = IframeStream(iframe)
var dnode = Dnode()
dnode.on('remote', function(child){
  child.doAsyncSomething(function(){
    console.log('child finished doing the thing!')
  })
})

dnode.pipe(iframeStream).pipe(dnode)
```

Child:
```js
const ParentStream = require('iframe-stream').ParentStream
const Dnode = require('dnode')

var parentStream = ParentStream(iframe)
var dnode = Dnode({
  doAsyncSomething: function (cb) {
    console.log('doing something async...')
    cb()
  }
})

dnode.pipe(parentStream).pipe(dnode)
```

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