Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update Winked to latest Node

  • Loading branch information...
commit 7435aaf996211e05e14a856ded7ba128310b66e6 1 parent 08a468e
Devin Torres authored
View
10 README.md
@@ -8,11 +8,11 @@ prototype, jQuery's DOM manipulation methods, and Python.
## Usage
- $ cd /path/to/linkedjs
- $ rlwrap node repl.js
- linkedjs> var list = new LinkedList();
- linkedjs> list.appendAll(new Node(1), new Node(2))
- linkedjs> list.head.next.prev
+ $ cd /path/to/winked
+ $ node repl.js
+ winked> var list = new LinkedList();
+ winked> list.appendAll(new Node(1), new Node(2))
+ winked> list.head.next.prev
{ prev: null
, next: { prev: [Circular], next: null, data: 2 }
, data: 1
View
2  index.js
@@ -1 +1 @@
-module.exports = require('./lib/linked');
+module.exports = require('./lib/winked');
View
7 lib/winked.js
@@ -23,6 +23,7 @@ var Node = function (data) {
};
LinkedList.prototype = {
+
get: function (idx) {
idx = idx || 0;
@@ -368,6 +369,7 @@ LinkedList.prototype = {
size: function () {
return this._size;
}
+
};
// Aliases
@@ -375,8 +377,13 @@ LinkedList.prototype.add = LinkedList.prototype.append;
LinkedList.prototype.addAll = LinkedList.prototype.appendAll;
LinkedList.prototype.addFirst = LinkedList.prototype.prepend;
LinkedList.prototype.addLast = LinkedList.prototype.append;
+LinkedList.prototype['delete'] = LinkedList.prototype.remove;
+LinkedList.prototype.deleteAll = LinkedList.prototype.removeAll;
+LinkedList.prototype.deleteRange = LinkedList.prototype.removeRange;
LinkedList.prototype.removeFirst = LinkedList.prototype.shift;
+LinkedList.prototype.deleteFirst = LinkedList.prototype.shift;
LinkedList.prototype.removeLast = LinkedList.prototype.pop;
+LinkedList.prototype.deleteLast = LinkedList.prototype.pop;
LinkedList.prototype.swap = LinkedList.prototype.replace;
LinkedList.prototype.index = LinkedList.prototype.indexOf;
LinkedList.prototype.count = LinkedList.prototype.size;
View
2  package.json
@@ -2,7 +2,7 @@
"name": "winked",
"version": "0.1.0",
"description": "A suggestive CommonJS linked list implementation",
- "site": "http://github.com/devinus/winked",
+ "site": "http://github.com/devinus/winked",
"author": "Devin Torres <devin@devintorres.com>",
"repositories": [
View
7 repl.js
@@ -1,7 +1,8 @@
-var repl = require('repl'),
- winked = require('./lib/winked');
+var
+ repl = require('repl'),
+ winked = require('./lib/winked');
-repl.start("winked> ").scope = {
+repl.start("winked> ").context = {
LinkedList: winked.LinkedList,
Node: winked.Node
};
View
22 test/test-linked-list.js → test/test.js
@@ -1,14 +1,16 @@
-var assert = require('assert'),
- winked = require('../lib/winked'),
- LinkedList = winked.LinkedList,
- Node = winked.Node;
+var
+ assert = require('assert'),
+ winked = require('../lib/winked'),
+ LinkedList = winked.LinkedList,
+ Node = winked.Node;
-var list = new LinkedList(),
- node1 = list.append(new Node(1)),
- node3 = list.append(new Node(3)),
- node4 = list.append(new Node(5)),
- node2 = list.insertBefore(new Node(2), node3),
- node5 = list.insertAfter(new Node(5), node4);
+var
+ list = new LinkedList(),
+ node1 = list.append(new Node(1)),
+ node3 = list.append(new Node(3)),
+ node4 = list.append(new Node(5)),
+ node2 = list.insertBefore(new Node(2), node3),
+ node5 = list.insertAfter(new Node(5), node4);
assert.strictEqual(list.length, 5, "list.length !== 5");
assert.strictEqual(list.head, node1, "head !== node1");
Please sign in to comment.
Something went wrong with that request. Please try again.