# hdr-histogram-percentiles-obj

> A little lib for turning hdr-histogram-js to objects

Latest version **3.0.0** (published 2020-09-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install hdr-histogram-percentiles-obj
pnpm add hdr-histogram-percentiles-obj
yarn add hdr-histogram-percentiles-obj
bun add hdr-histogram-percentiles-obj
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2020-09-09 |
| First published | 2016-07-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Glen Keane |
| Maintainers | matteo.collina, thekemkid |
| Keywords | hdr-histogram, hdr-histogram-js, percentiles |

## Links

- npm: https://www.npmjs.com/package/hdr-histogram-percentiles-obj
- Repository: https://github.com/GlenTiki/hdr-histogram-percentiles-obj
- Homepage: https://github.com/GlenTiki/hdr-histogram-percentiles-obj#readme
- Issues: https://github.com/GlenTiki/hdr-histogram-percentiles-obj/issues
- npm.io page: https://npm.io/package/hdr-histogram-percentiles-obj

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2020-09-09
- 2.0.1 — 2018-07-20
- 2.0.0 — 2018-07-20
- 1.2.0 — 2018-01-25
- 1.1.0 — 2016-07-21
- 1.0.3 — 2016-07-15
- 1.0.0 — 2016-07-15

## README

# hdr-histogram-percentiles-obj

## Install

```
npm install --save hdr-histogram-percentiles-obj
```

## Usage

```js
const histPercentileObj = require('hdr-histogram-percentiles-obj')
const Histogram = require('hdr-histogram-js')

const histogram = hdr.build({
  lowestDiscernibleValue: 1,
  highestTrackableValue: 100
})
const total = 0
// record some histogram data...
// total++...

const result = histPercentileObj.histAsObj(histogram, total)
const resultWithPercentiles = histPercentileObj.addPercentiles(histogram, histPercentileObj.histAsObj(histogram, total))
histPercentileObj.percentiles.forEach((p) => {
  const key = `p${p}`.replace('.', '_')
  console.log(`${p}%`, resultWithPercentiles[key])
})
```

## API

hdr-histogram-percentiles-obj has two utility functions to use

### histAsObj(histogram, total)

* `histogram`: A hdr-histogram-js object you want to get some values from in a js object
* `total`: the total amount recorded by the histogram, optional

Returns a json object with the `min`, `max`, `average` (mean) and `stddev`

### addPercentiles(histogram, histAsObjResult)

* `histogram`: A hdr-histogram-js object you want to retrieve the percentiles from
* `histAsObjResult`: the result returned when `histAsObj` is called on some hdr-histogram-js object

Returns the histAsObjResult with the percentiles properties added. Percentile properties are named `pNN_DD`, for the `NN.DD%` percentile. Eg., the 99th percentile is `p99`, while the 99.99th percentile is `p99_99`.

### percentiles

An array listing the percentiles that hdr-histogram-percentiles-obj adds, as numbers.

## Sponsor

Kindly sponsored by [nearForm](www.nearform.com)

## License

[MIT](./LICENSE)

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