Gathering detailed insights and metrics for simple-backoff
Gathering detailed insights and metrics for simple-backoff
Gathering detailed insights and metrics for simple-backoff
Gathering detailed insights and metrics for simple-backoff
npm install simple-backoff
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
12 Stars
3 Commits
3 Forks
4 Watching
1 Branches
1 Contributors
Updated on 20 Jun 2023
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-8.3%
255
Compared to previous day
Last week
28.9%
2,094
Compared to previous week
Last month
1.7%
7,708
Compared to previous month
Last year
-15.1%
105,098
Compared to previous year
Calculates the delay values for various backoff mechanisms. Like backoff, except it doesn't wrap everything up in an arbitrary API. Like backo/backo2, except it provides three choices of algorithm.
var LinearBackoff = require('simple-backoff').LinearBackoff;
var backoff = new LinearBackoff({
min: 10,
step: 50
});
console.log(backoff.next());
console.log(backoff.next());
backoff.reset();
console.log(backoff.next());
Outputs:
10
60
10
Four constructors are exported: LinearBackoff
, ExponentialBackoff
, FibonacciBackoff
, and FixedBackoff
. They each have slightly different options, but the first three accept a basic set of core options, passed as an options bag:
new LinearBackoff({
min: 10,
max: 10000,
step: 50,
jitter: 0
});
new ExponentialBackoff({
min: 10,
max: 10000,
factor: 2,
jitter: 0
});
new FibonacciBackoff({
min: 10,
max: 10000,
jitter: 0
});
The values shown above are the defaults.
FixedBackoff
is a bit different, and accepts an array of integers >= 0. min
and max
are invalid since the sequence is explicit. Jitter is accepted, however.
new FixedBackoff({
sequence: [100, 300, 5000, ...],
jitter: 0
});
Returns the next value in the sequence, with jitter applied (if any). Will not exceed the value of max
, except by some amount of jitter.
backoff.next()
will always return an integer >= 0
.
Resets the sequence to its initial state.
Specifies the starting/minimum value of the sequence.
Specifies the maximum value of the sequence. Calls to next
will not increase the sequence above this value.
Used only for LinearBackoff
. This value is added to the previous value to arrive at the next value in the sequence.
Used only for ExponentialBackoff
. This value is multiplied by the previous value to arrive at the next value in the sequence.
Used only for FixedBackoff
. Must be an array of one or more integers >= 0. It need not be monotonically increasing. Specifies the values to produce in sequence.
A number between 0 and 1, inclusive. The jitter
value specifies a percentage of the difference between the current and next values, centered on the current value. Jitter is cumulative.
Example:
In a linear sequence, if the current value is 100
, the step is 50
, and the jitter is 0.5
, the result of backoff.next()
will be a random value between 87.5
and 112.5
:
100
and 150
is 50
50
multiplied by the jitter value is 25
25
centered around 100
is 87.5
-112.5
The range of values used for jitter varies slightly depending on the backoff strategy:
The point of the jitter
option is to vary values such as reconnect times from clients when a server restarts to avoid everything trying to reconnect at the same time.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/3 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More