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

hdr-histogram-percentiles-obj

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hdr-histogram-percentiles-obj - npm Package Compare versions

Comparing version 1.0.0 to 1.0.3

2

index.js

@@ -0,1 +1,3 @@

'use strict'
const percentiles = [

@@ -2,0 +4,0 @@ 50,

{
"name": "hdr-histogram-percentiles-obj",
"version": "1.0.0",
"version": "1.0.3",
"description": "A little lib for turning native-hdr-histograms to objects",

@@ -21,2 +21,5 @@ "main": "index.js",

},
"pre-commit": [
"test"
],
"homepage": "https://github.com/thekemkid/hdr-histogram-percentiles-obj#readme",

@@ -26,4 +29,5 @@ "devDependencies": {

"standard": "^7.1.2",
"pre-commit": "^1.1.3",
"tap": "^6.1.1"
}
}

@@ -0,1 +1,3 @@

'use strict'
const test = require('tap').test

@@ -36,1 +38,31 @@ const Histogram = require('native-hdr-histogram')

})
test('should return expected numbers', (t) => {
t.plan(16)
const histogram = new Histogram(1, 10)
histogram.record(4)
histogram.record(5)
histogram.record(6)
// any of the numbers below _could_ be 0, so we do a type test instead of t.ok
const result = histPercentileObj.histAsObj(histogram, 15)
t.ok(result)
t.equal(result.average, 5)
t.equal(result.mean, 5)
t.equal(result.stddev, 0.82)
t.equal(result.min, 4)
t.equal(result.max, 6)
t.equal(result.total, 15)
const withPercentiles = histPercentileObj.addPercentiles(histogram, result)
t.ok(withPercentiles)
t.equal(withPercentiles.average, 5)
t.equal(withPercentiles.p50, 5)
t.equal(withPercentiles.p75, 5)
t.equal(withPercentiles.p90, 6)
t.equal(withPercentiles.p99, 6)
t.equal(withPercentiles.p999, 6)
t.equal(withPercentiles.p9999, 6)
t.equal(withPercentiles.p99999, 6)
})
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