From 0b72fe4d14a5a6faf4ff812cb18152484921567a Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Sat, 18 Nov 2017 13:32:43 +0100 Subject: [PATCH] Normative: Ban |> await Given problems with all possibilities considered for await integration with pipeline, ban |> await within an async function as the initial option. When we have considered things further, we could add await integration as a follow-on feature. Relates to #66 --- README.md | 25 +------------------------ spec.html | 6 ------ 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/README.md b/README.md index d3d42f8..cdb6da0 100644 --- a/README.md +++ b/README.md @@ -78,30 +78,7 @@ As you can see, because the pipe operator always pipes a single result value, it ### Use of `await` -The pipeline operator allows the result of a `Promise`-returning function to be `await`ed as follows: - - -```js -x |> await f -``` - -which is the equivalent of - -```js -await f(x) -``` - -This is to allow you to `await` the result of an asynchronous function and pass it to the next function from within a function pipeline, as follows: - -```js -const userAge = userId |> await fetchUserById |> getAgeFromUser -``` - -which is the equivalent of - -```js -const userAge = getAgeFromUser(await fetchUserById(userId)) -``` +The pipeline operator does not have any special integration with async/await in its initial version, due to [issues](https://github.com/tc39/proposal-pipeline-operator/issues/66) with various alternatives discussed. To leave space for future additions to integrate await support, the not-very-useful sequence `|> await` (which would otherwise await a function, not the result of calling a function) is a SyntaxError. ### Usage with Function.prototype.papp diff --git a/spec.html b/spec.html index 8c50f2f..08ad706 100644 --- a/spec.html +++ b/spec.html @@ -36,7 +36,6 @@

Syntax

LogicalORExpression[?In, ?Yield, ?Await] [~Await] PipelineExpression[?In, ?Yield, ?Await] `|>` LogicalORExpression[?In, ?Yield, ?Await] [+Await] PipelineExpression[?In, ?Yield, ?Await] `|>` [lookahead <! {`await`}] LogicalORExpression[?In, ?Yield, ?Await] - [+Await] PipelineExpression[?In, ?Yield, ?Await] `|>` `await` LogicalORExpression[?In, ?Yield, ?Await] @@ -81,11 +80,6 @@

Runtime Semantics: Evaluation

1. Let _result_ be the result of PipelineEvaluate for |PipelineExpression| and |LogicalORExpression|. 1. Return _result_. - PipelineExpression : PipelineExpression `|>` `await` LogicalORExpression - - 1. Let _result_ be the result of PipelineEvaluate for |PipelineExpression| and |LogicalORExpression|. - 1. Return ? AsyncFunctionAwait(_result_). - PipelineExpression : LogicalORExpression 1. Return the result of evaluating |LogicalORExpression|.