array-to-linkedlist
Convert an array to Singly Linked List.
Install
Install with npm:
$ npm install array-to-linkedlist --save
Usage
Convert an array to Singly Linked List, access next node by .next
and data by .data
var arrayToLinkedlist = ; ;//=>Node { data: 1, next: Node { data: 2, next: Node { data: 3, next: null } } }
Params
;
array
: {Array} The Array to be converted into Singly Linked List.
Examples
var arrayToLinkedlist = ; var array = 123;var list = ; // Returns head of the linked listconsole; // Return data of the head node console); // Return data of the next node console; // Return all data whilelistconsole;list = listnext;
Running tests
Install dev dependencies and run test:
$ npm install -d && npm test
Author
Apurva Patel
License
Copyright © 2016, Apurva Patel. Released under the MIT license.