Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

timers-browserify

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timers-browserify - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

44

main.js
var nextTick = require('process/browser.js').nextTick;
var apply = Function.prototype.apply;
var slice = Array.prototype.slice;

@@ -8,20 +9,41 @@ var immediateIds = {};

if (typeof setTimeout !== 'undefined') exports.setTimeout = function() { return setTimeout.apply(window, arguments); };
if (typeof clearTimeout !== 'undefined') exports.clearTimeout = function() { clearTimeout.apply(window, arguments); };
if (typeof setInterval !== 'undefined') exports.setInterval = function() { return setInterval.apply(window, arguments); };
if (typeof clearInterval !== 'undefined') exports.clearInterval = function() { clearInterval.apply(window, arguments); };
exports.setTimeout = function() {
return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
};
exports.setInterval = function() {
return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
};
exports.clearTimeout =
exports.clearInterval = function(timeout) { timeout.close(); };
// TODO: Change to more efficient list approach used in Node.js
// For now, we just implement the APIs using the primitives above.
function Timeout(id, clearFn) {
this._id = id;
this._clearFn = clearFn;
}
Timeout.prototype.unref = Timeout.prototype.ref = function() {};
Timeout.prototype.close = function() {
this._clearFn.call(window, this._id);
};
exports.enroll = function(item, delay) {
item._timeoutID = setTimeout(item._onTimeout, delay);
// Does not start the time, just sets up the members needed.
exports.enroll = function(item, msecs) {
clearTimeout(item._idleTimeoutId);
item._idleTimeout = msecs;
};
exports.unenroll = function(item) {
clearTimeout(item._timeoutID);
clearTimeout(item._idleTimeoutId);
item._idleTimeout = -1;
};
exports.active = function(item) {
// our naive impl doesn't care (correctness is still preserved)
exports._unrefActive = exports.active = function(item) {
clearTimeout(item._idleTimeoutId);
var msecs = item._idleTimeout;
if (msecs >= 0) {
item._idleTimeoutId = setTimeout(function onTimeout() {
if (item._onTimeout)
item._onTimeout();
}, msecs);
}
};

@@ -28,0 +50,0 @@

@@ -5,3 +5,3 @@ {

"description": "timers module for browserify",
"version": "1.3.0",
"version": "1.4.0",
"homepage": "https://github.com/jryans/timers-browserify",

@@ -17,4 +17,6 @@ "bugs": "https://github.com/jryans/timers-browserify/issues",

"James Halliday <mail@substack.net>",
"Jan Schär <jscissr@gmail.com>",
"Johannes Ewald <johannes.ewald@peerigon.com>",
"Jonathan Prins <jon@blip.tv>"
"Jonathan Prins <jon@blip.tv>",
"Matt Esch <matt@mattesch.info>"
],

@@ -21,0 +23,0 @@ "main": "main.js",

@@ -33,4 +33,9 @@ # Overview

## I need lots of timers and want to use linked list timers as Node.js does.
Linked lists are efficient when you have thousands (millions?) of timers with the same delay.
Take a look at [timers-browserify-full](https://www.npmjs.com/package/timers-browserify-full) in this case.
# License
[MIT](http://jryans.mit-license.org/)
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc