https://github.com/sebinsua/monitor-head-stream
💦 Monitor the head of a stream.
https://github.com/sebinsua/monitor-head-stream
continuous follow head monitor refresh stream tail tailing
Last synced: 6 months ago
JSON representation
💦 Monitor the head of a stream.
- Host: GitHub
- URL: https://github.com/sebinsua/monitor-head-stream
- Owner: sebinsua
- Created: 2017-01-27T00:39:35.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-02-02T20:22:39.000Z (over 8 years ago)
- Last Synced: 2025-04-06T23:12:55.083Z (6 months ago)
- Topics: continuous, follow, head, monitor, refresh, stream, tail, tailing
- Language: JavaScript
- Homepage:
- Size: 68.4 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# `monitor-head-stream` [](https://travis-ci.org/sebinsua/monitor-head-stream) [](https://npmjs.org/package/monitor-head-stream)
> 💦 Monitor the head of a streamThis module polls streams of objects for their latest item(s).
It's sort of like `tail -f` for [`Stream`s](https://nodejs.org/api/stream.html), but acts upon the head of the stream.
It was created in order to help implement small-scale firehoses.
Other applications might include sending alerts [via SMS](https://github.com/twilio/twilio-node) or [OSX notifications](https://github.com/mikaelbr/node-notifier) on breaking news or the mention of particular topics.
## Example
```js
import { TimelineStream } from 'scrape-twitter'
import JSONStream from 'JSONStream'
import pump from 'pump'import monitorHeadStream from 'monitor-head-stream'
const createStream = () => new TimelineStream('POTUS')
const indexBy = obj => obj.id
const skipWhenPinned = obj => obj.isPinned === truepump(
monitorHeadStream(createStream, indexBy, skipWhenPinned),
JSONStream.stringify('[\n', ',\n', '\n]\n'),
process.stdout
)
```## Install
*With `yarn`*:
```sh
yarn add monitor-head-stream
```*With `npm`*:
```sh
npm install --save monitor-head-stream
```