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_npm_registry_fetch_node_modules_yallist_README_autotoc_md18640}{}\doxysection{basic usage}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18640}

\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_npm_registry_fetch_node_modules_yallist_README_autotoc_md18641}{}\doxysection{api}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18641}
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_npm_registry_fetch_node_modules_yallist_README_autotoc_md18642}{}\doxysubsection{Yallist}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18642}
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_npm_registry_fetch_node_modules_yallist_README_autotoc_md18643}{}\doxysubsection{Yallist.\+create(..)}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18643}
Alias for Yallist function. Some people like factories.\hypertarget{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18644}{}\doxysubsubsection{yallist.\+head}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18644}
The first node in the list\hypertarget{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18645}{}\doxysubsubsection{yallist.\+tail}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18645}
The last node in the list\hypertarget{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18646}{}\doxysubsubsection{yallist.\+length}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18646}
The number of nodes in the list. (Change this at your peril. It is not magic like Array length.)\hypertarget{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18647}{}\doxysubsubsection{yallist.\+to\+Array()}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18647}
Convert the list to an array.\hypertarget{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18648}{}\doxysubsubsection{yallist.\+for\+Each(fn, \mbox{[}thisp\mbox{]})}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18648}
Call a function on each item in the list.\hypertarget{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18649}{}\doxysubsubsection{yallist.\+for\+Each\+Reverse(fn, \mbox{[}thisp\mbox{]})}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18649}
Call a function on each item in the list, in reverse order.\hypertarget{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18650}{}\doxysubsubsection{yallist.\+get(n)}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18650}
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_npm_registry_fetch_node_modules_yallist_README_autotoc_md18651}{}\doxysubsubsection{yallist.\+get\+Reverse(n)}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18651}
Get the data at position {\ttfamily n}, counting from the tail.\hypertarget{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18652}{}\doxysubsubsection{yallist.\+map(fn, thisp)}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18652}
Create a new Yallist with the result of calling the function on each item.\hypertarget{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18653}{}\doxysubsubsection{yallist.\+map\+Reverse(fn, thisp)}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18653}
Same as {\ttfamily map}, but in reverse.\hypertarget{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18654}{}\doxysubsubsection{yallist.\+pop()}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18654}
Get the data from the list tail, and remove the tail from the list.\hypertarget{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18655}{}\doxysubsubsection{yallist.\+push(item, ...)}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18655}
Insert one or more items to the tail of the list.\hypertarget{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18656}{}\doxysubsubsection{yallist.\+reduce(fn, initial\+Value)}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18656}
Like Array.\+reduce.\hypertarget{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18657}{}\doxysubsubsection{yallist.\+reduce\+Reverse}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18657}
Like Array.\+reduce, but in reverse.\hypertarget{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18658}{}\doxysubsubsection{yallist.\+reverse}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18658}
Reverse the list in place.\hypertarget{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18659}{}\doxysubsubsection{yallist.\+shift()}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18659}
Get the data from the list head, and remove the head from the list.\hypertarget{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18660}{}\doxysubsubsection{yallist.\+slice(\mbox{[}from\mbox{]}, \mbox{[}to\mbox{]})}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18660}
Just like Array.\+slice, but returns a new Yallist.\hypertarget{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18661}{}\doxysubsubsection{yallist.\+slice\+Reverse(\mbox{[}from\mbox{]}, \mbox{[}to\mbox{]})}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18661}
Just like yallist.\+slice, but the result is returned in reverse.\hypertarget{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18662}{}\doxysubsubsection{yallist.\+to\+Array()}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18662}
Create an array representation of the list.\hypertarget{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18663}{}\doxysubsubsection{yallist.\+to\+Array\+Reverse()}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18663}
Create a reversed array representation of the list.\hypertarget{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18664}{}\doxysubsubsection{yallist.\+unshift(item, ...)}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18664}
Insert one or more items to the head of the list.\hypertarget{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18665}{}\doxysubsubsection{yallist.\+unshift\+Node(node)}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18665}
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_npm_registry_fetch_node_modules_yallist_README_autotoc_md18666}{}\doxysubsubsection{yallist.\+push\+Node(node)}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18666}
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_npm_registry_fetch_node_modules_yallist_README_autotoc_md18667}{}\doxysubsubsection{yallist.\+remove\+Node(node)}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18667}
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_npm_registry_fetch_node_modules_yallist_README_autotoc_md18668}{}\doxysubsection{Yallist.\+Node}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18668}
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_npm_registry_fetch_node_modules_yallist_README_autotoc_md18669}{}\doxysubsubsection{node.\+next}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18669}
The next node in the list.\hypertarget{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18670}{}\doxysubsubsection{node.\+prev}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18670}
The previous node in the list.\hypertarget{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18671}{}\doxysubsubsection{node.\+value}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18671}
The data the node contains.\hypertarget{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18672}{}\doxysubsubsection{node.\+list}\label{md_sfcode_node_modules_npm_registry_fetch_node_modules_yallist_README_autotoc_md18672}
The list to which this node belongs. (Null if it does not belong to any list.) 