Socket
Socket
Sign inDemoInstall

safe-timers

Package Overview
Dependencies
0
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.2

.travis.yml

4

component.json
{
"name": "safe-timers",
"repo": "wizcorp/safe-timers",
"version": "1.0.0",
"version": "1.0.1",
"description": "Timers with near-infinite duration support",
"scripts": [
"index.js",
"index.js"
],

@@ -9,0 +9,0 @@ "main": "index.js"

@@ -62,6 +62,6 @@ // All common browsers limit the interval to 2^31 numbers.

function callback() {
var callback = function () {
that.timeout.fireIn(that.interval);
cb();
}
cb.apply(that.timeout.thisArg, that.timeout.args);
};

@@ -68,0 +68,0 @@ this.timeout = new Timeout(callback, args, thisArg);

{
"name": "safe-timers",
"version": "1.0.1",
"version": "1.0.2",
"description": "Timers with near-infinite duration support",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -34,3 +34,3 @@ # Safe Timers

```js
const setTimeout = require('safetimers').setTimeout;
const setTimeout = require('safe-timers').setTimeout;

@@ -48,3 +48,3 @@ setTimeout(function (msg) {

```js
const setTimeoutAt = require('safetimers').setTimeoutAt;
const setTimeoutAt = require('safe-timers').setTimeoutAt;

@@ -62,3 +62,3 @@ setTimeoutAt(function (msg) {

```js
const setInterval = require('safetimers').setInterval;
const setInterval = require('safe-timers').setInterval;

@@ -76,3 +76,3 @@ setInterval(function (msg) {

```js
const setTimeout = require('safetimers').setTimeout;
const setTimeout = require('safe-timers').setTimeout;

@@ -79,0 +79,0 @@ const timer = setTimeout(function (msg) {

@@ -0,1 +1,3 @@

'use strict';
const test = require('tape');

@@ -11,5 +13,7 @@ const timers = require('..');

const interval = timers.setInterval(function () {
timers.maxInterval = originalMaxInterval;
interval.clear();
t.pass('interval fired');
interval.clear();
timers.maxInterval = originalMaxInterval;
t.equal(arguments.length, 0);
t.end();

@@ -19,6 +23,63 @@ }, 30);

t.test('Crossing the maxInterval border is fired multiple times', function (t) {
timers.maxInterval = 2;
let callCount = 0;
const interval = timers.setInterval(function () {
callCount++;
t.pass('interval fired ' + callCount + ' times');
t.equal(arguments.length, 0);
if (callCount === 2) {
timers.maxInterval = originalMaxInterval;
interval.clear();
t.end();
}
}, 30);
});
t.test('Crossing the maxInterval border with args', function (t) {
timers.maxInterval = 2;
const interval = timers.setInterval(function (a, b) {
timers.maxInterval = originalMaxInterval;
interval.clear();
t.pass('interval fired');
t.equal(arguments.length, 2);
t.equal(a, 1);
t.equal(b, 2);
t.end();
}, 30, 1, 2);
});
t.test('Crossing the maxInterval border with args is fired multiple times', function (t) {
timers.maxInterval = 2;
let callCount = 0;
const interval = timers.setInterval(function (a, b) {
callCount++;
t.pass('interval fired ' + callCount + ' times');
t.equal(arguments.length, 2);
t.equal(a, 1);
t.equal(b, 2);
if (callCount === 2) {
timers.maxInterval = originalMaxInterval;
interval.clear();
t.end();
}
}, 30, 1, 2);
});
t.test('Not crossing the maxInterval border', function (t) {
const interval = timers.setInterval(function () {
interval.clear();
t.pass('interval fired');
interval.clear();
t.equal(arguments.length, 0);
t.end();

@@ -28,3 +89,64 @@ }, 5);

t.test('Not crossing the maxInterval border is fired multiple times', function (t) {
let callCount = 0;
const interval = timers.setInterval(function () {
callCount++;
t.pass('interval fired ' + callCount + ' times');
t.equal(arguments.length, 0);
if (callCount === 2) {
timers.maxInterval = originalMaxInterval;
interval.clear();
t.end();
}
}, 5);
});
t.test('Not crossing the maxInterval border with args', function (t) {
const interval = timers.setInterval(function (a, b) {
interval.clear();
t.pass('interval fired');
t.equal(arguments.length, 2);
t.equal(a, 1);
t.equal(b, 2);
t.end();
}, 5, 1, 2);
});
t.test('Not crossing the maxInterval border with args with fired multiple times', function (t) {
let callCount = 0;
const interval = timers.setInterval(function (a, b) {
callCount++;
t.pass('interval fired ' + callCount + ' times');
t.equal(arguments.length, 2);
t.equal(a, 1);
t.equal(b, 2);
if (callCount === 2) {
timers.maxInterval = originalMaxInterval;
interval.clear();
t.end();
}
}, 5, 1, 2);
});
t.test('clear()', function (t) {
const interval = timers.setInterval(function () {
t.end('interval fired despite clear()');
}, 0);
interval.clear();
setTimeout(function () {
t.pass('interval did not fire');
t.end();
}, 10);
});
t.end();
});

@@ -0,1 +1,3 @@

'use strict';
const test = require('tape');

@@ -10,5 +12,7 @@ const timers = require('..');

timeout = timers.setTimeout(function () {
timers.setTimeout(function () {
timers.maxInterval = originalMaxInterval;
t.pass('timeout fired');
timers.maxInterval = originalMaxInterval;
t.equal(arguments.length, 0);
t.end();

@@ -18,5 +22,20 @@ }, 30);

t.test('Crossing the maxInterval border with args', function (t) {
timers.maxInterval = 2;
timers.setTimeout(function (a, b) {
timers.maxInterval = originalMaxInterval;
t.pass('timeout fired');
t.equal(arguments.length, 2);
t.equal(a, 1);
t.equal(b, 2);
t.end();
}, 30, 1, 2);
});
t.test('Not crossing the maxInterval border', function (t) {
timers.setTimeout(function () {
t.pass('timeout fired');
t.equal(arguments.length, 0);
t.end();

@@ -26,5 +45,15 @@ }, 5);

t.test('Not crossing the maxInterval border with args', function (t) {
timers.setTimeout(function (a, b) {
t.pass('timeout fired');
t.equal(arguments.length, 2);
t.equal(a, 1);
t.equal(b, 2);
t.end();
}, 5, 1, 2);
});
t.test('clear()', function (t) {
const timeout = timers.setTimeout(function () {
t.end('TimeOut fired despite clear()');
t.end('timeout fired despite clear()');
}, 0);

@@ -31,0 +60,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc