npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

callbag-merge-all

v1.0.1

Published

Callbag operator that merges all items a source of sources into a single output source

Readme

callbag-merge-all 👜

Callbag operator that merges all items of a source of sources into a single output source

npm install callbag-merge-all

The input source can be listenable or pullable, and its inner sources can be listenable or pullable as well.

The output source reflects the nature of inner sources: Listenable inner sources are merged into a listenable output source, pullable inner sources are merged into a pullable output source. More on this later.

Usage:

const mergeAll   = require('callbag-merge-all');
const fromIter   = require('callbag-from-iter');
const of         = require('callbag-of');
const pipe       = require('callbag-pipe');
const map        = require('callbag-map');
const toIterable = require('callbag-to-iterable');

// Pullable sources
const iterable = pipe(
  fromIter([1, 2]),
  map(i => fromIter([`${i}a`, `${i}b`])),
  mergeAll,
  toIterable
);

for (const i of iterable) {
  console.log(i);                // Logs 1a, 1b, 2a, 2b
}

// Listenable sources
pipe(
  of(1, 2),
  map(i => of(`${i}a`, `${i}b`)),
  mergeAll,
  forEach(x => console.log(x))   // Logs 1a, 1b, 2a, 2b
);

Merging a Pullable Source of Listenable Inner Sources

Since pullable inner sources should be merged into a pullable output source, mergeAll doesn't pull the input by itself, but instead waits until the output is pulled.

On the other hand, this creates a problem when merging a pullable source of listenable inner sources: The output should be listenable, i.e. doesn't have to be pulled. Although, to get the inner sources, mergeAll needs to pull the outer input source, yet it can't, because it doesn't know in advance whether the inner sources are pullable or listenable.

To solve this dilemma, mergeAll offers a compromise in this special case. It creates a 'lazy listenable' output source: You must pull it once to get it started. This pull is forwarded to the inner source and thereby fetches the first inner source. After that first pull, it behaves exactly like a listenable source. Then, whenever the last inner source completes, and there haven't been any unanswered pulls to the output source, mergeAll issues a pull to the input with a special payload NO_INNER_SOURCES. Most sources will interpret this as an ordinary pull, but the special payload gives you the option to treat these pulls differently, e.g. deferring them for a while.


const tapUp   = require('callbag-tap-up');
const pull    = require('callbag-pull');
const observe = require('callbag-observe');

const output = pipe(
  fromIter([1, 2]),
  map(i => of(`${i}a`, `${i}b`)),
  tapUp(msg => console.log(msg)),   // Logs undefined, NO_INNER_SOURCES, NO_INNER_SOURCES
  mergeAll,
  pull(1),
  observe(x => console.log(x))      // Logs 1a, 1b, 2a, 2b
);