4

I am using singly-linked-list to manage my in-out transactions but singly-linked-list is not provided hasPrevious() method.

Why I need hasPrevious() method ?

In some conditions I want to iterate linked list twice in same method signature check here

So I moved to smart-list which is provided hasPrevious() but I could not make this work. See example

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

Community
  • 1
  • 1
Priyanka Pawar
  • 205
  • 1
  • 4
  • 16

1 Answers1

0

From the source of the list for the smart-list module, the iterators are present in the _first and _last properties of the list:

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

templist.push("foo");

templist._first.hasNext(); // false
gnerkus
  • 11,357
  • 6
  • 47
  • 71