Skip to content

May yield* send the last yield value? #3

@hax

Description

@hax
YieldExpression:yield*AssignmentExpression
...
4. Let received be NormalCompletion(undefined).

May it update to 4. Let received be NormalCompletion(LastYieldValue) so we can satisfy:

function *g1() {
  yield function.sent
}
function *g2() {
  yield* g1()
}

g2().next(42) // => {value:42}

But allow delegate generator access the last yield value also have dark side:

function* service() {
  const token = function.sent
  if (auth(token)) {
    yield* serviceOf3rdParty()
  }
}

const serv = service()
serv.next('my-secret-token')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions