Socket
Socket
Sign inDemoInstall

timeout

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.1 to 0.2.1

README.md

26

lib/timeout.js
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
!(function(timeout) {
var _timeouts;
var _maxId, _timeouts;
_timeouts = {};
_maxId = 0;
return timeout.timeout = function(name, delay, fn) {

@@ -9,15 +10,13 @@ var args, data, resetTimeout;

args = Array.prototype.slice.call(arguments, 3);
if (name in _timeouts) {
data = _timeouts[name];
clearTimeout(data.id);
} else {
_timeouts[name] = data = {};
}
} else {
fn = delay;
delay = name;
name = null;
args = Array.prototype.slice.call(arguments, 2);
data = {};
name = "_timeout__" + (++_maxId);
}
if (name in _timeouts) {
data = _timeouts[name];
clearTimeout(data.id);
} else {
_timeouts[name] = data = {};
}
if (fn) {

@@ -34,8 +33,11 @@ resetTimeout = function() {

}, this);
return resetTimeout();
resetTimeout();
return name;
} else {
if (delay != null) {
return data.fn();
} else if (name in _timeouts) {
return delete _timeouts[name];
} else {
return delete _timeouts[name];
return false;
}

@@ -42,0 +44,0 @@ }

{
"name": "timeout",
"version": "0.1.1",
"version": "0.2.1",
"description": "Simple replacement for setTimeout, setInterval, and polling loops",

@@ -5,0 +5,0 @@ "keywords": ["ender", "timeout", "polling", "setTimeout", "setInterval"],

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc