Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/krawaller/callbag-with-previous


https://github.com/krawaller/callbag-with-previous

Last synced: 18 days ago
JSON representation

Awesome Lists containing this project

README

        

# callbag-with-previous

[Callbag](https://github.com/callbag/callbag) operator that puts the previous value alongside the current in an array.

```
[currentValue, previousValue]
```

The first output will also have `true` as a third item, to allow you to distinguish from the previous item being `undefined` and the first value.

```
[firstValue, undefined, true]
```

`npm install callbag-with-previous`

## example

```js
const fromIter = require('callbag-from-iter');
const forEach = require('callbag-for-each');
const withPrevious = require('callbag-with-previous');

const source = withPrevious(fromIter([1,2,3]));

forEach(x => console.log(x))(source); // [1, undefined, true]
// [2, 1]
// [3, 2]
```