Skip to content

Commit

Permalink
Merge pull request #108 from valtech-nyc/ban-await
Browse files Browse the repository at this point in the history
Remove await from current minimal proposal spec
  • Loading branch information
littledan authored Mar 18, 2018
2 parents 432b823 + 63a87d8 commit da9a5ff
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 30 deletions.
25 changes: 1 addition & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,30 +95,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 current minimal proposal makes `|> await f` an early error, so there is no support currently for `await` in the pipeline. Each proposal has a different solution to `await` in a pipeline, so support is planned. Please see the respective proposals for their solutions.

### Usage with `?` partial application syntax

Expand Down
6 changes: 0 additions & 6 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ <h1>Syntax</h1>
LogicalORExpression[?In, ?Yield, ?Await]
[~Await] PipelineExpression[?In, ?Yield, ?Await] `|>` LogicalORExpression[?In, ?Yield, ?Await]
[+Await] PipelineExpression[?In, ?Yield, ?Await] `|>` [lookahead &lt;! {`await`}] LogicalORExpression[?In, ?Yield, ?Await]
[+Await] PipelineExpression[?In, ?Yield, ?Await] `|>` `await` LogicalORExpression[?In, ?Yield, ?Await]
</ins>
</emu-grammar>
</emu-clause>
Expand Down Expand Up @@ -81,11 +80,6 @@ <h1>Runtime Semantics: Evaluation</h1>
1. Let _result_ be the result of PipelineEvaluate for |PipelineExpression| and |LogicalORExpression|.
1. Return _result_.
</emu-alg>
<emu-grammar>PipelineExpression : PipelineExpression `|>` `await` LogicalORExpression</emu-grammar>
<emu-alg>
1. Let _result_ be the result of PipelineEvaluate for |PipelineExpression| and |LogicalORExpression|.
1. Return ? AsyncFunctionAwait(_result_).
</emu-alg>
<emu-grammar>PipelineExpression : LogicalORExpression</emu-grammar>
<emu-alg>
1. Return the result of evaluating |LogicalORExpression|.
Expand Down

0 comments on commit da9a5ff

Please sign in to comment.