add function.sent

This commit is contained in:
Sebastian McKenzie
2015-11-17 23:02:21 -08:00
parent f8c2beb9d8
commit 983ca5c71f
21 changed files with 295 additions and 25 deletions

View File

@@ -0,0 +1,19 @@
function *adder(total = 0) {
let increment = 1;
while (true) {
let request = function.sent;
switch (request) {
case undefined: break;
case "done": return total;
default: increment = Number(request);
}
yield total += increment;
}
}
let tally = adder();
tally.next(0.1);
tally.next(0.1);
tally.next(0.1);
let last = tally.next("done");
assert.equal(last.value, 0.30000000000000004);