Array.prototype.toObjectByProperty( element=>element.property )
Naveen Chawla
naveen.chwl at gmail.com
Wed Aug 9 07:56:50 UTC 2017
But I accept that this a very tall order for ES
On Wed, 9 Aug 2017 at 13:22 Naveen Chawla <naveen.chwl at gmail.com> wrote:
> Java has a great example of such a construct: default interface methods
>
> On Wed, 9 Aug 2017 at 13:21 Naveen Chawla <naveen.chwl at gmail.com> wrote:
>
>> The `toObject` behaviour doesn't need to be "implemented" on a
>> per-iterable class basis. It has a constant behaviour: iterate and on each
>> next(), pass the value to the `toKeyFromElement` and `toValueFromElement`
>> callbacks to generate and return an object. There must be some construct by
>> which that can be achieved. I wouldn't call it "better" to put it on Object
>> (for the reasons stated), but rather a compromise in the absence of any
>> such construct
>>
>> On Wed, 9 Aug 2017 at 13:12 T.J. Crowder <tj.crowder at farsightsoftware.com>
>> wrote:
>>
>>> On Wed, Aug 9, 2017 at 8:35 AM, Naveen Chawla <naveen.chwl at gmail.com>
>>> wrote:
>>> >
>>> > It would be in the `iteratable` `protocol` (interface)
>>>
>>> As Jordan said, that's likely to be a nonstarter. The Iterable protocol
>>> is *very* lean (exactly one required property) for a reason: So it can be
>>> supported with minimum investment. Much better, IMHO, to put functions on
>>> `Object` and `Map` (which is why that's what I suggested).
>>>
>>> -- T.J. Crowder
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170809/eceab88e/attachment.html>
More information about the es-discuss
mailing list