Commit 30c9a311 authored by Yerlan Bakuyev's avatar Yerlan Bakuyev

#3 test commit

parent 37d94f1d
const test = {
from: 0,
to: 10,
[Symbol.iterator]: () => {
return {
current: test.from,
last: test.to,
next() {
if(this.current <= this.last) {
return {done: false, value: this.current++};
} else {
return {done: true};
}
}
}
}
}
for(const t of test){
console.log(t);
}
const arr = [0,1,20,34];
const it = arr[Symbol.iterator]();
console.log(it.next());
console.log(it.next());
console.log(it.next());
function* tracker(){
const start = Date.now();
while(true){
const y = yield Date.now() - start;
console.log({y});
yield y;
}
}
const tr1 = tracker();
const tr2 = tracker();
console.log(tr1.next(1).value);
console.log(tr2.next().value);
console.log(tr1.next(33).value);
setTimeout(()=>{
console.log(tr1.next(3).value);
console.log(tr2.next(6).value);
console.log(tr1.next(3).value);
},2000)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment