@util.js/node-timers 0.41.0 → 0.41.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Timers.js +1 -1
- package/lib/schedule.js +1 -1
- package/package.json +4 -4
- package/test/TimersTest.js +9 -9
package/lib/Timers.js
CHANGED
|
@@ -120,7 +120,7 @@ module.exports = class Timers {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
function recurse() {
|
|
123
|
-
if (functions.length
|
|
123
|
+
if (functions.length === 0) return;
|
|
124
124
|
if (!executing && Date.now() - lastRan > limitInMilliseconds) {
|
|
125
125
|
lastRan = execute.apply(null, functions.shift());
|
|
126
126
|
if (functions.length >= 1) recurse();
|
package/lib/schedule.js
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Chris Topher <c@creemama.com>",
|
|
3
3
|
"dependencies": {
|
|
4
|
-
"@util.js/privates": "0.41.
|
|
5
|
-
"cron": "1.
|
|
4
|
+
"@util.js/privates": "0.41.2",
|
|
5
|
+
"cron": "2.1.0"
|
|
6
6
|
},
|
|
7
7
|
"description": "An object to hold JavaScript timers: https://nodejs.org/api/timers.html",
|
|
8
8
|
"keywords": [
|
|
@@ -26,6 +26,6 @@
|
|
|
26
26
|
"type": "git",
|
|
27
27
|
"url": "https://github.com/creemama/utiljs/tree/master/packages/utiljs-node-timers"
|
|
28
28
|
},
|
|
29
|
-
"version": "0.41.
|
|
30
|
-
"gitHead": "
|
|
29
|
+
"version": "0.41.2",
|
|
30
|
+
"gitHead": "174b81ec0ead0221b9bb6617bc254b025bd20a5a"
|
|
31
31
|
}
|
package/test/TimersTest.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const { assert, expect } = require("chai")
|
|
4
|
-
|
|
3
|
+
const { assert, expect } = require("chai");
|
|
4
|
+
const timers = require("..");
|
|
5
5
|
|
|
6
6
|
describe("Timers#setImmediate(callback[, ...args])", () => {
|
|
7
7
|
it("should notify a callback", (done) => {
|
|
@@ -28,7 +28,7 @@ describe("Timers#setInterval(callback, delay[, ...args]) and Timers#clearInterva
|
|
|
28
28
|
let numCalls = 0;
|
|
29
29
|
const timeout = timers.setInterval(
|
|
30
30
|
(value) => {
|
|
31
|
-
if (++numCalls
|
|
31
|
+
if (++numCalls === 3) {
|
|
32
32
|
timers.clearInterval(timeout);
|
|
33
33
|
timers.setTimeout(() => {
|
|
34
34
|
try {
|
|
@@ -90,9 +90,9 @@ describe("Timers#clearImmediate(immediate)", () => {
|
|
|
90
90
|
require("fs").readFile(__filename, "utf8", (string) => {
|
|
91
91
|
try {
|
|
92
92
|
expect(numCalls).to.eql(0);
|
|
93
|
-
if (numCalls
|
|
93
|
+
if (numCalls === 0) done();
|
|
94
94
|
} catch (e) {
|
|
95
|
-
if (numCalls
|
|
95
|
+
if (numCalls === 0)
|
|
96
96
|
// We should never get here.
|
|
97
97
|
// done should have already been called.
|
|
98
98
|
done(e);
|
|
@@ -108,9 +108,9 @@ describe("Timers#clearTimeout(timeout)", () => {
|
|
|
108
108
|
timers.setTimeout(() => {
|
|
109
109
|
try {
|
|
110
110
|
expect(numCalls).to.eql(0);
|
|
111
|
-
if (numCalls
|
|
111
|
+
if (numCalls === 0) done();
|
|
112
112
|
} catch (e) {
|
|
113
|
-
if (numCalls
|
|
113
|
+
if (numCalls === 0)
|
|
114
114
|
// We should never get here.
|
|
115
115
|
// done should have already been called.
|
|
116
116
|
done(e);
|
|
@@ -165,7 +165,7 @@ describe("Times#throttle(func, limit)", () => {
|
|
|
165
165
|
expectedInternalResults.push("result " + derivedNum);
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
-
if (number
|
|
168
|
+
if (number === 2) throw new Error("error " + 2);
|
|
169
169
|
return "result " + number;
|
|
170
170
|
}
|
|
171
171
|
|
|
@@ -175,7 +175,7 @@ describe("Times#throttle(func, limit)", () => {
|
|
|
175
175
|
const expectedResult = [];
|
|
176
176
|
let errorPromise;
|
|
177
177
|
for (let i = 1; i <= n; i++) {
|
|
178
|
-
if (i
|
|
178
|
+
if (i !== 2) {
|
|
179
179
|
initialPromises.push(throttledFunction(i));
|
|
180
180
|
expectedResult.push("result " + i);
|
|
181
181
|
} else {
|