summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2015-09-26 14:27:36 -0700
committerRich Trott <rtrott@gmail.com>2015-10-08 17:32:08 -0700
commit47befffc5325a39e80208cafc9acf3827a5aa721 (patch)
tree149837427410a10c5a7e4b1d5f56c37482a48fad
parent01908d0a9a0db65b91270327850ae03ba8e0da16 (diff)
downloadandroid-node-v8-47befffc5325a39e80208cafc9acf3827a5aa721.tar.gz
android-node-v8-47befffc5325a39e80208cafc9acf3827a5aa721.tar.bz2
android-node-v8-47befffc5325a39e80208cafc9acf3827a5aa721.zip
lib,test: deprecate _linklist
Deprecate _linklist and add test to confirm internal linklist and public _linklist are the same. PR-URL: https://github.com/nodejs/node/pull/3078 Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
-rw-r--r--lib/_linklist.js57
-rw-r--r--lib/internal/linkedlist.js57
-rw-r--r--lib/timers.js2
-rw-r--r--node.gyp5
-rw-r--r--test/parallel/test-timers-linked-list.js11
5 files changed, 72 insertions, 60 deletions
diff --git a/lib/_linklist.js b/lib/_linklist.js
index 02186cfedc..08ecbea828 100644
--- a/lib/_linklist.js
+++ b/lib/_linklist.js
@@ -1,57 +1,6 @@
'use strict';
-function init(list) {
- list._idleNext = list;
- list._idlePrev = list;
-}
-exports.init = init;
+const msg = require('internal/util').printDeprecationMessage;
-
-// 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) {
- var first = list._idlePrev;
- remove(first);
- return first;
-}
-exports.shift = shift;
-
-
-// remove a item from its list
-function remove(item) {
- if (item._idleNext) {
- item._idleNext._idlePrev = item._idlePrev;
- }
-
- if (item._idlePrev) {
- item._idlePrev._idleNext = item._idleNext;
- }
-
- item._idleNext = null;
- item._idlePrev = null;
-}
-exports.remove = remove;
-
-
-// remove a item from its list and place at the end.
-function append(list, item) {
- remove(item);
- item._idleNext = list._idleNext;
- list._idleNext._idlePrev = item;
- item._idlePrev = list;
- list._idleNext = item;
-}
-exports.append = append;
-
-
-function isEmpty(list) {
- return list._idleNext === list;
-}
-exports.isEmpty = isEmpty;
+module.exports = require('internal/linkedlist');
+msg('_linklist module is deprecated. Please use a userland alternative.');
diff --git a/lib/internal/linkedlist.js b/lib/internal/linkedlist.js
new file mode 100644
index 0000000000..02186cfedc
--- /dev/null
+++ b/lib/internal/linkedlist.js
@@ -0,0 +1,57 @@
+'use strict';
+
+function init(list) {
+ list._idleNext = list;
+ list._idlePrev = list;
+}
+exports.init = init;
+
+
+// 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) {
+ var first = list._idlePrev;
+ remove(first);
+ return first;
+}
+exports.shift = shift;
+
+
+// remove a item from its list
+function remove(item) {
+ if (item._idleNext) {
+ item._idleNext._idlePrev = item._idlePrev;
+ }
+
+ if (item._idlePrev) {
+ item._idlePrev._idleNext = item._idleNext;
+ }
+
+ item._idleNext = null;
+ item._idlePrev = null;
+}
+exports.remove = remove;
+
+
+// remove a item from its list and place at the end.
+function append(list, item) {
+ remove(item);
+ item._idleNext = list._idleNext;
+ list._idleNext._idlePrev = item;
+ item._idlePrev = list;
+ list._idleNext = item;
+}
+exports.append = append;
+
+
+function isEmpty(list) {
+ return list._idleNext === list;
+}
+exports.isEmpty = isEmpty;
diff --git a/lib/timers.js b/lib/timers.js
index 5a0a8ab271..0dc9ed80b7 100644
--- a/lib/timers.js
+++ b/lib/timers.js
@@ -1,7 +1,7 @@
'use strict';
const Timer = process.binding('timer_wrap').Timer;
-const L = require('_linklist');
+const L = require('internal/linkedlist');
const assert = require('assert').ok;
const util = require('util');
const debug = util.debuglog('timer');
diff --git a/node.gyp b/node.gyp
index 386074be79..b35c8a508a 100644
--- a/node.gyp
+++ b/node.gyp
@@ -17,7 +17,6 @@
'src/node.js',
'lib/_debug_agent.js',
'lib/_debugger.js',
- 'lib/_linklist.js',
'lib/assert.js',
'lib/buffer.js',
'lib/child_process.js',
@@ -39,6 +38,7 @@
'lib/_http_outgoing.js',
'lib/_http_server.js',
'lib/https.js',
+ 'lib/_linklist.js',
'lib/module.js',
'lib/net.js',
'lib/os.js',
@@ -70,9 +70,10 @@
'lib/zlib.js',
'lib/internal/child_process.js',
'lib/internal/freelist.js',
+ 'lib/internal/linkedlist.js',
'lib/internal/module.js',
- 'lib/internal/socket_list.js',
'lib/internal/repl.js',
+ 'lib/internal/socket_list.js',
'lib/internal/util.js',
'lib/internal/streams/lazy_transform.js',
],
diff --git a/test/parallel/test-timers-linked-list.js b/test/parallel/test-timers-linked-list.js
index 00b2129d12..0c76af970a 100644
--- a/test/parallel/test-timers-linked-list.js
+++ b/test/parallel/test-timers-linked-list.js
@@ -1,8 +1,13 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var L = require('_linklist');
+// Flags: --expose-internals
+
+const common = require('../common');
+const assert = require('assert');
+const L = require('_linklist');
+const internalL = require('internal/linkedlist');
+
+assert.strictEqual(L, internalL);
var list = { name: 'list' };
var A = { name: 'A' };