ct
callbag-take
npm i callbag-take
ct

callbag-take

👜 Callbag operator that limits the total amount of data sent through

by André Staltz

1.5.0 (see all)License:MITTypeScript:Built-In
npm i callbag-take
Readme

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

Downloads/wk

2K

GitHub Stars

6

LAST COMMIT

9mos ago

MAINTAINERS

2

CONTRIBUTORS

6

OPEN ISSUES

0

OPEN PRs

0
VersionTagPublished
1.5.0
latest
3yrs ago
No alternatives found
No tutorials found
Add a tutorial

Rate & Review

100
No reviews found
Be the first to rate