Launch Week Day 2: Introducing Reports: An Extensible Reporting Framework for Socket Data.Learn More
Socket
Book a DemoSign in
Socket

callbag-take

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

callbag-take

Callbag operator that limits the total amount of data sent through

latest
Source
npmnpm
Version
1.5.0
Version published
Weekly downloads
3.9K
65.1%
Maintainers
2
Weekly downloads
 
Created
Source

callbag-take

Callbag operator that limits the amount of data sent by a source. Works on either pullable and listenable sources.

npm install callbag-take

example

On a listenable source:

const interval = require('callbag-interval');
const observe = require('callbag-observe');
const take = require('callbag-take');

const source = take(3)(interval(1000));

source(0, observe(x => console.log(x))); // 0
                                         // 1
                                         // 2

On a pullable source:

const fromIter = require('callbag-from-iter');
const iterate = require('callbag-iterate');
const take = require('callbag-take');

function* range(from, to) {
  let i = from;
  while (i <= to) {
    yield i;
    i++;
  }
}

const source = take(4)(fromIter(range(100, 999)));

source(0, iterate(x => console.log(x))); // 100
                                         // 101
                                         // 102
                                         // 103

Keywords

callbag

FAQs

Package last updated on 11 Mar 2020

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