Re: Additional methods for Objects (like Arrays)

2016-02-05 Thread Isiah Meadows
I think that these methods should exist in iterator prototypes, with the native iterators subclassing something like Iterator. Object.entries and Object.values should return iterators that inherit these methods. Such wrapper libraries are already coming out, and making existing arrays lazily

Re: Additional methods for Objects (like Arrays)

2016-02-05 Thread Isiah Meadows
Ok. Never mind. I forgot about that part (I hadn't looked it up lately...) :) On Fri, Feb 5, 2016, 14:26 Jordan Harband wrote: > Object.entries and Object.values must remain consistent with Object.keys > and will return arrays - luckily those are iterable too. > > On Friday,

Re: Additional methods for Objects (like Arrays)

2016-02-05 Thread Jordan Harband
Object.entries and Object.values must remain consistent with Object.keys and will return arrays - luckily those are iterable too. On Friday, February 5, 2016, Isiah Meadows wrote: > I think that these methods should exist in iterator prototypes, with the > native

Re: Additional methods for Objects (like Arrays)

2016-02-02 Thread Simon Blackwell
Although Rick makes a good point that Object.values and Object.entries make creating functionality similar to that describe by Kaustubh, they are no exactly direct. We have added the requested functions to V2.0 of JavaScript Object Extensions at https://github.com/anywhichway/joex. On Fri, Jan

Re: Additional methods for Objects (like Arrays)

2016-01-30 Thread Kaustubh Karkare
ld make them static methods of Object, I personally > don't think this is very useful. Using a for-in loop is enough in my > opinion. > > -- > From: kaustubh.kark...@gmail.com > Date: Fri, 29 Jan 2016 18:07:30 -0500 > Subject: Additional methods for Ob

RE: Additional methods for Objects (like Arrays)

2016-01-30 Thread Gary Guo
. From: kaustubh.kark...@gmail.com Date: Fri, 29 Jan 2016 18:07:30 -0500 Subject: Additional methods for Objects (like Arrays) To: es-discuss@mozilla.org I have recently come to feel the need for Object.map, which is like Array.map, except that it receive keys instead of indices

Re: Additional methods for Objects (like Arrays)

2016-01-30 Thread Gilbert B Garza
>> `Object.create(null)`, so adding to prototype is definitely a bad idea. As >> for whether we should make them static methods of Object, I personally >> don't think this is very useful. Using a for-in loop is enough in my >> opinion. >> >> --

Re: Additional methods for Objects (like Arrays)

2016-01-29 Thread Dmitry Soshnikov
On Friday, January 29, 2016, Rick Waldron wrote: > > > On Fri, Jan 29, 2016 at 6:08 PM Kaustubh Karkare < > kaustubh.kark...@gmail.com > > wrote: > >> I have recently come to feel the need for Object.map, which

Re: Additional methods for Objects (like Arrays)

2016-01-29 Thread Dmitry Soshnikov
Yeah, some languages have this functionality available for maps, e.g. Erlang http://erlang.org/doc/man/maps.html#map-2. Might be a good addition, although considering `Map` instead of `Object` is worth as well. (although, when we were discussing of adding `Map.prototype.map/filter`, it was decided

Re: Additional methods for Objects (like Arrays)

2016-01-29 Thread Dmitry Soshnikov
On Fri, Jan 29, 2016 at 3:07 PM, Kaustubh Karkare < kaustubh.kark...@gmail.com> wrote: > I have recently come to feel the need for Object.map, which is like > Array.map, > except that it receive keys instead of indices. > > Object.prototype.map = function(mapFn, context) { > return

Re: Re: Additional methods for Objects (like Arrays)

2016-01-29 Thread Alican Çubukçuoğlu
> Are these necessary given the introduction of Object.values() and Object.entries()? `Object.entries()` works. `Object.p.map()` would be shorter to write, easier to read and more compatible with functions already written for `Array.p.map()`. ___

Additional methods for Objects (like Arrays)

2016-01-29 Thread Kaustubh Karkare
I have recently come to feel the need for Object.map, which is like Array.map, except that it receive keys instead of indices. Object.prototype.map = function(mapFn, context) { return Object.keys(this) .reduce(function(result, key) { result[key] = mapFn.call(context, this[key], key,

Re: Additional methods for Objects (like Arrays)

2016-01-29 Thread Rick Waldron
On Fri, Jan 29, 2016 at 6:08 PM Kaustubh Karkare wrote: > I have recently come to feel the need for Object.map, which is like > Array.map, > except that it receive keys instead of indices. > > Object.prototype.map = function(mapFn, context) { > return

Re: Additional methods for Objects (like Arrays)

2016-01-29 Thread 段垚
在 2016/1/30 7:07, Kaustubh Karkare 写道: I have recently come to feel the need for Object.map, which is like Array.map, except that it receive keys instead of indices. Object.prototype.map = function(mapFn, context) { return Object.keys(this) .reduce(function(result, key) {