list-zipper
Simple list zipper, inspired by Haskell Data.List.Zipper. If you ever found yourself using something like this:
var array = 'foo' 'bar' 'baz';var currentIndex = 1;
Then you can replace it with:
var array = ;
Read the usage section for more details. You can also find more info about zippers here.
Installation
Node.js
npm install list-zipper
Bower
bower install list-zipper
Usage
// Move rightnextnext; // 3 // Move left; // second argument sets the index of currently focused element // 1 // It doesn't change the original arraynextnext; // [1, 2, 3] // It is immutablevar lz = ;lz; // 2lznext; // 3lz; // 2lz; // 1
More info in API Docs.