Re: Object.entries(), Object.values()
Won't this create a subtle false symmetry? For the collection types, keys, entries, and values return iterators, but in this case Object.keys would have to return an array. Does that matter? ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: An Arrow Parsing Edge Case
`yield` is a keyword inside `function*` whether you're in strict or non-strict code. So that is a syntax error. -j On Thu, Mar 20, 2014 at 4:37 PM, Kevin Smith zenpars...@gmail.com wrote: Given the following edge case contained in non-strict code: function* g() { (yield) = null } Is this a syntax error, or not? The sequence `(yield)` will successfully parse as a parenthesized expression. If we re-parse as an arrow parameter list, do we view the lexical token stream as containing a yield keyword, or an identifier whose value is yield? ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Object.entries(), Object.values()
Hmm. It definitely affects the behavior when properties are added or removed during iteration. Map and Set iterators are live. But then, Map and Set iteration is fully specified and deterministic. That's not in the cards for property enumeration. So live iterators over object properties would, I'm sure, end up being less compatible across implementations than arrays, in those mutating cases. Because of that, and because Object.keys already returns an array, I think Object.values and Object.entries should too. -j P.S. Separately, I just noticed that you can say: `new Map(Object.entries(obj))`. That Map constructor was designed to compose; nice to see that it works. On Fri, Mar 21, 2014 at 8:18 AM, Kevin Smith zenpars...@gmail.com wrote: Won't this create a subtle false symmetry? For the collection types, keys, entries, and values return iterators, but in this case Object.keys would have to return an array. Does that matter? ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: An Arrow Parsing Edge Case
`yield` is a keyword inside `function*` whether you're in strict or non-strict code. Right, but not within the body of nested arrow functions: function* g() { () = { var yield; } } IIUC, this would parse fine. So I'm asking whether a yield in the token stream for an arrow parameter list should be interpreted as a keyword or an identifier when we do the rewind/transform dance. ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Object.entries(), Object.values()
On Fri, Mar 21, 2014 at 10:10 AM, Jason Orendorff jason.orendo...@gmail.com wrote: Because of that, and because Object.keys already returns an array, I think Object.values and Object.entries should too. I agree. This is also consistent with the arrays returned by getPropertyDescriptors and the proxy trap (which I believe was also going to be changed from an iterator to an array). It's not an iterator, but it's still an iterable. It should work seamlessly in common cases such as `new Map(Object.entries(obj)` (which happens to be the use case I was thinking of in particular when I wrote the OP) and `Array.from(Object.entries())` (which is pointless in itself, but we might start seeing `Array.from` in generic contexts to snapshot possible iterators/iterables). --scott ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: RegExp.escape
On 21 Mar 2014, at 16:38, C. Scott Ananian ecmascr...@cscott.net wrote: ```js function replaceTitle(title, str) { return str.replace(new RegExp(title), ...); } ``` There ought to be a standard simple way of writing this correctly. I’ve used something like this in the past: RegExp.escape = function(text) { return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$'); }; It escapes some characters that do not strictly need escaping to avoid bugs in ancient JavaScript engines. A standardized version could be even simpler, and would indeed be very welcome IMHO. ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: RegExp.escape
Continuing a 2 year old thread. http://esdiscuss.org/topic/regexp-escape ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Object.entries(), Object.values()
getPropertyDescriptors should not return an array at all but an object with all keys/symbols so it can be reused to defineProperties later on ... right? 'cause I don't see why getPropertyDescriptors would return an Array otherwise .. On Fri, Mar 21, 2014 at 8:32 AM, C. Scott Ananian ecmascr...@cscott.netwrote: On Fri, Mar 21, 2014 at 10:10 AM, Jason Orendorff jason.orendo...@gmail.com wrote: Because of that, and because Object.keys already returns an array, I think Object.values and Object.entries should too. I agree. This is also consistent with the arrays returned by getPropertyDescriptors and the proxy trap (which I believe was also going to be changed from an iterator to an array). It's not an iterator, but it's still an iterable. It should work seamlessly in common cases such as `new Map(Object.entries(obj)` (which happens to be the use case I was thinking of in particular when I wrote the OP) and `Array.from(Object.entries())` (which is pointless in itself, but we might start seeing `Array.from` in generic contexts to snapshot possible iterators/iterables). --scott ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: An Arrow Parsing Edge Case
On Mar 21, 2014, at 7:14 AM, Kevin Smith wrote: `yield` is a keyword inside `function*` whether you're in strict or non-strict code. Right, but not within the body of nested arrow functions: function* g() { () = { var yield; } } IIUC, this would parse fine. So I'm asking whether a yield in the token stream for an arrow parameter list should be interpreted as a keyword or an identifier when we do the rewind/transform dance. See bug https://bugs.ecmascript.org/show_bug.cgi?id=2504 My current spec draft disallows 'yield' as a arrow function parameter when the arrow function is directly within a generator function. Allen ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Object.entries(), Object.values()
On Fri, Mar 21, 2014 at 12:48 PM, Andrea Giammarchi andrea.giammar...@gmail.com wrote: getPropertyDescriptors should not return an array at all but an object with all keys/symbols so it can be reused to defineProperties later on ... right? 'cause I don't see why getPropertyDescriptors would return an Array otherwise .. The version I have on the agenda, that you wrote, returns an object. No disrespect to you, but this is irrelevant to the current thread. Rick ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Object.entries(), Object.values()
the version in agenda is about getOwnPropertyDescriptors ... I thought it is relevant to not mess up too much with what same method without the `Own` part also because I don't know why, getPropertyDescriptors, would return an Array, except just as simulation of the Java meaning? Or rephrasing: what is a list of descriptors useful for in ES7? On Fri, Mar 21, 2014 at 10:38 AM, Rick Waldron waldron.r...@gmail.comwrote: On Fri, Mar 21, 2014 at 12:48 PM, Andrea Giammarchi andrea.giammar...@gmail.com wrote: getPropertyDescriptors should not return an array at all but an object with all keys/symbols so it can be reused to defineProperties later on ... right? 'cause I don't see why getPropertyDescriptors would return an Array otherwise .. The version I have on the agenda, that you wrote, returns an object. No disrespect to you, but this is irrelevant to the current thread. Rick ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Object.entries(), Object.values()
also ... as side note, why this came back to me when the topic is Object.values I didn't go off topic, I just asked a clarification of a mentioned method that has nothing to do with values? Anyway ... off the thread again, I didn't mean to bring irrelevant discussions in here ... Cheers On Fri, Mar 21, 2014 at 1:02 PM, Andrea Giammarchi andrea.giammar...@gmail.com wrote: the version in agenda is about getOwnPropertyDescriptors ... I thought it is relevant to not mess up too much with what same method without the `Own` part also because I don't know why, getPropertyDescriptors, would return an Array, except just as simulation of the Java meaning? Or rephrasing: what is a list of descriptors useful for in ES7? On Fri, Mar 21, 2014 at 10:38 AM, Rick Waldron waldron.r...@gmail.comwrote: On Fri, Mar 21, 2014 at 12:48 PM, Andrea Giammarchi andrea.giammar...@gmail.com wrote: getPropertyDescriptors should not return an array at all but an object with all keys/symbols so it can be reused to defineProperties later on ... right? 'cause I don't see why getPropertyDescriptors would return an Array otherwise .. The version I have on the agenda, that you wrote, returns an object. No disrespect to you, but this is irrelevant to the current thread. Rick ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: RegExp.escape
Thanks for the back-reference, Kris. So, everyone seemed to be in favor of this, it just never got formally added. @rwaldron, are you interested in championing this for ES7 as well? --scott On Fri, Mar 21, 2014 at 12:09 PM, Kris Kowal kris.ko...@cixar.com wrote: Continuing a 2 year old thread. http://esdiscuss.org/topic/regexp-escape ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Object.entries(), Object.values()
On Fri, Mar 21, 2014 at 4:02 PM, Andrea Giammarchi andrea.giammar...@gmail.com wrote: the version in agenda is about getOwnPropertyDescriptors ... I thought it is relevant to not mess up too much with what same method without the `Own` part also because I don't know why, getPropertyDescriptors, would return an Array, except just as simulation of the Java meaning? I just assumed getPropertyDescriptors was a mistyped. Sorry for the noise. I don't think they should deviate from each other. Rick ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: RegExp.escape
On Fri, Mar 21, 2014 at 4:29 PM, C. Scott Ananian ecmascr...@cscott.netwrote: Thanks for the back-reference, Kris. So, everyone seemed to be in favor of this, it just never got formally added. @rwaldron, are you interested in championing this for ES7 as well? Not until someone writes something like this: https://gist.github.com/WebReflection/9353781, which I don't have the time to do myself. - Rick ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: RegExp.escape
How about this -- https://gist.github.com/kangax/9698100 Made it loosely based on B.2.1.1 (escape) -- kangax On Fri, Mar 21, 2014 at 5:56 PM, Rick Waldron waldron.r...@gmail.comwrote: On Fri, Mar 21, 2014 at 4:29 PM, C. Scott Ananian ecmascr...@cscott.netwrote: Thanks for the back-reference, Kris. So, everyone seemed to be in favor of this, it just never got formally added. @rwaldron, are you interested in championing this for ES7 as well? Not until someone writes something like this: https://gist.github.com/WebReflection/9353781, which I don't have the time to do myself. - Rick ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Object.entries(), Object.values()
Sorry for the confusion. I was actually referring to [[OwnPropertyKeys]] returning an Array, as discussed previously: http://esdiscuss.org/topic/object-getownpropertydescriptors-o-plural#content-34 Presumably the corresponding proxy trap would change to return an Array as well. But this is a bit off-topic for Object.entries/Object.values --- although related in the sense that the [[OwnPropertyKeys]] returns Array proposal also got support (and a +1 from be) on the list, but hasn't been formally added to the ES6 agenda as far as I can tell. --scott ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss