0.0.5 • Published 3 years ago

@mm-snap/post-message-stream v0.0.5

Weekly downloads
-
License
-
Repository
github
Last release
3 years ago

post-message-stream

Sets up a duplex object stream over window.postMessage, between pages or a Web Worker and its parent window.

Usage

const streamA = new WindowPostMessageStream({
  name: 'thing one',
  target: 'thing two',
})

const streamB = new WindowPostMessageStream({
  name: 'thing two',
  target: 'thing one',
})

streamB.on('data', (data) => console.log(data))
streamA.write(chunk)

Constructor arguments

const messageStream = new WindowPostMessageStream({

  // required

  // name of stream, used to differentiate
  // when multiple streams are on the same window 
  name: 'source',

  // name of target stream 
  target: 'sink',

  // optional

  // window to send the message to
  // default is `window`
  window: iframe.contentWindow,
  
})
0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago