callbag-first

1.1.2 • Public • Published

callbag-first

Callbag operator that emit the first value emitted from source on completion, based on provided expression.

npm install callbag-first

first(predicate?: (v: any) => Boolean, resultSelector?: (v: any) => any)

const {
  forEach,
  interval,
  pipe,
  fromIter 
= require('callbag-basics');
 
const first = require('callbag-first');
 
pipe(
  fromIter([1, 2, 3, 4]),
  first(),
  forEach(v => console.log(v)) // 1
);
 
pipe(
  fromIter([1, 2, 3, 4]),
  first(v => v > 3),
  forEach(v => console.log(v)) // 4
);
 
pipe(
  fromIter([1, 2, 3, 4]),
  first(v => v > 3, v => `value: ${v}`),
  forEach(v => console.log(v)) // value: 4
);

Readme

Keywords

Package Sidebar

Install

npm i callbag-first

Weekly Downloads

0

Version

1.1.2

License

MIT

Unpacked Size

12.8 kB

Total Files

12

Last publish

Collaborators

  • jinahm