Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/krawaller/callbag-with-previous
https://github.com/krawaller/callbag-with-previous
Last synced: 18 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/krawaller/callbag-with-previous
- Owner: krawaller
- License: mit
- Created: 2018-02-15T14:24:56.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-07-23T07:50:35.000Z (over 6 years ago)
- Last Synced: 2024-09-18T08:13:41.010Z (about 2 months ago)
- Language: JavaScript
- Size: 8.79 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
- awesome-callbags - with-previous
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]
```