\hypertarget{md_sfcode_node_modules_es6_iterator_README_autotoc_md9120}{}\doxysection{ECMAScript 6 Iterator interface}\label{md_sfcode_node_modules_es6_iterator_README_autotoc_md9120}
\hypertarget{md_sfcode_node_modules_es6_iterator_README_autotoc_md9121}{}\doxysubsection{Installation}\label{md_sfcode_node_modules_es6_iterator_README_autotoc_md9121}
\begin{DoxyVerb}$ npm install es6-iterator
\end{DoxyVerb}
 To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try\+: \href{http://browserify.org/}{\texttt{ Browserify}}, \href{https://github.com/medikoo/modules-webmake}{\texttt{ Webmake}} or \href{http://webpack.github.io/}{\texttt{ Webpack}}\hypertarget{md_sfcode_node_modules_es6_iterator_README_autotoc_md9122}{}\doxysection{API}\label{md_sfcode_node_modules_es6_iterator_README_autotoc_md9122}
\hypertarget{md_sfcode_node_modules_es6_iterator_README_autotoc_md9123}{}\doxysubsection{Constructors}\label{md_sfcode_node_modules_es6_iterator_README_autotoc_md9123}
\hypertarget{md_sfcode_node_modules_es6_iterator_README_autotoc_md9124}{}\doxysubsubsection{Iterator(list) \+\_\+(es6-\/iterator)\+\_\+}\label{md_sfcode_node_modules_es6_iterator_README_autotoc_md9124}
Abstract Iterator interface. Meant for extensions and not to be used on its own.

Accepts any {\itshape list} object (technically object with numeric {\itshape length} property).

{\itshape Mind it doesn\textquotesingle{}t iterate strings properly, for that use dedicated \href{\#string-iterator}{\texttt{ String\+Iterator}}}


\begin{DoxyCode}{0}
\DoxyCodeLine{var Iterator = require('es6-\/iterator')}
\DoxyCodeLine{var iterator = new Iterator([1, 2, 3]);}
\DoxyCodeLine{}
\DoxyCodeLine{iterator.next(); // \{ value: 1, done: false \}}
\DoxyCodeLine{iterator.next(); // \{ value: 2, done: false \}}
\DoxyCodeLine{iterator.next(); // \{ value: 3, done: false \}}
\DoxyCodeLine{iterator.next(); // \{ value: undefined, done: true \} }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_es6_iterator_README_autotoc_md9125}{}\doxysubsubsection{Array\+Iterator(array\+Like\mbox{[}, kind\mbox{]}) \+\_\+(es6-\/iterator/array)\+\_\+}\label{md_sfcode_node_modules_es6_iterator_README_autotoc_md9125}
Dedicated for arrays and array-\/likes. Supports three iteration kinds\+:
\begin{DoxyItemize}
\item {\bfseries{value}} \+\_\+(default)\+\_\+ -\/ Iterates values
\item {\bfseries{key}} -\/ Iterates indexes
\item {\bfseries{key+value}} -\/ Iterates keys and indexes, each iteration value is in {\itshape \mbox{[}key, value\mbox{]}} form.
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{var ArrayIterator = require('es6-\/iterator/array')}
\DoxyCodeLine{var iterator = new ArrayIterator([1, 2, 3], 'key+value');}
\DoxyCodeLine{}
\DoxyCodeLine{iterator.next(); // \{ value: [0, 1], done: false \}}
\DoxyCodeLine{iterator.next(); // \{ value: [1, 2], done: false \}}
\DoxyCodeLine{iterator.next(); // \{ value: [2, 3], done: false \}}
\DoxyCodeLine{iterator.next(); // \{ value: undefined, done: true \} }

\end{DoxyCode}


May also be used for {\itshape arguments} objects\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{(function () \{}
\DoxyCodeLine{  var iterator = new ArrayIterator(arguments);}
\DoxyCodeLine{}
\DoxyCodeLine{  iterator.next(); // \{ value: 1, done: false \}}
\DoxyCodeLine{  iterator.next(); // \{ value: 2, done: false \}}
\DoxyCodeLine{  iterator.next(); // \{ value: 3, done: false \}}
\DoxyCodeLine{  iterator.next(); // \{ value: undefined, done: true \}}
\DoxyCodeLine{\}(1, 2, 3)); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_es6_iterator_README_autotoc_md9126}{}\doxysubsubsection{String\+Iterator(str) \+\_\+(es6-\/iterator/string)\+\_\+}\label{md_sfcode_node_modules_es6_iterator_README_autotoc_md9126}
Assures proper iteration over unicode symbols. ~\newline
 See\+: \href{http://mathiasbynens.be/notes/javascript-unicode}{\texttt{ http\+://mathiasbynens.\+be/notes/javascript-\/unicode}}


\begin{DoxyCode}{0}
\DoxyCodeLine{var StringIterator = require('es6-\/iterator/string');}
\DoxyCodeLine{var iterator = new StringIterator('f🙈o🙉o🙊');}
\DoxyCodeLine{}
\DoxyCodeLine{iterator.next(); // \{ value: 'f', done: false \}}
\DoxyCodeLine{iterator.next(); // \{ value: '🙈', done: false \}}
\DoxyCodeLine{iterator.next(); // \{ value: 'o', done: false \}}
\DoxyCodeLine{iterator.next(); // \{ value: '🙉', done: false \}}
\DoxyCodeLine{iterator.next(); // \{ value: 'o', done: false \}}
\DoxyCodeLine{iterator.next(); // \{ value: '🙊', done: false \}}
\DoxyCodeLine{iterator.next(); // \{ value: undefined, done: true \} }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_es6_iterator_README_autotoc_md9127}{}\doxysubsection{Function utilities}\label{md_sfcode_node_modules_es6_iterator_README_autotoc_md9127}
\hypertarget{md_sfcode_node_modules_es6_iterator_README_autotoc_md9128}{}\doxysubsubsection{for\+Of(iterable, callback\mbox{[}, this\+Arg\mbox{]}) \+\_\+(es6-\/iterator/for-\/of)\+\_\+}\label{md_sfcode_node_modules_es6_iterator_README_autotoc_md9128}
Polyfill for ECMAScript 6 \href{https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of}{\texttt{ {\ttfamily for...of}}} statement.


\begin{DoxyCode}{0}
\DoxyCodeLine{var forOf = require('es6-\/iterator/for-\/of');}
\DoxyCodeLine{var result = [];}
\DoxyCodeLine{}
\DoxyCodeLine{forOf('🙈🙉🙊', function (monkey) \{ result.push(monkey); \});}
\DoxyCodeLine{console.log(result); // ['🙈', '🙉', '🙊']; }

\end{DoxyCode}


Optionally you can break iteration at any point\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{var result = [];}
\DoxyCodeLine{}
\DoxyCodeLine{forOf([1,2,3,4]', function (val, doBreak) \{}
\DoxyCodeLine{  result.push(monkey);}
\DoxyCodeLine{  if (val >= 3) doBreak();}
\DoxyCodeLine{\});}
\DoxyCodeLine{console.log(result); // [1, 2, 3]; }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_es6_iterator_README_autotoc_md9129}{}\doxysubsubsection{get(obj) \+\_\+(es6-\/iterator/get)\+\_\+}\label{md_sfcode_node_modules_es6_iterator_README_autotoc_md9129}
Return iterator for any iterable object.


\begin{DoxyCode}{0}
\DoxyCodeLine{var getIterator = require('es6-\/iterator/get');}
\DoxyCodeLine{var iterator = get([1,2,3]);}
\DoxyCodeLine{}
\DoxyCodeLine{iterator.next(); // \{ value: 1, done: false \}}
\DoxyCodeLine{iterator.next(); // \{ value: 2, done: false \}}
\DoxyCodeLine{iterator.next(); // \{ value: 3, done: false \}}
\DoxyCodeLine{iterator.next(); // \{ value: undefined, done: true \} }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_es6_iterator_README_autotoc_md9130}{}\doxysubsubsection{is\+Iterable(obj) \+\_\+(es6-\/iterator/is-\/iterable)\+\_\+}\label{md_sfcode_node_modules_es6_iterator_README_autotoc_md9130}
Whether {\itshape obj} is iterable


\begin{DoxyCode}{0}
\DoxyCodeLine{var isIterable = require('es6-\/iterator/is-\/iterable');}
\DoxyCodeLine{}
\DoxyCodeLine{isIterable(null); // false}
\DoxyCodeLine{isIterable(true); // false}
\DoxyCodeLine{isIterable('str'); // true}
\DoxyCodeLine{isIterable(['a', 'r', 'r']); // true}
\DoxyCodeLine{isIterable(new ArrayIterator([])); // true }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_es6_iterator_README_autotoc_md9131}{}\doxysubsubsection{valid\+Iterable(obj) \+\_\+(es6-\/iterator/valid-\/iterable)\+\_\+}\label{md_sfcode_node_modules_es6_iterator_README_autotoc_md9131}
If {\itshape obj} is an iterable it is returned. Otherwise {\itshape Type\+Error} is thrown.\hypertarget{md_sfcode_node_modules_es6_iterator_README_autotoc_md9132}{}\doxysubsection{Method extensions}\label{md_sfcode_node_modules_es6_iterator_README_autotoc_md9132}
\hypertarget{md_sfcode_node_modules_es6_iterator_README_autotoc_md9133}{}\doxysubsubsection{iterator.\+chain(iterator1\mbox{[}, …iteratorn\mbox{]}) \+\_\+(es6-\/iterator/\#/chain)\+\_\+}\label{md_sfcode_node_modules_es6_iterator_README_autotoc_md9133}
Chain multiple iterators into one.\hypertarget{md_sfcode_node_modules_es6_iterator_README_autotoc_md9134}{}\doxysubsection{Tests $<$a href=\char`\"{}https\+://travis-\/ci.\+org/medikoo/es6-\/iterator\char`\"{}$>$$<$img src=\char`\"{}https\+://travis-\/ci.\+org/medikoo/es6-\/iterator.\+png\char`\"{} alt=\char`\"{}\+Build Status\char`\"{}/$>$$<$/a$>$}\label{md_sfcode_node_modules_es6_iterator_README_autotoc_md9134}
\begin{DoxyVerb}$ npm test
\end{DoxyVerb}
 