Skip to content
This repository has been archived by the owner on Jul 9, 2018. It is now read-only.

Commit

Permalink
Babel preset: Enable support for async generator functions (#126)
Browse files Browse the repository at this point in the history
* Babel preset: Enabled support for async generator functions

* Babel preset: Add unit tests for async generator functions

* Babel preset: Update changelog
  • Loading branch information
gziolo authored May 22, 2018
1 parent d409ace commit 4a991ec
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/babel-preset-default/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.3.0 (2018-05-22)

- Added support for async generator functions ([#126](https://github.com/WordPress/packages/pull/126))

## 1.2.1 (2018-05-18)

- Fix: Standardized `package.json` format ([#119](https://github.com/WordPress/packages/pull/119))
1 change: 1 addition & 0 deletions packages/babel-preset-default/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = {
[ require( 'babel-plugin-transform-react-jsx' ), {
pragma: 'wp.element.createElement',
} ],
require( 'babel-plugin-transform-async-generator-functions' ),
! isTestEnv && require( 'babel-plugin-transform-runtime' ),
].filter( Boolean ),
};
1 change: 1 addition & 0 deletions packages/babel-preset-default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
},
"dependencies": {
"@wordpress/browserslist-config": "^2.1.4",
"babel-plugin-transform-async-generator-functions": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-plugin-transform-react-jsx": "^6.24.1",
"babel-plugin-transform-runtime": "^6.23.0",
Expand Down
15 changes: 15 additions & 0 deletions packages/babel-preset-default/test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
describe( 'Babel preset default', () => {
async function* foo() {
await 1;
yield 2;
}

test( 'support for async generator functions', async () => {
const generator = foo();

expect( await generator.next() ).toEqual( {
done: false,
value: 2,
} );
} );
} );

0 comments on commit 4a991ec

Please sign in to comment.