Urine
$ npm install urine -g
This library provides a simple CLI and a JavaScript API for sampling data from
a stream or file for testing or limiting data consumption. It can be installed
in whichever way you prefer, but I recommend NPM.
Documentation
Typical usage is from the command line with the urine
command. To get help or
usage information, try urine -h
. Some contrived examples of using the command
are shown below.
$ urine -p 0.1 input.txt
$ urine -p .9 -s ',' input.txt
$ urine -p .75 -s '[:;]' input.txt
$ cat input.txt | urine -p 0.001
$ tail -f /var/log/syslog | urine -p .1
$ tail -f /var/log/syslog | grep --line-buffered 'myapp' | urine -p .5
$ while true; do date; sleep 1; done | urine -p .1
There's also a public JavaScript API for working with streams inside your
application.
var urine = require('urine');
var fs = require('fs');
var stdout = process.stdout;
var stream = fs.createReadStream('input.txt');
urine(stream, stdout, {
probability: 0.1,
split: /\r\n/
});
Contributing
I accept contributions to the source via Pull Request, but passing unit tests
must be included before it will be considered for merge.
$ curl -O https://raw.githubusercontent.com/adlawson/vagrantfiles/master/nodejs/Vagrantfile
$ vagrant up
$ vagrant ssh
$ cd /srv
$ npm test
License
The content of this library is released under the MIT License by
Andrew Lawson.
You can find a copy of this license in
LICENSE
or at http://www.opensource.org/licenses/mit.