-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for await with the pipeline operator
- Loading branch information
1 parent
8250ff9
commit 173784a
Showing
5 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...s/babel-plugin-proposal-pipeline-operator/test/fixtures/pipeline-operator/async/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
var incPromise = (x) => Promise.resolve(x + 1); | ||
var double = (x) => x * 2; | ||
|
||
var result = async () => 10 |> await incPromise; | ||
var result2 = async () => 10 |> await incPromise |> double; |
10 changes: 10 additions & 0 deletions
10
...ges/babel-plugin-proposal-pipeline-operator/test/fixtures/pipeline-operator/async/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
var incPromise = x => Promise.resolve(x + 1); | ||
var double = x => x * 2; | ||
|
||
var result = async () => 10 |> (await incPromise); | ||
var result2 = async () => 10 |> (await incPromise) |> double; | ||
|
||
return Promise.all([result(), result2()]).then(([r, r2]) => { | ||
assert.equal(r, 11); | ||
assert.equal(r2, 22); | ||
}); |
15 changes: 15 additions & 0 deletions
15
...babel-plugin-proposal-pipeline-operator/test/fixtures/pipeline-operator/async/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
var incPromise = x => Promise.resolve(x + 1); | ||
|
||
var double = x => x * 2; | ||
|
||
var result = async () => { | ||
var _; | ||
|
||
return _ = 10, await (0, incPromise)(_); | ||
}; | ||
|
||
var result2 = async () => { | ||
var _ref, _2; | ||
|
||
return _ref = (_2 = 10, await (0, incPromise)(_2)), double(_ref); | ||
}; |
5 changes: 5 additions & 0 deletions
5
...abel-plugin-proposal-pipeline-operator/test/fixtures/pipeline-operator/async/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"parserOpts": { | ||
"allowReturnOutsideFunction": true | ||
} | ||
} |