@toruslabs/post-message-stream

3.1.0 • Public • Published

post-message-stream

Sets up a duplex object stream over window.postMessage

var streamA = new PostMessageStream({
  name: 'thing one',
  target: 'thing two',
})

var streamB = new PostMessageStream({
  name: 'thing two',
  target: 'thing one',
})

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

constructor arguments

var messageStream = new PostMessageStream({

  // 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,
  
})

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i @toruslabs/post-message-stream

    Weekly Downloads

    1

    Version

    3.1.0

    License

    ISC

    Unpacked Size

    3.12 kB

    Total Files

    3

    Last publish

    Collaborators

    • archit_web3
    • himanshunpm009
    • torusresearch
    • chaitanyapotti
    • tetratorus