monitor-head-stream

0.1.2 • Public • Published

monitor-head-stream Build Status npm version

💦 Monitor the head of a stream

This module polls streams of objects for their latest item(s).

It's sort of like tail -f for Streams, but acts upon the head of the stream.

It was created in order to help implement small-scale firehoses.

Example

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 === true
 
pump(
  monitorHeadStream(createStream, indexBy, skipWhenPinned),
  JSONStream.stringify('[\n', ',\n', '\n]\n'),
  process.stdout
)

Install

With yarn:

yarn add monitor-head-stream

With npm:

npm install --save monitor-head-stream

/monitor-head-stream/

    Package Sidebar

    Install

    npm i monitor-head-stream

    Weekly Downloads

    1

    Version

    0.1.2

    License

    MIT

    Last publish

    Collaborators

    • sebinsua