New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

pull-obv

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pull-obv

turn a pull-stream into an observable.

latest
Source
npmnpm
Version
1.3.2
Version published
Weekly downloads
17
750%
Maintainers
1
Weekly downloads
 
Created
Source

pull-obv

turn a pull-stream into an observable.

example

var More = require('pull-obv')

//takes a reduce function and a pull stream source (or other async function)
var obv = More(function reduce (state, item) {
  return (state.value || 0) + item
}, pull.values(1,2,3))

//it won't start listening until a listener is subscribed
obv(function (state) {
  //if the listener returns true, request more data.
  return true
  //alternativly, call obv.more() can be called async
  obv.more()
})

More(reduce, get) => obv

reduce(state, item)

item is whatever the stream gives. state is always an {} with properties {reading: boolean, ended: boolean | Error, more: boolean} and whatever else is added by the reduce function. If more is truthy, the stream will continue to be read. (this is just one way of requesting more. also, return true in listener, or call obv.more())

get (abort, cb)

read the next item - note, this is the same as a pull-stream. it should eventually cb(true) which means the stream is over.

obv(fn)

Assign a listener. This observable supports only a single listener. if fn returns true, more is read.

obv.more()

read more. note, calling more once the state is already reading does nothing.

obv.value

access the internal value of the observable

License

MIT

FAQs

Package last updated on 14 Aug 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