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_webpack_node_modules_yallist_README_autotoc_md33049}{}\doxysection{basic usage}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33049}

\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_webpack_node_modules_yallist_README_autotoc_md33050}{}\doxysection{api}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33050}
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_webpack_node_modules_yallist_README_autotoc_md33051}{}\doxysubsection{Yallist}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33051}
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_webpack_node_modules_yallist_README_autotoc_md33052}{}\doxysubsection{Yallist.\+create(..)}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33052}
Alias for Yallist function. Some people like factories.\hypertarget{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33053}{}\doxysubsubsection{yallist.\+head}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33053}
The first node in the list\hypertarget{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33054}{}\doxysubsubsection{yallist.\+tail}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33054}
The last node in the list\hypertarget{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33055}{}\doxysubsubsection{yallist.\+length}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33055}
The number of nodes in the list. (Change this at your peril. It is not magic like Array length.)\hypertarget{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33056}{}\doxysubsubsection{yallist.\+to\+Array()}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33056}
Convert the list to an array.\hypertarget{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33057}{}\doxysubsubsection{yallist.\+for\+Each(fn, \mbox{[}thisp\mbox{]})}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33057}
Call a function on each item in the list.\hypertarget{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33058}{}\doxysubsubsection{yallist.\+for\+Each\+Reverse(fn, \mbox{[}thisp\mbox{]})}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33058}
Call a function on each item in the list, in reverse order.\hypertarget{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33059}{}\doxysubsubsection{yallist.\+get(n)}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33059}
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_webpack_node_modules_yallist_README_autotoc_md33060}{}\doxysubsubsection{yallist.\+get\+Reverse(n)}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33060}
Get the data at position {\ttfamily n}, counting from the tail.\hypertarget{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33061}{}\doxysubsubsection{yallist.\+map(fn, thisp)}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33061}
Create a new Yallist with the result of calling the function on each item.\hypertarget{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33062}{}\doxysubsubsection{yallist.\+map\+Reverse(fn, thisp)}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33062}
Same as {\ttfamily map}, but in reverse.\hypertarget{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33063}{}\doxysubsubsection{yallist.\+pop()}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33063}
Get the data from the list tail, and remove the tail from the list.\hypertarget{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33064}{}\doxysubsubsection{yallist.\+push(item, ...)}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33064}
Insert one or more items to the tail of the list.\hypertarget{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33065}{}\doxysubsubsection{yallist.\+reduce(fn, initial\+Value)}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33065}
Like Array.\+reduce.\hypertarget{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33066}{}\doxysubsubsection{yallist.\+reduce\+Reverse}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33066}
Like Array.\+reduce, but in reverse.\hypertarget{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33067}{}\doxysubsubsection{yallist.\+reverse}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33067}
Reverse the list in place.\hypertarget{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33068}{}\doxysubsubsection{yallist.\+shift()}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33068}
Get the data from the list head, and remove the head from the list.\hypertarget{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33069}{}\doxysubsubsection{yallist.\+slice(\mbox{[}from\mbox{]}, \mbox{[}to\mbox{]})}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33069}
Just like Array.\+slice, but returns a new Yallist.\hypertarget{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33070}{}\doxysubsubsection{yallist.\+slice\+Reverse(\mbox{[}from\mbox{]}, \mbox{[}to\mbox{]})}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33070}
Just like yallist.\+slice, but the result is returned in reverse.\hypertarget{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33071}{}\doxysubsubsection{yallist.\+to\+Array()}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33071}
Create an array representation of the list.\hypertarget{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33072}{}\doxysubsubsection{yallist.\+to\+Array\+Reverse()}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33072}
Create a reversed array representation of the list.\hypertarget{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33073}{}\doxysubsubsection{yallist.\+unshift(item, ...)}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33073}
Insert one or more items to the head of the list.\hypertarget{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33074}{}\doxysubsubsection{yallist.\+unshift\+Node(node)}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33074}
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_webpack_node_modules_yallist_README_autotoc_md33075}{}\doxysubsubsection{yallist.\+push\+Node(node)}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33075}
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_webpack_node_modules_yallist_README_autotoc_md33076}{}\doxysubsubsection{yallist.\+remove\+Node(node)}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33076}
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_webpack_node_modules_yallist_README_autotoc_md33077}{}\doxysubsection{Yallist.\+Node}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33077}
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_webpack_node_modules_yallist_README_autotoc_md33078}{}\doxysubsubsection{node.\+next}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33078}
The next node in the list.\hypertarget{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33079}{}\doxysubsubsection{node.\+prev}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33079}
The previous node in the list.\hypertarget{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33080}{}\doxysubsubsection{node.\+value}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33080}
The data the node contains.\hypertarget{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33081}{}\doxysubsubsection{node.\+list}\label{md_sfcode_node_modules_webpack_node_modules_yallist_README_autotoc_md33081}
The list to which this node belongs. (Null if it does not belong to any list.) 