Skip to content

Commit d61a511

Browse files
committed
lib: refactor internal/linkedlist
PR-URL: #11406 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent ca48071 commit d61a511

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

‎lib/internal/linkedlist.js‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,26 @@ function init(list){
44
list._idleNext=list;
55
list._idlePrev=list;
66
}
7-
exports.init=init;
87

98
// create a new linked list
109
functioncreate(){
1110
constlist={_idleNext: null,_idlePrev: null};
1211
init(list);
1312
returnlist;
1413
}
15-
exports.create=create;
1614

1715
// show the most idle item
1816
functionpeek(list){
1917
if(list._idlePrev===list)returnnull;
2018
returnlist._idlePrev;
2119
}
22-
exports.peek=peek;
23-
2420

2521
// remove the most idle item from the list
2622
functionshift(list){
2723
constfirst=list._idlePrev;
2824
remove(first);
2925
returnfirst;
3026
}
31-
exports.shift=shift;
32-
3327

3428
// remove a item from its list
3529
functionremove(item){
@@ -44,8 +38,6 @@ function remove(item){
4438
item._idleNext=null;
4539
item._idlePrev=null;
4640
}
47-
exports.remove=remove;
48-
4941

5042
// remove a item from its list and place at the end.
5143
functionappend(list,item){
@@ -62,10 +54,17 @@ function append(list, item){
6254
list._idleNext._idlePrev=item;
6355
list._idleNext=item;
6456
}
65-
exports.append=append;
66-
6757

6858
functionisEmpty(list){
6959
returnlist._idleNext===list;
7060
}
71-
exports.isEmpty=isEmpty;
61+
62+
module.exports={
63+
init,
64+
create,
65+
peek,
66+
shift,
67+
remove,
68+
append,
69+
isEmpty
70+
};

0 commit comments

Comments
(0)