Big News: Socket Selected for OpenAI's Cybersecurity Grant Program.Details
Socket
Book a DemoSign in
Socket

pull-inactivity

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pull-inactivity

kill a duplex pull-stream after period of inactivity.

latest
Source
npmnpm
Version
2.1.4
Version published
Weekly downloads
538
-40.88%
Maintainers
2
Weekly downloads
 
Created
Source

pull-inactivity

Abort a pull-stream (duplex or transform) when the rate of throughput gets too low.

This is useful for a p2p protocol where you must manage multiple connections, aborting connections to unhelpful peers.

example

var inactivity = require('pull-inactivity')
var pull = require('pull-stream')
//some sort of p2p system, eg, scuttlebot.
var peer = createPeer()

//create a reliable stream to a remote peer
//i.e. tcp, websockets, or webrtc data channel
var stream = connect(remotePeer)

//create the protocol stream, give a min data rate (megabytes/second)
var peerStream = inactivity(peer.createStream(), 0.001, function (err) {
  //this cb is triggered when stream is aborted.
  console.log('disconnected')
})

pull(stream, peerStream, stream)

example - transform

if you have a normal source, transform, sink pipeline, you can use pull-inactivity with that too.

var inactivity = require('pull-inactivity')
var pull = require('pull-stream')

pull(
  source,
  transform,
  inactivity.through(0.01, function (err) {
    console.log('stream ended')
  }),
  sink
)


License

MIT

FAQs

Package last updated on 28 Feb 2022

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