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

borescope

v0.0.4

Published

Borescope is a module used to get information about pipes such as throughput, total data sent etc... It is very similar to the amazing UNIX utility pipe viewer or 'pv'.

Downloads

10

Readme

Borescope

Borescope is a module used to get information about pipes such as throughput, total data sent etc... It is very similar to the amazing UNIX utility pipe viewer or 'pv'.

Installation

Borescope is an NPM module and can be installed using the stock standard method below:

npm install borescope

Usage

When you want to pipe a stream into borescope you should if you can give it the size of the stream (eg: an image file that you are using dd to write to an SD card), you can do this by calling the size function and passing int the size of the stream in bytes:

borescope.size(40960000);

This is not mandatory but will impact the data coming out of the 'borescopeData' event.

Events

borescopeData

This is emitted every time data flows through the stream being piped into borescope. This will return the following data:

Name | Description --- | --- volume | Total amount of data passed through the pipe so far (in bytes). throughput | Speed of throughput (in bytes). elapsedTime | Total amount of time elapsed so far (in seconds). chunkSize | Total amount of data passed through since last event of borescopeData (in bytes). chunkSize | Total amount of data passed through since last event of borescopeData (in bytes). size | Total size of the stream (in bytes, only is size specified). eta | Estimated time of arrival for completion of stream (in seconds, only is size specified). percent | Percentage completed. (in percent, only is size specified).

borescopeDone

This is emitted when the stream being piped through borescope ends and is flushed. This will return the following data:

Name | Description --- | --- averageThroughput | The average throughput of the data throughout the life of the stream (in bytes). totalTime | The total amount of time taken to complete the stream (in seconds). totalVolume | Total amount of volume processed in the stream (in bytes).

Example

"use strict";

var borescope = require("../../");
var Progress = require("progress");
var spawn = require("child_process").spawn;
var fs = require("fs");
var numeral = require("numeral");
var chalk = require("chalk");

// image.img needs to exist on disk.
var imageSize = fs.statSync("image.img").size;

borescope.size(imageSize);

var bar = new Progress("  downloading :bar :eta :percent :throughput", {
	complete: chalk.bgCyan(" "),
	incomplete: chalk.bgWhite(" "),
	width: 10,
	total: imageSize
});


spawn("dd", ["if=image.img"]).stdout
	.pipe(borescope)
	.pipe(spawn("dd", ["of=/dev/null"]).stdin);

borescope.on("borescopeData", function(data){
	bar.tick(data.chunkSize, {
		throughput: numeral(data.throughput).format("0.00 b") + "/s"
	});
});

borescope.on("borescopeDone", function(data){
	console.log("Average throughput: " + numeral(data.averageThroughput).format("0.00 b") + "/s");
	console.log("Duration: " + numeral(data.totalTime).format("00:00:00"));
	console.log("Transfered: " + numeral(data.totalVolume).format("0.00 b"));
});