Re: The generator.next() method
It already is dealt with via destructuring assignments: ```js function* gen() { var {x, y, z} = yield [1, 2, 3] return x y || z } var g = gen() var [a, b, c] = g.next().value assert(a === 1) assert(b === 2) assert(c === 3) var res = g.send({x: true, y: false, z: true}).value assert(res === true) ``` ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: The generator.next() method
`g.next()` returns `{value: [1, 2, 3], done: false}` for me, so .value is needed here. Or do you mean something else? Thanks, André No .value anywhere, though. /be Forbes Lindesay wrote: / It already is dealt with via destructuring assignments: // // ```js // function* gen() { // var {x, y, z} = yield [1, 2, 3] // return x y || z // } // var g = gen() // var [a, b, c] = g.next().value // assert(a === 1) // assert(b === 2) // assert(c === 3) // var res = g.send({x: true, y: false, z: true}).value // assert(res === true) // ```/ ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: The generator.next() method
I just wanted to demonstrate the point, I couldn't remember what the exact API agreed upon for `gen.send` is. On 23 Aug 2013, at 10:07, Andr? Bargull andre.barg...@udo.edumailto:andre.barg...@udo.edu wrote: `g.next()` returns `{value: [1, 2, 3], done: false}` for me, so .value is needed here. Or do you mean something else? Thanks, Andr? No .value anywhere, though. /be Forbes Lindesay wrote: It already is dealt with via destructuring assignments: ```js function* gen() { var {x, y, z} = yield [1, 2, 3] return x y || z } var g = gen() var [a, b, c] = g.next().value assert(a === 1) assert(b === 2) assert(c === 3) var res = g.send({x: true, y: false, z: true}).value assert(res === true) ``` ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
RE: The generator.next() method
I believe .value is indeed correct, although as André alludes to, .send() has been replaced by .next(). [Working example in Traceur][1] (this is fun!) [1]: http://traceur-compiler.googlecode.com/git/demo/repl.html#function*%20gen%28%29%20{%0A%20%20var%20{x%2C%20y%2C%20z}%20%3D%20yield%20[1%2C%202%2C%203]%0A%20%20return%20x%20%26%26%20y%20||%20z%0A}%0Avar%20g%20%3D%20gen%28%29%0Avar%20[a%2C%20b%2C%20c]%20%3D%20g.next%28%29.value%0Aconsole.log%28%27a%20%3D%3D%3D%201%27%2C%20a%20%3D%3D%3D%201%29%0Aconsole.log%28%27b%20%3D%3D%3D%202%27%2C%20b%20%3D%3D%3D%202%29%0Aconsole.log%28%27c%20%3D%3D%3D%203%27%2C%20c%20%3D%3D%3D%203%29%0Avar%20res%20%3D%20g.next%28{x%3A%20true%2C%20y%3A%20false%2C%20z%3A%20true}%29.value%0Aconsole.log%28%27res%20%3D%3D%3D%20true%27%2C%20res%20%3D%3D%3D%20true%29 ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: The generator.next() method
Domenic Denicola wrote: [Working example in Traceur][1] (this is fun!) Yes, +lots for Traceur. /be ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: The generator.next() method
André Bargull wrote: `g.next()` returns `{value: [1, 2, 3], done: false}` for me, so .value is needed here. Or do you mean something else? Sorry (to Forbes), I was thinking of when for-of orchestrates. /be Thanks, André No .value anywhere, though. /be Forbes Lindesay wrote: / It already is dealt with via destructuring assignments: // // ```js // function* gen() { // var {x, y, z} = yield [1, 2, 3] // return x y || z // } // var g = gen() // var [a, b, c] = g.next().value // assert(a === 1) // assert(b === 2) // assert(c === 3) // var res = g.send({x: true, y: false, z: true}).value // assert(res === true) // ```/ ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: The generator.next() method
I'd rather be corrected when I'm right than ignored when I'm wrong, and at the moment I'm still pretty new to the specifics of ES6 APIs :) On 23 Aug 2013, at 19:44, Brendan Eich bren...@mozilla.com wrote: André Bargull wrote: `g.next()` returns `{value: [1, 2, 3], done: false}` for me, so .value is needed here. Or do you mean something else? Sorry (to Forbes), I was thinking of when for-of orchestrates. /be Thanks, André No .value anywhere, though. /be Forbes Lindesay wrote: / It already is dealt with via destructuring assignments: // // ```js // function* gen() { // var {x, y, z} = yield [1, 2, 3] // return x y || z // } // var g = gen() // var [a, b, c] = g.next().value // assert(a === 1) // assert(b === 2) // assert(c === 3) // var res = g.send({x: true, y: false, z: true}).value // assert(res === true) // ```/ ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss