UNPKG

callbag-skip

Version:

Callbag operator that skips the first N data points of a source

21 lines (19 loc) 380 B
const skip = max => source => (start, sink) => { if (start !== 0) return; let skipped = 0; let talkback; source(0, (t, d) => { if (t === 0) { talkback = d; sink(t, d); } else if (t === 1) { if (skipped < max) { skipped++; talkback(1); } else sink(t, d); } else { sink(t, d); } }); }; module.exports = skip;