Simulator first commit
This commit is contained in:
28
node_modules/rtimer/.npmignore
generated
vendored
Normal file
28
node_modules/rtimer/.npmignore
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directory
|
||||
# Commenting this out is preferred by some people, see
|
||||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
|
||||
node_modules
|
||||
|
||||
# Users Environment Variables
|
||||
.lock-wscript
|
22
node_modules/rtimer/LICENSE
generated
vendored
Normal file
22
node_modules/rtimer/LICENSE
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Harri Kovalainen
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
44
node_modules/rtimer/README.md
generated
vendored
Normal file
44
node_modules/rtimer/README.md
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
# rtimer
|
||||
Persistent timer with set and clear
|
||||
|
||||
## Install
|
||||
|
||||
npm install rtimer
|
||||
|
||||
## Usage
|
||||
|
||||
rtimer has two instance methods `set` and `clear`.
|
||||
- `set` restart the timeout
|
||||
- `clear` clear the current timeout, timeout can be restarted again after clear
|
||||
- `callback` property contains the callback method
|
||||
- `delay` property contains the timeout delay
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
var rtimer = require('rtimer');
|
||||
|
||||
var start_time = +new Date();
|
||||
|
||||
// create new timeout with 1000ms delay
|
||||
var timeout = rtimer(function() {
|
||||
// this will be triggered after 1500ms
|
||||
// because of the reset
|
||||
var t = (+new Date() - start_time);
|
||||
console.log('time ' + t + ' ms');
|
||||
|
||||
// change timeout delay and callback
|
||||
timeout.delay = 500;
|
||||
timeout.callback = function() {
|
||||
console.log('Hello World!');
|
||||
};
|
||||
// reset timeout
|
||||
timeout.set();
|
||||
}, 1000);
|
||||
|
||||
// reset timeout after 500ms
|
||||
setTimeout(function() {
|
||||
timeout.set();
|
||||
}, 500);
|
||||
|
||||
```
|
27
node_modules/rtimer/example.js
generated
vendored
Normal file
27
node_modules/rtimer/example.js
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
|
||||
var rtimer = require('./index');
|
||||
|
||||
var start_time = +new Date();
|
||||
|
||||
// create new timeout with 1000ms delay
|
||||
var timeout = rtimer(function() {
|
||||
// this will be triggered after 1500ms
|
||||
// because of the reset
|
||||
var t = (+new Date() - start_time);
|
||||
console.log('time ' + t + ' ms');
|
||||
|
||||
// re-use timeout with different delay and callback
|
||||
timeout.delay = 500;
|
||||
timeout.callback = function() {
|
||||
console.log('Hello World!');
|
||||
};
|
||||
// reset timeout
|
||||
timeout.set();
|
||||
}, 1000);
|
||||
|
||||
// reset timeout after 500ms
|
||||
setTimeout(function() {
|
||||
timeout.set();
|
||||
}, 500);
|
||||
|
32
node_modules/rtimer/index.js
generated
vendored
Normal file
32
node_modules/rtimer/index.js
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
|
||||
|
||||
function Timer(callback, delay) {
|
||||
if (!(this instanceof Timer))
|
||||
return new Timer(callback, delay);
|
||||
|
||||
this._timeout = null;
|
||||
this.delay = delay;
|
||||
this.callback = callback;
|
||||
}
|
||||
module.exports = Timer;
|
||||
|
||||
/**
|
||||
* Clear current timeout
|
||||
*/
|
||||
Timer.prototype.clear = function() {
|
||||
if (this._timeout) {
|
||||
clearTimeout(this._timeout);
|
||||
this._timeout = null;
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set timeout and clear previous timeout
|
||||
*/
|
||||
Timer.prototype.set = function() {
|
||||
this.clear();
|
||||
this._timeout = setTimeout(this.callback, this.delay);
|
||||
return this;
|
||||
};
|
53
node_modules/rtimer/package.json
generated
vendored
Normal file
53
node_modules/rtimer/package.json
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
{
|
||||
"_from": "rtimer@^0.1.0",
|
||||
"_id": "rtimer@0.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-ghyBIKlOLapa3PzuGEz8n7smQ1M=",
|
||||
"_location": "/rtimer",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "rtimer@^0.1.0",
|
||||
"name": "rtimer",
|
||||
"escapedName": "rtimer",
|
||||
"rawSpec": "^0.1.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^0.1.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/mumble-client"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/rtimer/-/rtimer-0.1.0.tgz",
|
||||
"_shasum": "821c8120a94e2daa5adcfcee184cfc9fbb264353",
|
||||
"_spec": "rtimer@^0.1.0",
|
||||
"_where": "/home/sergiu/linx-audio-simulator/node_modules/mumble-client",
|
||||
"author": {
|
||||
"name": "Harri Kovalainen",
|
||||
"email": "hakovala@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/hakovala/node-rtimer/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Persistent timer with set and clear",
|
||||
"homepage": "https://github.com/hakovala/node-rtimer",
|
||||
"keywords": [
|
||||
"timer",
|
||||
"timeout"
|
||||
],
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "https://raw.githubusercontent.com/hakovala/node-rtimer/master/LICENSE"
|
||||
}
|
||||
],
|
||||
"main": "index.js",
|
||||
"name": "rtimer",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/hakovala/node-rtimer.git"
|
||||
},
|
||||
"version": "0.1.0"
|
||||
}
|
Reference in New Issue
Block a user