Re: Re: A few module ideas

2018-03-05 Thread James Browning
Just as a follow up to these ideas, the first proposal I suggested can be *entirely* resolved with the [top level await proposal](https://github.com/ MylesBorins/proposal-top-level-await

Re: Re: Proposal: for-of-withas a way to provide a value to the generator

2017-08-27 Thread James Browning
I've always wanted a way to do something similar so that operators over coroutines are virtually the same as over iterables, although I don't know we need it to be part of a `for-of` loop, simply having a set of utilities that help with dealing with coroutines would be nice. In particular just a s

Re: Re: A few module ideas

2017-08-20 Thread James Browning
> export values are dynamic today! you can do: > let lib = null; > export default lib; > loadScript("foo").then(o => lib = o); > but what cannot be dynamic, is the set of export names, which shapes the > module. Cariday, while interesting the main problem with this approach is it doesn't guaran

A few module ideas

2017-08-19 Thread James Browning
These are just some ideas I've had for improving es modules based on my experiences with them. The syntax and stuff with them isn't too important, the main point is the problem I'm trying to solve with each of them, feedback and criticism is welcome. # Dynamic modules One of the biggest issues I'

Re: Re: An update on rest operator ?

2017-08-03 Thread James Browning
The 1, 1 would happen if you decided that `[a, ...rest, b]` read in both directions (although personally I'm not a fan of this approach) e.g. ``` const arr = [1] const [a, ...rest, b] = arr // Roughly equivalent to: const [a] = arr.slice(0, 1) const [c] = arr.slice(-1) // So they get duplicated c

Re: Re: An update on rest operator ?

2017-08-02 Thread James Browning
I still think it's silly that `[...rest, last]` isn't allowed, the point that it's "iterable destructuring" is actually irrelevant as if there's a spread it's always coerced to an array e.g.: ``` function* nums() { yield 1 yield 2 yield 3 yield 4 } const [first, ...rest] = nums()

Re: Re: Stream + async await

2017-07-30 Thread James Browning
It'll look something like this: ```javascript async function consumeReadableStream(stream) {     const start = Date.now()     for await (const chunk of stream) { /* Do whatever you want with the chunk here e,g, await other async tasks with chunks send them off to wherever, et

Re: Strawman: Complete array and object destructuring

2017-03-29 Thread James Browning
The conversion to array is correct according to the spec (https://tc39.github.io/ecma262/#sec-runtime-semantics-iteratordestructuringassignmentevaluation final part on `AssignmentRestElement`). Given that I see absolutely no reason initial rest couldn't work, middle would work alright too but does

Re: Introduction of promise.return() and promise.throw() similar to generator.return() and generator.throw()

2017-01-14 Thread James Browning
If you really need an object that you describe then you use a function like this to create them: ```js function deferred(executor=() => {}) { let _resolve let _reject let promise = new Promise((resolve, reject) => { _resolve = resolve _reject = reject }) promise