JSPM

pull-timeout

0.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q29481F

Timeout pull streams.

Package Exports

  • pull-timeout

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pull-timeout) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

pull-timeout

Timeout pull streams.

If you have long running streams that depend on extermal resources, you might want abort the stream when timing out.

Usage

timeout(ms)

Example

var pull = require("pull-stream");
var timeout = require("pull-timeout");

pull(
  pull.values([1,2,3,4,5,6,7,8,9,10]),
  pull.asyncMap( function (data, done) {
    setTimeout( function () {
      done(null, data);
    }, Math.round(Math.random()*4) == 0 ? 1500 : 100)
  }),
  timeout(1000),
  pull.Through( function (read) {
    return function next (end, cb) {
      read(end, function (end, data) {
        console.log(end, data);
        if (end && end !== true) return next(null, cb);
        cb(end, data);
      })
    }
  })(),
  pull.drain(function (){})
)

install

With npm do:

npm install pull-timeout

license

MIT