sample-size

1.0.1 • Public • Published

sample-size

🎲 pass/fail by sample size

Accepts one decimal fraction

const sample = require('sample-size');
 
filter(0) // always false
 
filter(1) // always true
 
filter(.2) // about 20% true

Usage examples

Report only about 5% of events

sample(.05) && reportEvent();

Sample about half of a list

array.filter(() => sample(.5));

Transpiled version

Environments which exclude node_modules from the transpiling pipeline should include the "browser" entry instead of "main". This exposes an ES5 commonjs module.

Also available for explicit import:

const sample = require('sample-size/dist');

Package Sidebar

Install

npm i sample-size

Weekly Downloads

1,308

Version

1.0.1

License

MIT

Unpacked Size

1.93 kB

Total Files

5

Last publish

Collaborators

  • omrilotan