How to use the hasNext () and hasPrevious () methods for a list module with a smart list for Node

I use singly-linked-list to manage my in-out transactions, but there is no hasPrevious () method in a single connection.

Why do I need a hasPrevious () method?

In some conditions, I want to iterate over the linked list twice in the same method signature here

So, I switched to smart-list , which is provided by hasPrevious (), but I could not do this work. See example

Can anyone suggest me how to use hasNext () and hasPrevious () in a smart list or any other solution?

+4
source share
1 answer

From the source list for the module smart-list, iterators are present in _firstand the _lastlist properties:

var List = require("smart-list")
var templist = new List()

templist.push("foo");

templist._first.hasNext(); // false
0
source

All Articles