# callbag-flatten

> Callbag operator that flattens a higher-order callbag source

Latest version **1.7.0** (published 2020-10-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install callbag-flatten
pnpm add callbag-flatten
yarn add callbag-flatten
bun add callbag-flatten
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.7.0 |
| Published | 2020-10-30 |
| First published | 2018-02-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 17.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | staltz.com |
| Maintainers | zimme, staltz |
| Keywords | callbag |

## Links

- npm: https://www.npmjs.com/package/callbag-flatten
- Repository: https://github.com/staltz/callbag-flatten
- Homepage: https://github.com/staltz/callbag-flatten#readme
- Issues: https://github.com/staltz/callbag-flatten/issues
- npm.io page: https://npm.io/package/callbag-flatten

## Dependencies (1)

- [callbag](https://npm.io/package/callbag.md) ^1.1.0

## Recent versions

- 1.7.0 (latest) — 2020-10-30
- 1.6.0 — 2020-10-26
- 1.5.0 — 2020-10-26
- 1.4.0 — 2019-02-09
- 1.3.0 — 2019-02-09
- 1.2.0 — 2018-07-31
- 1.1.0 — 2018-03-30
- 1.0.0 — 2018-02-01

## README

# callbag-flatten

Callbag operator that flattens a higher-order callbag source. Like RxJS "switch" or xstream "flatten". Use it with `map` to get behavior equivalent to "switchMap". Works on either pullable or listenable sources.

`npm install callbag-flatten`

## examples

### listenables

On each mouse click, start a stopwatch ticking every second:

```js
const fromEvent = require('callbag-from-event');
const interval = require('callbag-interval');
const flatten = require('callbag-flatten');
const observe = require('callbag-observe');
const pipe = require('callbag-pipe');
const map = require('callbag-map');

const source = pipe(
  fromEvent(document, 'click'),
  map(() => interval(1000)),
  flatten,
  observe(x => console.log(x))
);
```

### pullables

Loop over two iterables (such as arrays) and combine their values together:

```js
const fromIter = require('callbag-from-iter');
const iterate = require('callbag-iterate');
const flatten = require('callbag-flatten');
const pipe = require('callbag-pipe');
const map = require('callbag-map');

const source = pipe(
  fromIter('hi'),
  map(char => pipe(
    fromIter([10, 20, 30]),
    map(num => char + num)
  )),
  flatten,
  iterate(x => console.log(x))
);

// h10
// h20
// h30
// i10
// i20
// i30
```

---
_Source: https://npm.io/package/callbag-flatten · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
