npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

timed-stream

v1.1.0

Published

Yet another timed stream package

Downloads

7

Readme

node-timed-stream

Greenkeeper badge Build Status codecov Dependency Status devDependencies contributions welcome Code Climate npm version

Yet another timed stream package. Mostly an exercise.

This module offers features similar to node-throttle and node-brake: throttle a stream with time constraints (rate and period at which it emits data) There is one more feature that this package provide: ability to pause the stream.

The rate can be adjusted on the fly.

Internally it uses backpressure to ensure the rate and period are constant. It also uses a passthrough stream in paused mode and reads to it at the given rate & period.

Examples

const fs = require('fs')
const TimedStream = require('../')

console.log("Reading file rate.js at constant rate of 10bps with a period of 1 seconds between each data burst")

const t = new TimedStream({
	rate: 10 /* 1 byte per second */,
	period: 1000 /* try to emit data every 1000 ms */
})

let c = 0 // counting data length
t.on('data', data => {
	c += data.length
	console.log(data.toString())
})
t.on('end', () => {
	console.log("Total length: " + c)
})

fs.createReadStream(__filename).pipe(t)

For more insight please take a look at tests

Installing

Install via npm:

npm install --save timed-stream

JSDoc

TimedStream

A TimedStream allow data to passthrough at a given rate and pause/resume at any time

Kind: global class

new TimedStream([options])

Creates an instance of TimedStream.

| Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | object | | Options forwarder to Stream.Transform ctor | | [options.rate] | number | 0 | Bytes per seconds (0: unlimited) | | [options.period] | number | 100 | Time between data event in ms |

timedStream.rate : number

The rate in bytes per second

Kind: instance property of TimedStream

timedStream.period : number

The period between data events in ms

Kind: instance property of TimedStream

timedStream.streamPaused : boolean

True if the stream is paused

Kind: instance property of TimedStream

timedStream.totalTime : number

The total time that the data flowed

Kind: instance property of TimedStream Read only: true

timedStream.pauseStream()

Pause the stream

Kind: instance method of TimedStream

timedStream.resumeStream()

Resume the stream

Kind: instance method of TimedStream

timedStream.destroy()

Destroy the stream. A destroyed stream will not emit 'end' or any other event

Kind: instance method of TimedStream