1.2.0 • Published 2 years ago

@rbbn/distant-pull-vchannel v1.2.0

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
github
Last release
2 years ago

pull-vchannel

Create a pull-stream from a vchannel.

Usage

Install using npm:

npm install @distant/pull-vchannel

or yarn:

yarn add @distant/pull-vchannel

Use the package like so:

import { pull, drain, values } from 'pull-stream'
import { createPullChannel } from '@distant/pull-vchannel'

const channel = getChannel()

const done = (err) => {
  if (err) {
    return console.error("There was an error that closed the channel", err)
  }

  console.log("The channel closed normally")
}

const pullChannel = createPullChannel(channel, done)

pull(
  pullChannel,
  drain(
    (message) => console.log("We got a message", message),
    (err) => console.log("The stream closed", err)
  )
)

pull(
  values(["foo", "bar", "xyzzy"]),
  pullChannel
)