{"_id":"linkedlist-js","_rev":"841337","name":"linkedlist-js","description":"A Doubly Linked List Implementation in Javascript","dist-tags":{"latest":"1.3.0"},"maintainers":[{"name":"omranjamal","email":"o.jamal97@gmail.com"}],"time":{"modified":"2024-07-09T04:54:24.000Z","created":"2016-01-06T19:06:50.704Z","1.3.0":"2016-01-07T14:22:48.689Z","1.2.6":"2016-01-07T12:28:17.999Z","1.2.3":"2016-01-07T10:47:10.673Z","1.1.0":"2016-01-06T19:11:34.153Z","1.0.0":"2016-01-06T19:06:50.704Z"},"users":{},"author":{"name":"Omran Jamal","email":"o.jamal97@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/Hedronium/LinkedList.js.git"},"versions":{"1.3.0":{"name":"linkedlist-js","version":"1.3.0","description":"A Doubly Linked List Implementation in Javascript","scripts":{"test":"mocha tests"},"repository":{"type":"git","url":"git+https://github.com/Hedronium/LinkedList.js.git"},"keywords":["doubly","linked","list","data","structure"],"author":{"name":"Omran Jamal","email":"o.jamal97@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/Hedronium/LinkedList.js/issues"},"homepage":"https://github.com/Hedronium/LinkedList.js#readme","devDependencies":{"chai":"^3.4.1","mocha":"^2.3.4"},"gitHead":"b4cd1c9989b2d47a6586ad0b868efb8792f6a813","_id":"linkedlist-js@1.3.0","_shasum":"2b41f93338c538683f5940a0c87851388bf5de78","_from":".","_npmVersion":"2.14.7","_nodeVersion":"4.2.2","_npmUser":{"name":"omranjamal","email":"o.jamal97@gmail.com"},"dist":{"shasum":"2b41f93338c538683f5940a0c87851388bf5de78","tarball":"http://registry-npm.ywwl.com/linkedlist-js/download/linkedlist-js-1.3.0.tgz","integrity":"sha512-YwgG4Et8dJF04nsn9YuyrydUJvwmJHOQo7PzxvkT09NTgQ1yC+vXHGBolo48rTjAItIYR7YWIXh6xZsavCBSvQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDtSS3LCQ3ph2s4cSuhefpNex2ue2lIPHs0ChOhZBdeXQIgGU57VWL5nJgAYfi/cZMLQrpvxhEq0w1P3q3jgv5oez4="}],"size":3884,"noattachment":false,"key":"/linkedlist-js/-/linkedlist-js-1.3.0.tgz"},"maintainers":[{"name":"omranjamal","email":"o.jamal97@gmail.com"}],"directories":{},"publish_time":1452176568689,"_cnpm_publish_time":1452176568689},"1.2.6":{"name":"linkedlist-js","version":"1.2.6","description":"A Doubly Linked List Implementation in Javascript","scripts":{"test":"mocha tests"},"repository":{"type":"git","url":"git+https://github.com/Hedronium/LinkedList.js.git"},"keywords":["doubly","linked","list","data","structure"],"author":{"name":"Omran Jamal","email":"o.jamal97@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/Hedronium/LinkedList.js/issues"},"homepage":"https://github.com/Hedronium/LinkedList.js#readme","devDependencies":{"chai":"^3.4.1","mocha":"^2.3.4"},"gitHead":"96c79dc54e5ace2609a651a90cd80016a52e701c","_id":"linkedlist-js@1.2.6","_shasum":"a03337aa15a05855e9cc441c28bbab5b13c14f09","_from":".","_npmVersion":"2.14.7","_nodeVersion":"4.2.2","_npmUser":{"name":"omranjamal","email":"o.jamal97@gmail.com"},"dist":{"shasum":"a03337aa15a05855e9cc441c28bbab5b13c14f09","tarball":"http://registry-npm.ywwl.com/linkedlist-js/download/linkedlist-js-1.2.6.tgz","integrity":"sha512-rVXZA3bXKosbrQQYZj5jbBqFafp3A9TWBOI9LX7a9GJw2/U121ryb99tkoCQhUFQe3ok56JnrCN6L1cPkuTDZQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDVUdUvTtl9LjMnMhZ+7twTbVUE01Ly8Ol+TSD4zTdPxAiEAzeQcUeuft93y19DANqhWVwvfOjChCUVpmWHt9xXUaB0="}],"size":3680,"noattachment":false,"key":"/linkedlist-js/-/linkedlist-js-1.2.6.tgz"},"maintainers":[{"name":"omranjamal","email":"o.jamal97@gmail.com"}],"directories":{},"publish_time":1452169697999,"_cnpm_publish_time":1452169697999},"1.2.3":{"name":"linkedlist-js","version":"1.2.3","description":"A Doubly Linked List Implementation in Javascript","scripts":{"test":"mocha tests"},"repository":{"type":"git","url":"git+https://github.com/Hedronium/LinkedList.js.git"},"keywords":["doubly","linked","list","data","structure"],"author":{"name":"Omran Jamal","email":"o.jamal97@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/Hedronium/LinkedList.js/issues"},"homepage":"https://github.com/Hedronium/LinkedList.js#readme","devDependencies":{"chai":"^3.4.1","mocha":"^2.3.4"},"gitHead":"a1c9195e1f3067ae95e71453fcddbc88053e8f9b","_id":"linkedlist-js@1.2.3","_shasum":"3af72b1ff42649ceac03b0555081869b51fdbe53","_from":".","_npmVersion":"3.3.6","_nodeVersion":"5.0.0","_npmUser":{"name":"omranjamal","email":"o.jamal97@gmail.com"},"dist":{"shasum":"3af72b1ff42649ceac03b0555081869b51fdbe53","tarball":"http://registry-npm.ywwl.com/linkedlist-js/download/linkedlist-js-1.2.3.tgz","integrity":"sha512-zcNSsWz6RjtvHUkhLpmv+SHRmpnjZvwPpUtGFARXBLn1Hk+IA1OqdSnldl5G1Gsio5vhMXCiBx41IANtTMUn3Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICT9VjKgMRC0qg0Iktr64B3ZQbg3nHKKZtZMLmIC00QTAiAApVuW+LqDhx70G2OVZEkfqxtcbvRkU4WtqyJa+b4bjg=="}],"size":2668,"noattachment":false,"key":"/linkedlist-js/-/linkedlist-js-1.2.3.tgz"},"maintainers":[{"name":"omranjamal","email":"o.jamal97@gmail.com"}],"directories":{},"publish_time":1452163630673,"_cnpm_publish_time":1452163630673},"1.1.0":{"name":"linkedlist-js","version":"1.1.0","description":"A Doubly Linked List Implementation in Javascript","main":"index.js","scripts":{"test":"mocha tests"},"repository":{"type":"git","url":"git+https://github.com/Hedronium/LinkedList.js.git"},"keywords":["doubly","linked","list","data","structure"],"author":{"name":"Omran Jamal","email":"o.jamal97@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/Hedronium/LinkedList.js/issues"},"homepage":"https://github.com/Hedronium/LinkedList.js#readme","devDependencies":{"chai":"^3.4.1","mocha":"^2.3.4"},"gitHead":"a1c9195e1f3067ae95e71453fcddbc88053e8f9b","_id":"linkedlist-js@1.1.0","_shasum":"34126d60bc92c037015b7c24e0631dd4f5229000","_from":".","_npmVersion":"3.3.6","_nodeVersion":"5.0.0","_npmUser":{"name":"omranjamal","email":"o.jamal97@gmail.com"},"dist":{"shasum":"34126d60bc92c037015b7c24e0631dd4f5229000","tarball":"http://registry-npm.ywwl.com/linkedlist-js/download/linkedlist-js-1.1.0.tgz","integrity":"sha512-zgkYkRfwOLGRWdq/wGoiQgGVkqMjsYxDzyiBvmONEAzuwZSu9u1a01VfJifPbdZ/HHJe8UyE4KnayssLxBUKEQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAp1DezY8FTxH07QNv4g7qkvJmwSetlJ+MDD3JuMKhrGAiA0nXTyZalVsPlp2rT83EHE1GmbajKWCvMSYNaazp4x+A=="}],"size":2685,"noattachment":false,"key":"/linkedlist-js/-/linkedlist-js-1.1.0.tgz"},"maintainers":[{"name":"omranjamal","email":"o.jamal97@gmail.com"}],"directories":{},"publish_time":1452107494153,"_cnpm_publish_time":1452107494153},"1.0.0":{"name":"linkedlist-js","version":"1.0.0","description":"A Doubly Linked List Implementation in Javascript","main":"index.js","scripts":{"test":"mocha tests"},"repository":{"type":"git","url":"git+https://github.com/Hedronium/LinkedList.js.git"},"keywords":["doubly","linked","list","data","structure"],"author":{"name":"Omran Jamal","email":"o.jamal97@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/Hedronium/LinkedList.js/issues"},"homepage":"https://github.com/Hedronium/LinkedList.js#readme","devDependencies":{"chai":"^3.4.1","mocha":"^2.3.4"},"gitHead":"b783ad1e0b42ea9721a9b744ac30e26f59926f5c","_id":"linkedlist-js@1.0.0","_shasum":"375a4d27a85e8e28c8dd2301a4ff43ba435692f5","_from":".","_npmVersion":"3.3.6","_nodeVersion":"5.0.0","_npmUser":{"name":"omranjamal","email":"o.jamal97@gmail.com"},"dist":{"shasum":"375a4d27a85e8e28c8dd2301a4ff43ba435692f5","tarball":"http://registry-npm.ywwl.com/linkedlist-js/download/linkedlist-js-1.0.0.tgz","integrity":"sha512-DUVxxFnZJOo0agJ1i+YNpnDyqu7ufVm9iidUIMuMQ412MEXoTSdV2vNgh+co3kiMyCN+7+mjwsUFLC4vx/TOjw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDwf6KeQq10J8aQXONoFejNo8oWsJvO3wajuXi5OzHaQAiAS5uVWFi3aUYUbtbB3BHsOUrELFwGRrlXGnoSyxlH4yg=="}],"size":2669,"noattachment":false,"key":"/linkedlist-js/-/linkedlist-js-1.0.0.tgz"},"maintainers":[{"name":"omranjamal","email":"o.jamal97@gmail.com"}],"directories":{},"publish_time":1452107210704,"_cnpm_publish_time":1452107210704}},"readme":"#LinkedList.js\r\nA simple doubly linked list implementation in Javascript.\r\n\r\n## Installation\r\n```\r\nnpm install linkedlist-js\r\n```\r\n\r\n## Usage\r\nrequire the module...\r\n\r\n```javascript\r\nvar List = require('linkedlist-js').List;\r\n```\r\n\r\ninstantiate a List object...\r\n```javascript\r\nvar list = new List();\r\n\r\n// PUSH!\r\nlist.push('HUEHUE');\r\n```\r\n\r\n### Traversing the List\r\n#### with each(callback)\r\n```javascript\r\nlist.each(function (index, node) {\r\n    console.log(index + ': ' + node.value());\r\n});\r\n```\r\n\r\n#### like a badass\r\n```javascript\r\nvar node = list.head();\r\n\r\nwhile (node != null) {\r\n    console.log(node.value());\r\n    node = node.next();\r\n}\r\n```\r\n\r\n\r\n## `List` API\r\n### Adding Nodes\r\n#### push(value)\r\nCreates a node with the value specified, adds it to the end of the list and returns the `Node` object.\r\n\r\n```javascript\r\nvar a = list.push('A');\r\na.value(); //'A'\r\n```\r\n\r\n#### unshift(value)\r\nCreates a node with the value specified, adds it to the beginning of the list and returns the `Node` object.\r\n\r\n```javascript\r\nvar b = list.unshift('B');\r\nb.value(); //'B'\r\n```\r\n\r\n### Accessing Nodes\r\n#### pop\r\nReturns the tail `Node` and removes it from the list.\r\n```\r\nvar list = new List();\r\nlist.push('A');\r\nlist.push('B');\r\n\r\nlist.pop().value(); //'B'\r\n```\r\n\r\n#### shift\r\nReturns the head `Node` and removes it from the list.\r\n```\r\nvar list = new List();\r\nlist.push('A');\r\nlist.push('B');\r\n\r\nlist.shift().value(); //'A'\r\n```\r\n\r\n#### get(index)\r\nReturns the `Node` at the specified index. _(Linear Lookup, not very performant)_\r\n```javascript\r\nvar list = new List();\r\nlist.push('A');\r\nlist.push('B');\r\nlist.push('C');\r\n\r\nlist.get(1).value(); //'B'\r\n```\r\n\r\n### Peeking\r\n#### head()\r\nReturns the head `Node` or `null` in list is empty\r\n```javascript\r\nvar list = new List();\r\nvar node_a = list.push('A');\r\nvar node_b = list.push('B');\r\n\r\nlist.head() === node_a; // true\r\n```\r\n\r\n#### tail()\r\nReturns the tail `Node` or `null` in list is empty\r\n```javascript\r\nvar list = new List();\r\nvar node_a = list.push('A');\r\nvar node_b = list.push('B');\r\n\r\nlist.tail() === node_b; // true\r\n```\r\n\r\n### Searching\r\n#### find(value)\r\nFind the node with the specified value and returns it. _(Linear search, not very performant)_\r\n```javascript\r\nvar list = new List();\r\nlist.push('A');\r\nvar node_b = list.push('B');\r\n\r\nlist.find('B') === node_b; // true\r\n```\r\n\r\n### Misc\r\n#### set(index, value)\r\nSets the value of the `Node` at the specifiec index.\r\n```javascript\r\nvar list = new List();\r\nlist.push('A');\r\n\r\nlist.set(0, 'B');\r\nlist.head().value(); // 'B'\r\n```\r\n\r\n#### count()\r\nReturns the number of `Node`s in the list.\r\n```javascript\r\nvar list = new List();\r\nlist.push('A');\r\nlist.push('B');\r\n\r\nlist.count(); // 2\r\n```\r\n\r\n#### isEmpty()\r\nReturns `true` if list has no `Node`s and `false` if otherwise.\r\n```javascript\r\nvar list = new List();\r\nlist.isEmpty(); // true\r\n\r\nlist.push('A');\r\nlist.isEmpty(); // false\r\n```\r\n\r\n#### truncateTo(length)\r\nTruncates the list to the specified size.\r\n```\r\nvar list = new List();\r\nlist.push('A');\r\nlist.push('B');\r\n\r\nlist.truncateTo(1);\r\nlist.count(); // 1\r\n```\r\n\r\n#### empty()\r\nSame as calling `truncateTo(0)`. Empties the list.\r\n```\r\nvar list = new List();\r\nlist.push('A');\r\nlist.push('B');\r\n\r\nlist.empty();\r\n\r\nlist.count();   // 0\r\nlist.isEmpty(); // true\r\n```\r\n\r\n\r\n### asArray()\r\nReturns the list as an Array.\r\n```javascript\r\nvar list = new List();\r\nlist.push('A');\r\nlist.push('B');\r\n\r\nlist.asArray(); // ['A', 'B']\r\n```\r\n\r\n\r\n## `Node` API\r\n### Getters\r\n#### value()\r\nReturns the value of the `Node`\r\n\r\n#### previous()\r\nReturns the previous `Node` in the list of `null` if the node is the forst `Node`.\r\n\r\n#### next()\r\nReturns the next `Node` in the list of `null` if the node is the last `Node`.\r\n\r\n### Setters\r\n#### set(value)\r\nSets the value of the node\r\n```\r\nvar node = new Node();\r\nnode.set('A');\r\n\r\nnode.value(); // 'A'\r\n```\r\n\r\n#### setPrevious(`Node` node)\r\nSets the previous pointer of the `Node`\r\n```\r\nvar node_a = new Node();\r\nvar node_b = new Node();\r\nnode_b.setPrevious(node_a);\r\n\r\nnode_b.previous() === node_a; // true\r\n```\r\n\r\n#### setNext(`Node` node)\r\nSets the next pointer of the `Node`\r\n```\r\nvar node_a = new Node();\r\nvar node_b = new Node();\r\nnode_a.setNext(node_b);\r\n\r\nnode_a.next() === node_b; // true\r\n```\r\n\r\n### Misc\r\n#### isHead()\r\nRetunrs true if the node is the first node in the list.\r\n```javascript\r\nvar list = new List();\r\nlist.push('A');\r\nlist.push('B');\r\n\r\nlist.head().isHead(); // true\r\n```\r\n\r\n#### isTail()\r\nRetunrs true if the node is the last node in the list.\r\n```javascript\r\nvar list = new List();\r\nlist.push('A');\r\nlist.push('B');\r\n\r\nlist.tail().isTail(); // true\r\n```\r\n\r\n## Running Tests\r\n```\r\nnpm test\r\n```\r\n\r\nif you have mocha installed, you may also run\r\n```\r\nmocha tests\r\n```","_attachments":{},"homepage":"https://github.com/Hedronium/LinkedList.js#readme","bugs":{"url":"https://github.com/Hedronium/LinkedList.js/issues"},"license":"MIT"}