Yet Another Linked List

There are many doubly-\/linked list implementations like it, but this one is mine.

For when an array would be too big, and a Map can\textquotesingle{}t be iterated in reverse order.

\href{https://travis-ci.org/isaacs/yallist}{\texttt{ }} \href{https://coveralls.io/github/isaacs/yallist}{\texttt{ }}\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34387}{}\doxysection{basic usage}\label{md_sfcode_node_modules_yallist_README_autotoc_md34387}

\begin{DoxyCode}{0}
\DoxyCodeLine{var yallist = require('yallist')}
\DoxyCodeLine{var myList = yallist.create([1, 2, 3])}
\DoxyCodeLine{myList.push('foo')}
\DoxyCodeLine{myList.unshift('bar')}
\DoxyCodeLine{// of course pop() and shift() are there, too}
\DoxyCodeLine{console.log(myList.toArray()) // ['bar', 1, 2, 3, 'foo']}
\DoxyCodeLine{myList.forEach(function (k) \{}
\DoxyCodeLine{  // walk the list head to tail}
\DoxyCodeLine{\})}
\DoxyCodeLine{myList.forEachReverse(function (k, index, list) \{}
\DoxyCodeLine{  // walk the list tail to head}
\DoxyCodeLine{\})}
\DoxyCodeLine{var myDoubledList = myList.map(function (k) \{}
\DoxyCodeLine{  return k + k}
\DoxyCodeLine{\})}
\DoxyCodeLine{// now myDoubledList contains ['barbar', 2, 4, 6, 'foofoo']}
\DoxyCodeLine{// mapReverse is also a thing}
\DoxyCodeLine{var myDoubledListReverse = myList.mapReverse(function (k) \{}
\DoxyCodeLine{  return k + k}
\DoxyCodeLine{\}) // ['foofoo', 6, 4, 2, 'barbar']}
\DoxyCodeLine{}
\DoxyCodeLine{var reduced = myList.reduce(function (set, entry) \{}
\DoxyCodeLine{  set += entry}
\DoxyCodeLine{  return set}
\DoxyCodeLine{\}, 'start')}
\DoxyCodeLine{console.log(reduced) // 'startfoo123bar' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34388}{}\doxysection{api}\label{md_sfcode_node_modules_yallist_README_autotoc_md34388}
The whole API is considered \char`\"{}public\char`\"{}.

Functions with the same name as an Array method work more or less the same way.

There\textquotesingle{}s reverse versions of most things because that\textquotesingle{}s the point.\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34389}{}\doxysubsection{Yallist}\label{md_sfcode_node_modules_yallist_README_autotoc_md34389}
Default export, the class that holds and manages a list.

Call it with either a for\+Each-\/able (like an array) or a set of arguments, to initialize the list.

The Array-\/ish methods all act like you\textquotesingle{}d expect. No magic length, though, so if you change that it won\textquotesingle{}t automatically prune or add empty spots.\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34390}{}\doxysubsection{Yallist.\+create(..)}\label{md_sfcode_node_modules_yallist_README_autotoc_md34390}
Alias for Yallist function. Some people like factories.\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34391}{}\doxysubsubsection{yallist.\+head}\label{md_sfcode_node_modules_yallist_README_autotoc_md34391}
The first node in the list\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34392}{}\doxysubsubsection{yallist.\+tail}\label{md_sfcode_node_modules_yallist_README_autotoc_md34392}
The last node in the list\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34393}{}\doxysubsubsection{yallist.\+length}\label{md_sfcode_node_modules_yallist_README_autotoc_md34393}
The number of nodes in the list. (Change this at your peril. It is not magic like Array length.)\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34394}{}\doxysubsubsection{yallist.\+to\+Array()}\label{md_sfcode_node_modules_yallist_README_autotoc_md34394}
Convert the list to an array.\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34395}{}\doxysubsubsection{yallist.\+for\+Each(fn, \mbox{[}thisp\mbox{]})}\label{md_sfcode_node_modules_yallist_README_autotoc_md34395}
Call a function on each item in the list.\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34396}{}\doxysubsubsection{yallist.\+for\+Each\+Reverse(fn, \mbox{[}thisp\mbox{]})}\label{md_sfcode_node_modules_yallist_README_autotoc_md34396}
Call a function on each item in the list, in reverse order.\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34397}{}\doxysubsubsection{yallist.\+get(n)}\label{md_sfcode_node_modules_yallist_README_autotoc_md34397}
Get the data at position {\ttfamily n} in the list. If you use this a lot, probably better off just using an Array.\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34398}{}\doxysubsubsection{yallist.\+get\+Reverse(n)}\label{md_sfcode_node_modules_yallist_README_autotoc_md34398}
Get the data at position {\ttfamily n}, counting from the tail.\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34399}{}\doxysubsubsection{yallist.\+map(fn, thisp)}\label{md_sfcode_node_modules_yallist_README_autotoc_md34399}
Create a new Yallist with the result of calling the function on each item.\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34400}{}\doxysubsubsection{yallist.\+map\+Reverse(fn, thisp)}\label{md_sfcode_node_modules_yallist_README_autotoc_md34400}
Same as {\ttfamily map}, but in reverse.\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34401}{}\doxysubsubsection{yallist.\+pop()}\label{md_sfcode_node_modules_yallist_README_autotoc_md34401}
Get the data from the list tail, and remove the tail from the list.\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34402}{}\doxysubsubsection{yallist.\+push(item, ...)}\label{md_sfcode_node_modules_yallist_README_autotoc_md34402}
Insert one or more items to the tail of the list.\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34403}{}\doxysubsubsection{yallist.\+reduce(fn, initial\+Value)}\label{md_sfcode_node_modules_yallist_README_autotoc_md34403}
Like Array.\+reduce.\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34404}{}\doxysubsubsection{yallist.\+reduce\+Reverse}\label{md_sfcode_node_modules_yallist_README_autotoc_md34404}
Like Array.\+reduce, but in reverse.\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34405}{}\doxysubsubsection{yallist.\+reverse}\label{md_sfcode_node_modules_yallist_README_autotoc_md34405}
Reverse the list in place.\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34406}{}\doxysubsubsection{yallist.\+shift()}\label{md_sfcode_node_modules_yallist_README_autotoc_md34406}
Get the data from the list head, and remove the head from the list.\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34407}{}\doxysubsubsection{yallist.\+slice(\mbox{[}from\mbox{]}, \mbox{[}to\mbox{]})}\label{md_sfcode_node_modules_yallist_README_autotoc_md34407}
Just like Array.\+slice, but returns a new Yallist.\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34408}{}\doxysubsubsection{yallist.\+slice\+Reverse(\mbox{[}from\mbox{]}, \mbox{[}to\mbox{]})}\label{md_sfcode_node_modules_yallist_README_autotoc_md34408}
Just like yallist.\+slice, but the result is returned in reverse.\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34409}{}\doxysubsubsection{yallist.\+to\+Array()}\label{md_sfcode_node_modules_yallist_README_autotoc_md34409}
Create an array representation of the list.\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34410}{}\doxysubsubsection{yallist.\+to\+Array\+Reverse()}\label{md_sfcode_node_modules_yallist_README_autotoc_md34410}
Create a reversed array representation of the list.\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34411}{}\doxysubsubsection{yallist.\+unshift(item, ...)}\label{md_sfcode_node_modules_yallist_README_autotoc_md34411}
Insert one or more items to the head of the list.\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34412}{}\doxysubsubsection{yallist.\+unshift\+Node(node)}\label{md_sfcode_node_modules_yallist_README_autotoc_md34412}
Move a Node object to the front of the list. (That is, pull it out of wherever it lives, and make it the new head.)

