Iterator.prototype.next >= 0.1.2

Purpose

Return the next item

Syntax

Iterator#next ( );

Return values

Object

Examples

Iterate over an array

var arr = ['a', 'b', 'c'],
    iter = new Iterator(arr);

iter.next();>>> {index: 0, value: "a", done: false}

iter.next();>>> {index: 1, value: "b", done: false}

iter.next();>>> {index: 2, value: "c", done: false}

// There is no next item, so 'done' is true
iter.next();>>> {done: true}

Iterate over an object

var obj = {a: 'x', b: 'y', c: 'z'},
    iter = new Iterator(obj);

iter.next();>>> {index: 0, key: "a", value: "x", done: false}

iter.next();>>> {index: 1, key: "b", value: "y", done: false}

iter.next();>>> {index: 2, key: "c", value: "z", done: false}

iter.next();>>> {done: true}