From d61a511728919c4833ba7717777af93f51aedbc8 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Wed, 15 Feb 2017 13:33:33 -0800 Subject: [PATCH] lib: refactor internal/linkedlist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/11406 Reviewed-By: Anna Henningsen Reviewed-By: Michaƫl Zasso --- lib/internal/linkedlist.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/internal/linkedlist.js b/lib/internal/linkedlist.js index 40bca91de2..a8cba6d009 100644 --- a/lib/internal/linkedlist.js +++ b/lib/internal/linkedlist.js @@ -4,7 +4,6 @@ function init(list) { list._idleNext = list; list._idlePrev = list; } -exports.init = init; // create a new linked list function create() { @@ -12,15 +11,12 @@ function create() { init(list); return list; } -exports.create = create; // show the most idle item function peek(list) { if (list._idlePrev === list) return null; return list._idlePrev; } -exports.peek = peek; - // remove the most idle item from the list function shift(list) { @@ -28,8 +24,6 @@ function shift(list) { remove(first); return first; } -exports.shift = shift; - // remove a item from its list function remove(item) { @@ -44,8 +38,6 @@ function remove(item) { item._idleNext = null; item._idlePrev = null; } -exports.remove = remove; - // remove a item from its list and place at the end. function append(list, item) { @@ -62,10 +54,17 @@ function append(list, item) { list._idleNext._idlePrev = item; list._idleNext = item; } -exports.append = append; - function isEmpty(list) { return list._idleNext === list; } -exports.isEmpty = isEmpty; + +module.exports = { + init, + create, + peek, + shift, + remove, + append, + isEmpty +};