cheerio-iterable
Adds iterable functionality to the cheerio module, and allows standard array functionality to used on cheerio/jquery elements.
Install It
npm install --save cheerio-iterable
Use it
var cheerio = ;var $ = cheerio;
Examples
Iterating over group of elements
html/xml:
foo bar
js:
formember of console;
output:
Text: foo
Text: bar
Iterating over children of an element
html/xml:
foo bar
js:
forchild of console;
output:
Text: foo
Text: bar
Using the iterable property
html/xml:
First Second Third
js:
for member of ...... console;
output:
Third
First
Second
Array prototypes
Most of the array prototype methods have been implemented for cheerio (some replacing existing functions).
The Array.prototype.find
function is implemented under element.arrayfind
for a cheerio element "element".
Using the map function:
html/xml:
Hello World
js:
var array = ;console;
output:
['Hello', 'World']
Using the reverse function
js:
var array = ;console;
html/xml:
Hello World
output:
['World', 'Hello']