Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/allain/stream-timer
An npm module for easy timing of stream flows.
https://github.com/allain/stream-timer
Last synced: 4 days ago
JSON representation
An npm module for easy timing of stream flows.
- Host: GitHub
- URL: https://github.com/allain/stream-timer
- Owner: allain
- Created: 2014-12-12T16:54:45.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-12-12T21:06:18.000Z (about 10 years ago)
- Last Synced: 2024-04-24T23:00:28.033Z (9 months ago)
- Language: JavaScript
- Size: 129 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# stream-timer
DO NOT USE YET. It's a work in progress
A naive tool for easily timing stream operations.
## Installing
``` bash
npm install --save stream-timer
```## API
### `new StreamTimer([name], [logger])`
#### parameters
* `[name]` (String): name of the timer to display in the logs, if blank, uses "timer"
* `[logger]` (Function): function which accepts a message to log, if not given, defaults to console.log### `StreamTimer.prototype.tick([label])`
#### parameters
* `[label]` (String): optional label to be used when displaying the ellapsed time of this tick#### returns
* (Transform) that prints the time elapsed since the timer was started.
### `StreamTimer.prototype.restart()`
#### returns
* (Transform) that restarts the timer and prints the current time
## Example
```javascript
var StreamTimer = require("stream-timer");
var interval = require("interval-stream");
var concat = require("array-concat-stream");
var stdout = require("stdout");
var streamArray = require("stream-array");var data = ["foo", "bar", "fizz", "baz"];
var timer = new StreamTimer('example');
streamArray(data)
.pipe(interval(1000))
.pipe(timer.restart())
.pipe(concat())
.pipe(timer.tick('step 1'))
.pipe(timer.tick('step 2'))
.pipe(stdout());```