Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

callbag-concat

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

callbag-concat

Callbag factory that concatenates data from multiple callbag sources

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

/**

  • callbag-concat

  • Callbag factory that concatenates the data from multiple (2 or more)
  • callbag sources. It starts each source at a time: waits for the previous
  • source to end before starting the next source. Works with both pullable
  • and listenable sources.
  • npm install callbag-concat
  • Example:
  • const fromIter = require('callbag-from-iter');
    
  • const iterate = require('callbag-iterate');
    
  • const concat = require('callbag-concat');
    
  • const source = concat(fromIter([10,20,30]), fromIter(['a','b']));
    
  • iterate(x => console.log(x))(source); // 10
    
  •                                       // 20
    
  •                                       // 30
    
  •                                       // a
    
  •                                       // b
    

*/

const concat = (...sources) => (start, sink) => { if (start !== 0) return; const n = sources.length; if (n === 0) { sink(0, () => {}); sink(2); return; } let i = 0; let sourceTalkback; const talkback = (t, d) => { if (t === 1 || t === 2) { sourceTalkback(t, d); } }; (function next() { if (i === n) { sink(2); return; } sources[i](0, (t, d) => { if (t === 0) { sourceTalkback = d; if (i === 0) sink(0, talkback); else sourceTalkback(1); } else if (t === 1) { sink(1, d); } else if (t === 2) { i++; next(); } }); })(); };

module.exports = concat;

Keywords

FAQs

Package last updated on 15 Feb 2018

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc