# sample-size

> 🎲 pass/fail by sample size

Latest version **1.0.1** (published 2019-05-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install sample-size
pnpm add sample-size
yarn add sample-size
bun add sample-size
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-05-20 |
| First published | 2019-03-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 1.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 39 |
| Author | omrilotan |
| Maintainers | omrilotan |
| Keywords | sample, size, filter, rate, sample-rate, sample-size, 🎲 |

## Links

- npm: https://www.npmjs.com/package/sample-size
- Repository: https://github.com/omrilotan/mono
- Homepage: https://omrilotan.com/mono/sample-size/
- Issues: https://github.com/omrilotan/mono/issues
- npm.io page: https://npm.io/package/sample-size

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2019-05-20
- 1.1.2 — 2021-12-24
- 1.1.1 — 2021-07-20
- 1.1.0 — 2021-07-19
- 1.0.0 — 2019-04-09
- 0.0.0 — 2019-03-25

## README

# sample-size [![](https://img.shields.io/npm/v/sample-size.svg)](https://www.npmjs.com/package/sample-size) [![](https://img.shields.io/badge/source--000000.svg?logo=github&style=social)](https://github.com/omrilotan/mono/tree/master/packages/sample-size)

## 🎲 pass/fail by sample size
Accepts one decimal fraction

```js
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
```js
sample(.05) && reportEvent();
```

Sample about half of a list
```js
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:
```js
const sample = require('sample-size/dist');
```

---
_Source: https://npm.io/package/sample-size · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
