Skip to content

Commit

Permalink
Remove await from current minimal proposal spec
Browse files Browse the repository at this point in the history
This will now result in an early error when using `|> await f`.
Updates the README as well.
  • Loading branch information
mAAdhaTTah committed Mar 18, 2018
1 parent 4d8fbd3 commit 63a87d8
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 @@ -94,30 +94,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 63a87d8

Please sign in to comment.