buble merge requestshttps://staging.gitlab.com/Rich-Harris/buble/-/merge_requests2017-07-28T09:32:17Zhttps://staging.gitlab.com/Rich-Harris/buble/-/merge_requests/49WIP: feat: basic async await support2017-07-28T09:32:17Zusername-removed-498219dario@uxtemple.comWIP: feat: basic async await supportHave you guys considered supporting async await? I figured that I'd kickstart the conversation with some code :). It's a very naive initial take at it that already works. I'd like to follow an approach like [kneden](https://github.com/m...Have you guys considered supporting async await? I figured that I'd kickstart the conversation with some code :). It's a very naive initial take at it that already works. I'd like to follow an approach like [kneden](https://github.com/marten-de-vries/kneden) compiling async/await to promises. Thoughts?
EDIT: Just submitted a second pass at it which supports multi-line functions mixing await and regular statements.
@Rich-Harris there's a weird thing going on with the output of the last test case:
```
input: `async function f() { await a(); thing(); await a2(); stuff(); await a3(); await a4(); }`,
output: `function f() { return Promise.resolve().then(function() { return a(); }) .then(function() { thing(); }) .then(function() { return a2(); }) .then(function() { stuff(); }) .then(function() { return a3(); }) .then(function() { return a4(); }).then(function() {}) }`
}
```
For some reason, the output adds a space before the next `.then`. I.e., `return a(); }) .then(function() { thing(); })` should read `return a(); }).then(function() { thing(); })`.
The final statement is still valid though but it's just odd to have that space there :/.
Any thoughts on why that might be happening?https://staging.gitlab.com/Rich-Harris/buble/-/merge_requests/57Add tests for mixed rest spread object and computed properties2016-12-14T21:07:40Zusername-removed-506044Add tests for mixed rest spread object and computed propertiesRef #74 Ref #74 https://staging.gitlab.com/Rich-Harris/buble/-/merge_requests/67WIP: support object rest properties2016-12-14T18:35:39Zusername-removed-498219dario@uxtemple.comWIP: support object rest properties```js
// given
let { a, b, ...rest } = obj;
// it should output
let a = obj.a;
let b = obj.b;
let rest = _objectWithoutProperties(obj, ['a', 'b']);
// where _objectWithoutProperties is a helper like babel's:
// function _objectWi...```js
// given
let { a, b, ...rest } = obj;
// it should output
let a = obj.a;
let b = obj.b;
let rest = _objectWithoutProperties(obj, ['a', 'b']);
// where _objectWithoutProperties is a helper like babel's:
// function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
```
I've added support for object rest properties in [acorn-object-spread](https://github.com/UXtemple/acorn-object-spread) ([PR pending results here](https://github.com/UXtemple/acorn-object-spread/pull/1)).
This branch is the first stab at it and doesn't really work. Hopefully this will open the door for others to take it and continue work on it, I'd absolutely love to see this land in buble as it's this feature and async/await what prevents me from using it in other projects but I don't have time now to keep at it.
Thanks for your help :)
DarĂohttps://staging.gitlab.com/Rich-Harris/buble/-/merge_requests/103Register options2016-12-13T16:57:42Zusername-removed-861968Register optionsSplit as a separate merge request from !102.
I needed a way to be able to pass `--no modules` when using the register script as a mocha compiler (https://github.com/rollup/rollup/issues/657#issuecomment-220786674).
The two environmen...Split as a separate merge request from !102.
I needed a way to be able to pass `--no modules` when using the register script as a mocha compiler (https://github.com/rollup/rollup/issues/657#issuecomment-220786674).
The two environment variables (`BUBLE_OPTION_YES` and `BUBLE_OPTION_NO`) are the equivalents of the `--no` and `--yes` command line switches.https://staging.gitlab.com/Rich-Harris/buble/-/merge_requests/109WIP: Support iterables in dangerous for-of loops2017-05-23T05:12:35Zusername-removed-634209WIP: Support iterables in dangerous for-of loopsRight now for-of loops are translated directly into typical for loops over the input's length. That's "dangerous" because it doesn't follow the spec, but works for Arrays.
This proposes adding (partial, dangerous) support for iterable...Right now for-of loops are translated directly into typical for loops over the input's length. That's "dangerous" because it doesn't follow the spec, but works for Arrays.
This proposes adding (partial, dangerous) support for iterables to for-of loops without altering the existing fast path dangerous-for-of behavior for Arrays and other looped content which has a `length` property.
This is still a "dangerous" transform!
- It still uses length when available instead of iterators
- If an environment does not define Symbol (native or polyfill), it falls back to length
- If a break or throw occurs in a loop over an iterator, the iterator is not properly "closed", which can impact code that uses `finally {}` blocks in generators.
In order to do this, for-of loops are translated into a slightly longer form.
For example, given the input:
```js
for ( let member of array ) {
doSomething( member );
}
```
The new transform will produce:
```js
for ( var list = array, iter = list.length === void 0 && typeof Symbol === 'function' && list[Symbol.iterator], i = iter ? iter.call(list) : -1; iter ? !(iter = i.next()).done : ++i < list.length; ) {
var member = iter ? iter.value : list[i];
doSomething( member );
}
```
Here's the same output with annotated expressions:
```js
// Same for loop structure is kept
for (
// Evaluate for-of's RHS (same as before)
var list = array,
// If the list does not have a length (preserve "dangerous" Array behavior)
iter = list.length === void 0 &&
// And this environment understands Symbol
typeof Symbol === 'function' &&
// Then get the list's defined iterator
// Will be undefined if Symbol.iterator is undefined
// Will be undefined if list does not define an iterator
// Will throw if list is null/undefined (spec compliant)
list[Symbol.iterator],
// If an iterator function was found
i = iter
// Then produce an iterator
? iter.call(list)
// Otherwise init an index integer
: -1
; // End init, begin test
// If an iterator is in use
iter
// Get the next iterator-result, returning true if it is not done
? !(iter = i.next()).done
// Otherwise, increment the index and return true if it's less than the list length
: ++i < list.length
; // End test, no update
) {
// If an iterator is in use
var member = iter
// Get the current value
? iter.value
// Otherwise, get the index from the list
: list[i];
doSomething( member );
}
```https://staging.gitlab.com/Rich-Harris/buble/-/merge_requests/118Pawn shop2017-07-28T01:46:47Zusername-removed-1120584Pawn shopI'm Rick Harrison, and this is my pawn shop. I work here with my old man and my son, Big Hoss. Everything in here has a story and a price. One thing I've learned after 21 years - you never know what is gonna come through that door.I'm Rick Harrison, and this is my pawn shop. I work here with my old man and my son, Big Hoss. Everything in here has a story and a price. One thing I've learned after 21 years - you never know what is gonna come through that door.