Simulator first commit

This commit is contained in:
2019-09-18 11:11:16 +03:00
commit 6e1686be67
5028 changed files with 985331 additions and 0 deletions

1
node_modules/backo2/.npmignore generated vendored Normal file
View File

@ -0,0 +1 @@
node_modules/

12
node_modules/backo2/History.md generated vendored Normal file
View File

@ -0,0 +1,12 @@
1.0.1 / 2014-02-17
==================
* go away decimal point
* history
1.0.0 / 2014-02-17
==================
* add jitter option
* Initial commit

8
node_modules/backo2/Makefile generated vendored Normal file
View File

@ -0,0 +1,8 @@
test:
@./node_modules/.bin/mocha \
--require should \
--reporter dot \
--bail
.PHONY: test

34
node_modules/backo2/Readme.md generated vendored Normal file
View File

@ -0,0 +1,34 @@
# backo
Simple exponential backoff because the others seem to have weird abstractions.
## Installation
```
$ npm install backo
```
## Options
- `min` initial timeout in milliseconds [100]
- `max` max timeout [10000]
- `jitter` [0]
- `factor` [2]
## Example
```js
var Backoff = require('backo');
var backoff = new Backoff({ min: 100, max: 20000 });
setTimeout(function(){
something.reconnect();
}, backoff.duration());
// later when something works
backoff.reset()
```
# License
MIT

11
node_modules/backo2/component.json generated vendored Normal file
View File

@ -0,0 +1,11 @@
{
"name": "backo",
"repo": "segmentio/backo",
"dependencies": {},
"version": "1.0.1",
"description": "simple backoff without the weird abstractions",
"keywords": ["backoff"],
"license": "MIT",
"scripts": ["index.js"],
"main": "index.js"
}

85
node_modules/backo2/index.js generated vendored Normal file
View File

@ -0,0 +1,85 @@
/**
* Expose `Backoff`.
*/
module.exports = Backoff;
/**
* Initialize backoff timer with `opts`.
*
* - `min` initial timeout in milliseconds [100]
* - `max` max timeout [10000]
* - `jitter` [0]
* - `factor` [2]
*
* @param {Object} opts
* @api public
*/
function Backoff(opts) {
opts = opts || {};
this.ms = opts.min || 100;
this.max = opts.max || 10000;
this.factor = opts.factor || 2;
this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0;
this.attempts = 0;
}
/**
* Return the backoff duration.
*
* @return {Number}
* @api public
*/
Backoff.prototype.duration = function(){
var ms = this.ms * Math.pow(this.factor, this.attempts++);
if (this.jitter) {
var rand = Math.random();
var deviation = Math.floor(rand * this.jitter * ms);
ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation;
}
return Math.min(ms, this.max) | 0;
};
/**
* Reset the number of attempts.
*
* @api public
*/
Backoff.prototype.reset = function(){
this.attempts = 0;
};
/**
* Set the minimum duration
*
* @api public
*/
Backoff.prototype.setMin = function(min){
this.ms = min;
};
/**
* Set the maximum duration
*
* @api public
*/
Backoff.prototype.setMax = function(max){
this.max = max;
};
/**
* Set the jitter
*
* @api public
*/
Backoff.prototype.setJitter = function(jitter){
this.jitter = jitter;
};

47
node_modules/backo2/package.json generated vendored Normal file
View File

@ -0,0 +1,47 @@
{
"_from": "backo2@1.0.2",
"_id": "backo2@1.0.2",
"_inBundle": false,
"_integrity": "sha1-MasayLEpNjRj41s+u2n038+6eUc=",
"_location": "/backo2",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "backo2@1.0.2",
"name": "backo2",
"escapedName": "backo2",
"rawSpec": "1.0.2",
"saveSpec": null,
"fetchSpec": "1.0.2"
},
"_requiredBy": [
"/socket.io-client"
],
"_resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz",
"_shasum": "31ab1ac8b129363463e35b3ebb69f4dfcfba7947",
"_spec": "backo2@1.0.2",
"_where": "/home/sergiu/linx-audio-simulator/node_modules/socket.io-client",
"bugs": {
"url": "https://github.com/mokesmokes/backo/issues"
},
"bundleDependencies": false,
"dependencies": {},
"deprecated": false,
"description": "simple backoff based on segmentio/backo",
"devDependencies": {
"mocha": "*",
"should": "*"
},
"homepage": "https://github.com/mokesmokes/backo#readme",
"keywords": [
"backoff"
],
"license": "MIT",
"name": "backo2",
"repository": {
"type": "git",
"url": "git+https://github.com/mokesmokes/backo.git"
},
"version": "1.0.2"
}

18
node_modules/backo2/test/index.js generated vendored Normal file
View File

@ -0,0 +1,18 @@
var Backoff = require('..');
var assert = require('assert');
describe('.duration()', function(){
it('should increase the backoff', function(){
var b = new Backoff;
assert(100 == b.duration());
assert(200 == b.duration());
assert(400 == b.duration());
assert(800 == b.duration());
b.reset();
assert(100 == b.duration());
assert(200 == b.duration());
})
})