JSPM

callbag-for-each

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2977
  • Score
    100M100P100Q120152F
  • License MIT

Callbag sink that consume both pullable and listenable sources

Package Exports

  • callbag-for-each

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (callbag-for-each) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

/**

  • callbag-for-each

  • Callbag sink that consume both pullable and listenable sources. When called
  • on a pullable source, it will iterate through its data. When called on a
  • listenable source, it will observe its data.
  • npm install callbag-for-each
  • Examples

  • Consume a pullable source:
  • const fromIter = require('callbag-from-iter');
  • const forEach = require('callbag-for-each');
  • const source = fromIter([10,20,30,40])
  • forEach(x => console.log(x))(source); // 10
  •                                       // 20
  •                                       // 30
  •                                       // 40
  • Consume a listenable source:
  • const interval = require('callbag-interval');
  • const forEach = require('callbag-for-each');
  • const source = interval(1000);
  • forEach(x => console.log(x))(source); // 0
  •                                       // 1
  •                                       // 2
  •                                       // 3
  •                                       // ...

*/

const forEach = operation => source => { let talkback; source(0, (t, d) => { if (t === 0) talkback = d; if (t === 1) operation(d); if (t === 1 || t === 0) talkback(1); }); };

module.exports = forEach;