A few more list clean ups
This commit is contained in:
parent
09994438e5
commit
29f48d48e5
@ -131,7 +131,7 @@ function insert(item, msecs) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list._idleNext === list) {
|
if (isEmpty(list)) {
|
||||||
// if empty (re)start the timer
|
// if empty (re)start the timer
|
||||||
list.again(msecs);
|
list.again(msecs);
|
||||||
}
|
}
|
||||||
@ -142,16 +142,14 @@ function insert(item, msecs) {
|
|||||||
|
|
||||||
|
|
||||||
var unenroll = exports.unenroll = function(item) {
|
var unenroll = exports.unenroll = function(item) {
|
||||||
if (item._idleNext) {
|
remove(item);
|
||||||
remove(item);
|
|
||||||
|
|
||||||
var list = lists[item._idleTimeout];
|
var list = lists[item._idleTimeout];
|
||||||
// if empty then stop the watcher
|
// if empty then stop the watcher
|
||||||
debug('unenroll');
|
debug('unenroll');
|
||||||
if (list && isEmpty(list)) {
|
if (list && isEmpty(list)) {
|
||||||
debug('unenroll: list empty');
|
debug('unenroll: list empty');
|
||||||
list.stop();
|
list.stop();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -166,6 +164,7 @@ exports.enroll = function(item, msecs) {
|
|||||||
init(item);
|
init(item);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// call this whenever the item is active (not idle)
|
// call this whenever the item is active (not idle)
|
||||||
// it will reset its timeout.
|
// it will reset its timeout.
|
||||||
exports.active = function(item) {
|
exports.active = function(item) {
|
||||||
|
@ -11,6 +11,11 @@ var D = { name: "D" };
|
|||||||
|
|
||||||
|
|
||||||
L.init(list);
|
L.init(list);
|
||||||
|
L.init(A);
|
||||||
|
L.init(B);
|
||||||
|
L.init(C);
|
||||||
|
L.init(D);
|
||||||
|
|
||||||
assert.ok(L.isEmpty(list));
|
assert.ok(L.isEmpty(list));
|
||||||
assert.equal(null, L.peek(list));
|
assert.equal(null, L.peek(list));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user