Socket
Book a DemoInstallSign in
Socket

pull-cont

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pull-cont

pull-streams and continuables make friends!

Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
235
193.75%
Maintainers
1
Weekly downloads
 
Created
Source

pull-cont

pull-streams and continuables make friends!

continuables

continuables are a like async callbacks, but more composable. instead of taking a series of arguments, then a callback, a continuable takes it's arguments, and returns a function that takes exactly one argument: the callback.

this makes it easy represent a single async operation, you can easily pass a continuable to another function.

continuable repo, bundle of best continuables.

example

pull-cont takes a continuable that returns a pull-stream, and makes it into a pull-stream.

It's like pull-defer but easier for simple cases.

var PullCont = require('pull-cont')
// or PullCont = requrie('pull-cont/source')

//create a pull-stream that reads a directory!
pull(
  PullCont(function (cb) {
    fs.readdir(directory, function (err, ls) {
      if(err) cb(err)
      else cb(null, pull.values(ls))
    })
  }),
  ...
)

for Source streams, if the continuable returns another continuable, pull-cont will also call that recursively until it gets a pull-stream source. I don't know, this might be useful for something.

Sink & Duplex

You can also use this to create sink and duplex streams. (Unless you are designing a protocol you can probably ignore Duplex)

var Sink = require('pull-cont/sink')
var Duplex = require('pull-cont/duplex')

//and then complete the continuable with the correct type of stream
Sink(function (cb) {
  cb(null, pull.drain())
})

License

MIT

FAQs

Package last updated on 04 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts