Re: Proposal: Map#assign

2018-01-18 Thread Tab Atkins Jr.
On Thu, Jan 18, 2018 at 11:25 AM, Peter Jaszkowiak wrote: > Isn't there a proposal for `Map#setAll`? That would fulfill the other use > case. Or, stealing naming from Python, Map#update. (I've asked for this in the past and would be very happy to see it.) ~TJ

Re: Proposal: Map#assign

2018-01-18 Thread Peter Jaszkowiak
Isn't there a proposal for `Map#setAll`? That would fulfill the other use case. On Jan 18, 2018 12:24, "Oriol _" wrote: > > I believe there's a very simple way to do this today: new Map([...mapA, > ...mapB, ...mapC]). > > But this only works if you want to create a

Re: Proposal: Map#assign

2018-01-18 Thread Oriol _
> I believe there's a very simple way to do this today: new Map([...mapA, > ...mapB, ...mapC]). But this only works if you want to create a new map, of course. Can't be used to assign to an existing map. - Oriol ___ es-discuss mailing list

Re: Proposal: Map#assign

2018-01-18 Thread T.J. Crowder
On Thu, Jan 18, 2018 at 6:59 PM, Gil Tayar wrote: > > I believe there's a very simple way to do this today: > new Map([...mapA, ...mapB, ...mapC]). facepalm Yup: https://jsfiddle.net/m23Lgkr1/ -- T.J. Crowder ___ es-discuss mailing

Re: Proposal: Map#assign

2018-01-18 Thread Gil Tayar
I believe there's a very simple way to do this today: new Map([...mapA, ...mapB, ...mapC]). Almost as nice as map.assign :-) - Gil Tayar On Thu, Jan 18, 2018 at 8:12 PM T.J. Crowder < tj.crow...@farsightsoftware.com> wrote: > On Thu, Jan 18, 2018 at 6:08 PM, Mike Samuel

Re: Proposal: Map#assign

2018-01-18 Thread T.J. Crowder
On Thu, Jan 18, 2018 at 6:08 PM, Mike Samuel wrote: > > What if, instead of a variety of assign methods, we respeced > Object.assign to do this given a Map as the left-value? I think even if one posits that that would have been a good idea when `Object.assign` was defined,

Re: Proposal: Map#assign

2018-01-18 Thread Mike Samuel
On Thu, Jan 18, 2018 at 12:37 PM, T.J. Crowder < tj.crow...@farsightsoftware.com> wrote: > On Thu, Jan 18, 2018 at 5:28 PM, 森建 wrote: > > > > This code is redundant. I just want to write > > `mapA.assign(mapB, mapC);`. > > FWIW, it would be more in keeping with

Re: Proposal: Map#assign

2018-01-18 Thread T.J. Crowder
On Thu, Jan 18, 2018 at 5:28 PM, 森建 wrote: > > This code is redundant. I just want to write > `mapA.assign(mapB, mapC);`. FWIW, it would be more in keeping with `Object.assign` if it were on `Map` rather than `Map.prototype`. E.g., you'd write the code above like this:

Proposal: Map#assign

2018-01-18 Thread 森建
Hi there, I want to add `Map#assign` to TC39 Stage 1. ECMAScript `Object` has `Object.assign`. On the other hand `Map` doesn't have assigning method. For example, we must write JavaScript like the following: ```js const mapA = new Map([["foo", 1], ["bar", 2]]); const mapB = new Map([["baz",