Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

urine

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

urine

Sample a data stream

  • 1.2.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Urine

Urine

Master branch build status Published version MIT Licensed

$ 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.

# Sample the input.txt file, splitting around newlines with a probability of 0.1
$ urine -p 0.1 input.txt

# Sample the input.txt file, splitting around commas with a probability of 0.9
$ urine -p .9 -s ',' input.txt

# Sample the input.txt file, splitting around colons or semicolons with a probability of 0.75
$ urine -p .75 -s '[:;]' input.txt

# Sample the input.txt file through stdin with a probability of 0.001
$ cat input.txt | urine -p 0.001

# Sample the syslog file through stdin with a probability of 0.1
# Note that `tail` keeps the stream open, as will `urine`
$ tail -f /var/log/syslog | urine -p .1

# Sample the syslog file, grepping for "myapp" with a probability of 0.5
$ tail -f /var/log/syslog | grep --line-buffered 'myapp' | urine -p .5

# Sample output from a stream of `date` output with a probability of 0.1
$ 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.

Keywords

FAQs

Package last updated on 10 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc