peekaboo

Peekable transform stream

This module is no longer maintained.
Last updated 10 years ago by hueniverse .
BSD-3-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install peekaboo 
SYNC missed versions from official npm registry.

#peekaboo

A Peekable node stream.

A Peekaboo stream works just like a PassThrough stream, it can be piped to and from without any transformation of the chunks. The difference is that a Peekaboo stream will emit each chunk as a peek event on an EventEmitter of your choosing, letting you spy on stream chunks in an uninvasive way.

Build Status

Lead Maintainer - Eran Hammer

Example

We can report the download process of a request by peeking on response stream events:

'use strict';

const Events = require('events');
const Fs = require('fs');
const Https = require('https');
const Peekaboo = require('peekaboo');

const emitter = new Events.EventEmitter();
const peek = new Peekaboo(emitter);

Https.get('https://codeload.github.com/hapijs/hapi/zip/master', (res) => {

    res.pipe(peek).pipe(Fs.createWriteStream('./hapi.zip'));

    let downloaded = 0;
    emitter.on('peek', (chunk) => {

        downloaded += chunk.length;
        const pct = (downloaded / res.headers['content-length'] * 100).toFixed(1);
        process.stdout.write(pct + '% downloaded\r');
    });
});

Current Tags

  • 2.0.2                                ...           latest (10 years ago)

4 Versions

  • 2.0.2 [deprecated]           ...           10 years ago
  • 2.0.1 [deprecated]           ...           10 years ago
  • 2.0.0 [deprecated]           ...           10 years ago
  • 1.0.0 [deprecated]           ...           11 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (2)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |