puma
puma copied to clipboard
ECMA 6 - Test iterators and for-of
Generate a test suite for:
let fibonacci = {
[Symbol.iterator]() {
let pre = 0, cur = 1
return {
next () {
[ pre, cur ] = [ cur, pre + cur ]
return { done: false, value: cur }
}
}
}
}
for (let n of fibonacci) {
if (n > 1000)
break
console.log(n)
}
More info at: http://es6-features.org/#IteratorForOfOperator