All Projects → fent → Node Streamspeed

fent / Node Streamspeed

Licence: mit
A simple way to keep track of the speed of your node streams.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Node Streamspeed

Mithril Data
A rich data model library for Mithril javascript framework
Stars: ✭ 17 (-48.48%)
Mutual labels:  stream
Remote Web Streams
Web streams that work across web workers and iframes.
Stars: ✭ 26 (-21.21%)
Mutual labels:  stream
Sidecar
Some old C++ code I developed while at MIT. Could be useful if you have an old radar lying around.
Stars: ✭ 20 (-39.39%)
Mutual labels:  stream
Hbc
A Java HTTP client for consuming Twitter's realtime Streaming API
Stars: ✭ 898 (+2621.21%)
Mutual labels:  stream
Chunk Store Stream
Convert an abstract-chunk-store compliant store into a readable or writable stream
Stars: ✭ 24 (-27.27%)
Mutual labels:  stream
Tuna
🐟 A streaming ETL for fish
Stars: ✭ 11 (-66.67%)
Mutual labels:  stream
Smux
A Stream Multiplexing Library for golang with least memory usage
Stars: ✭ 818 (+2378.79%)
Mutual labels:  stream
Xtream Iptv Player Reactnative
Stars: ✭ 30 (-9.09%)
Mutual labels:  stream
Trie
A Mixed Trie and Levenshtein distance implementation in Java for extremely fast prefix string searching and string similarity.
Stars: ✭ 25 (-24.24%)
Mutual labels:  stream
Python Stream
更优雅的流式数据处理方式
Stars: ✭ 20 (-39.39%)
Mutual labels:  stream
Node Jl Sql Api
SQL for JS objects streams
Stars: ✭ 19 (-42.42%)
Mutual labels:  stream
Redis Stream Demo
Demo for Redis Streams
Stars: ✭ 24 (-27.27%)
Mutual labels:  stream
Libzmq
ZeroMQ core engine in C++, implements ZMTP/3.1
Stars: ✭ 7,418 (+22378.79%)
Mutual labels:  stream
Sql Streams
Painless low level jdbc abstraction using the java 8 stream api.
Stars: ✭ 17 (-48.48%)
Mutual labels:  stream
Soundwaveinteractive
Interactive Sound Board for Mixer. Microsoft shut Mixer down, so this application no longer works. RIP Mixer.
Stars: ✭ 27 (-18.18%)
Mutual labels:  stream
Json Chunks
streamable json encoder
Stars: ✭ 17 (-48.48%)
Mutual labels:  stream
Streamjs
Lazy Object Streaming Pipeline for JavaScript
Stars: ✭ 858 (+2500%)
Mutual labels:  stream
Zipstream Php
💾 PHP ZIP Streaming Library
Stars: ✭ 961 (+2812.12%)
Mutual labels:  stream
Androidstreamable
Unofficial https://streamable.com API Wrapper for Android
Stars: ✭ 29 (-12.12%)
Mutual labels:  stream
Gollum
An n:m message multiplexer written in Go
Stars: ✭ 883 (+2575.76%)
Mutual labels:  stream

streamspeed

A simple way to keep track of the speed of your readable streams.

Depfu codecov

Usage

const StreamSpeed = require('streamspeed');

let rs = fs.createReadStream('somefile.avi');
let ss = new StreamSpeed();
ss.add(rs);

// Listen for events emitted by streamspeed on the given stream.
ss.on('speed', (speed) => {
  console.log('Reading at', speed, 'bytes per second');
});

Keep track of a group of streams

let group = new Streamspeed();
group.add(stream1);
group.add(stream2);
group.add(stream3);

group.on('speed', (speed) => {
  console.log('now reading at', speed, 'bps');
});

example img

API

new StreamSpeed([options])

A group that can be used to watch several streams. Will emit speed events. options can have the following properties,

  • timeUnit - Defaults to 1000 for speed per second. If you want another unit such as per hour, use 1000 * 60 * 60.
  • range - The time in ms to calculate speed over. Defaults to 1000. The longer this is, the more stable speed will be for a big stream. The shorter it is, the more responsive it is to sudden speed changes.

StreamSpeed#add(stream)

Adds stream to group.

StreamSpeed#remove(stream)

Removes stream from group.

StreamSpeed#getSpeed()

Get current speed.

StreamSpeed#getStreamSpeed(stream)

Get an individual's stream's current speed.

StreamSpeed#getStreams()

Returns a list of all streams in the group.

StreamSpeed.toHuman(bytes, options)

Helper method to convert bytes to a human readable string.

StreamSpeed.toHuman(1500);                                  // 1.46KB
StreamSpeed.toHuman(1024 * 1024);                           // 1MB
StreamSpeed.toHuman(1024 * 1024 * 20.5, { timeUnit: 's' }); // 20.5MB/s
StreamSpeed.toHuman(1024 * 1024 * 20.5, { precision: 3 });  // 20.50MB

Event: 'speed'

  • number - Speed at which streams in the group are being read.

Will be emitted every time a stream is read and only if there is a change in speed.

Install

npm install streamspeed

Tests

Tests are written with mocha

npm test
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].