Repository URL to install this package:
|
Version:
0.6.0 ▾
|
gateway-proxy
/
usr
/
share
/
gateway-proxy
/
app
/
node_modules
/
prom-client
/
lib
/
bucketGenerators.js
|
|---|
'use strict';
exports.linearBuckets = (start, width, count) => {
if (count < 1) {
throw new Error('Linear buckets needs a positive count');
}
const buckets = new Array(count);
for (let i = 0; i < count; i++) {
buckets[i] = start + i * width;
}
return buckets;
};
exports.exponentialBuckets = (start, factor, count) => {
if (start <= 0) {
throw new Error('Exponential buckets needs a positive start');
}
if (count < 1) {
throw new Error('Exponential buckets needs a positive count');
}
if (factor <= 1) {
throw new Error('Exponential buckets needs a factor greater than 1');
}
const buckets = new Array(count);
for (let i = 0; i < count; i++) {
buckets[i] = start;
start *= factor;
}
return buckets;
};