If the node belongs to a different list, then that list will remove it first.\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34413}{}\doxysubsubsection{yallist.\+push\+Node(node)}\label{md_sfcode_node_modules_yallist_README_autotoc_md34413}
Move a Node object to the end of the list. (That is, pull it out of wherever it lives, and make it the new tail.)

If the node belongs to a list already, then that list will remove it first.\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34414}{}\doxysubsubsection{yallist.\+remove\+Node(node)}\label{md_sfcode_node_modules_yallist_README_autotoc_md34414}
Remove a node from the list, preserving referential integrity of head and tail and other nodes.

Will throw an error if you try to have a list remove a node that doesn\textquotesingle{}t belong to it.\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34415}{}\doxysubsection{Yallist.\+Node}\label{md_sfcode_node_modules_yallist_README_autotoc_md34415}
The class that holds the data and is actually the list.

Call with {\ttfamily var n = new Node(value, previous\+Node, next\+Node)}

Note that if you do direct operations on Nodes themselves, it\textquotesingle{}s very easy to get into weird states where the list is broken. Be careful \+:)\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34416}{}\doxysubsubsection{node.\+next}\label{md_sfcode_node_modules_yallist_README_autotoc_md34416}
The next node in the list.\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34417}{}\doxysubsubsection{node.\+prev}\label{md_sfcode_node_modules_yallist_README_autotoc_md34417}
The previous node in the list.\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34418}{}\doxysubsubsection{node.\+value}\label{md_sfcode_node_modules_yallist_README_autotoc_md34418}
The data the node contains.\hypertarget{md_sfcode_node_modules_yallist_README_autotoc_md34419}{}\doxysubsubsection{node.\+list}\label{md_sfcode_node_modules_yallist_README_autotoc_md34419}
The list to which this node belongs. (Null if it does not belong to any list.) 