Re: Re: Stage 0 Proposal: Extensible Collection Literal

2017-07-30 Thread Naveen Chawla
If ES ever introduces a way of customizing key equality in Maps, then the literal syntax would have to be updated to include that "comparator" function. Also, curly braces with colons that separate the keys and values currently denote objects, whose keys are limited in type. Maps can have

Re: Stream + async await

2017-07-30 Thread kai zhu
the timeout handler will not work as advertised, e.g. what if io / db issues causes a network stream to intermittently respond in intervals far greater than 3ms or not at all? > On Jul 31, 2017, at 7:26 AM, James Browning wrote: > > It'll look something like

Re: Re: New Set methods - again

2017-07-30 Thread Darien Valentine
> Both the value and key arguments are equal for Sets Derp, forgot about that, you’re right. The internal algorithm references the indices, but they aren’t exposed. > [examples of unordered reduce] There are quite a few I think — in fact reductions that are order-agnostic are a pretty

Re: Re: New Set methods - again

2017-07-30 Thread Peter Jaszkowiak
> its `forEach` method does call its callback with indices. This is incorrect. Both the `value` and `key` arguments are equal for Sets, equal to the current element in the Set. >From a different reply which I mistakenly forget to CC esdiscuss > True, Sets are technically ordered by insertion

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,

Re: Stream + async await

2017-07-30 Thread kai zhu
so that everyday programmers can relate, can someone give a code-snippet of the proposal equivalent to the common-use nodejs example below? ```javascript function consumeReadableStream(stream, consumeChunk, callback) { /* * stream - readable stream * consumeChunk - has signature - function

Re: Re: Stage 0 Proposal: Extensible Collection Literal

2017-07-30 Thread Alexander Jones
https://github.com/tc39/proposal-pattern-matching/issues/47 On 30 July 2017 at 17:13, Isiah Meadows wrote: > Which is why I said there should be an issue filed there for it, so it > *does* get considered. My point was that we shouldn't get too in depth > independently of

Re: Re: Stage 0 Proposal: Extensible Collection Literal

2017-07-30 Thread Isiah Meadows
Which is why I said there should be an issue filed there for it, so it *does* get considered. My point was that we shouldn't get too in depth independently of that proposal. Currently, that strawman is so incomplete in its current state it doesn't even fully cover existing destructuring yet (like

Re: Re: Stage 0 Proposal: Extensible Collection Literal

2017-07-30 Thread Alexander Jones
Hey Isiah Good shout - definitely worth connecting pattern matching/destructuring to the same concept. Let's assume `#{}` is kept, for the avoidance of bikeshedding: ```js const map = Map#{42: "the answer"}; const #{42: fortyTwo} = someMap; // or? const {[42]: fortyTwo} = someMap;

Re: Re: Stage 0 Proposal: Extensible Collection Literal

2017-07-30 Thread Isiah Meadows
How about for now, let's hold off on anything concrete until after the pattern matching proposal gets to a point we can model the syntax and semantics after that. There's quite a bit of overlap in terms of behavior, too, which is more reason to consider this together with it.

Re: Stage 0 Proposal: Extensible Collection Literal

2017-07-30 Thread Viktor Kronvall
One of the stated advantages of the proposal is that because it is syntax driven it allows for static error messages limiting some bugs. Using a method would not give the same degree of certainty of correctness as that would require assertions to be deferred to runtime, since EcmaScript is not

Re: Stage 0 Proposal: Extensible Collection Literal

2017-07-30 Thread Naveen Chawla
I don't like the # symbol there. I would prefer something like Map.fromObject({ 'myKey': {}, myKey2: [] }); etc. On Sun, 30 Jul 2017 at 02:51 Alexander Jones wrote: > As a follow-up to https://esdiscuss.org/topic/map-literal I've finally (2 > years? Really?) written up a

Re: Stream + async await

2017-07-30 Thread Naveen Chawla
Guys! I thought of a way of doing this. Roughly it's having 2 loops, one for consumer and one for requester. Would this work?: ``` startRequestingAsync(); startConsumingAsync(); async startRequestingAsync(){ for async (const item of requestItems){ //Control the