Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/leslieJt/callbag-last
Callbag operator that emit the last value emitted from source on completion, based on provided expression.
https://github.com/leslieJt/callbag-last
callbag last
Last synced: 3 months ago
JSON representation
Callbag operator that emit the last value emitted from source on completion, based on provided expression.
- Host: GitHub
- URL: https://github.com/leslieJt/callbag-last
- Owner: leslieJt
- License: mit
- Created: 2018-02-03T14:24:41.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-04-20T12:23:38.000Z (over 1 year ago)
- Last Synced: 2024-04-10T05:22:42.416Z (9 months ago)
- Topics: callbag, last
- Language: JavaScript
- Homepage:
- Size: 97.7 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-callbags - last
README
# callbag-last
[Callbag](https://github.com/callbag/callbag) operator that emit the last value emitted from source on completion, based on provided expression.
`npm install callbag-last`
`last(predicate?: (v: any) => Boolean, resultSelector?: (v: any) => any)`
```javascript
const {
pipe,
interval,
take,
fromIter,
forEach
} = require('callbag-basics');const last = require('callbag-last');
pipe(
interval(100),
take(5),
last(),
forEach(v => console.log(v)) // 4
);pipe(
interval(100),
take(5),
last(v => v % 3 === 0, v => `value: ${v}`),
forEach(v => console.log(v)) // value: 3
);pipe(
fromIter([1, 2, 3, 4]),
last(),
forEach(v => console.log(v)) // 4
);
```