Re: syntax for case ranges

2020-01-31 Thread Oriol _
This sounds like https://github.com/tc39/proposal-pattern-matching El 31/1/20 a les 10:57, Sultan ha escrit: For example, the following: switch (value) { case 0...9: break case 'a'...'z': break } ___ es-discuss mailing list

Re: Proposal: syntactic sugar for extracting fields from objects

2019-05-29 Thread Oriol _
If you want to add this you will need a champion, see https://github.com/tc39/ecma262/blob/master/CONTRIBUTING.md#new-feature-proposals -- Oriol El 29/5/19 a les 21:15, Григорий Карелин ha escrit: I agree. So, what does community think? Do we want to have “destructuring picking” sugar in JS

Re: Indexing HTML Attributes and Unique Indexes

2019-05-22 Thread Oriol _
> About being unique, you can always > `document.querySelector('[attribute="' + value +'"]')` This code is vulnerable to CSS injection, input values shouldn't be inserted raw into queries! You can use `CSS.escape` to sanitize. -- Oriol __

Re: Polyfilling Object.observe

2018-07-28 Thread Oriol _
roperties in property descriptors and read them later, ignoring the receiver when calling getters and setters, assuming all objects are extensible and all properties are configurable, etc. --Oriol pEpkey.asc Description: pEpkey.asc ___ es-discuss mailin

Re: [Proposal] ignoreCase method

2018-06-27 Thread Oriol _
; const {compare} = new Intl.Collator(undefined, {sensitivity: "base"}); if (manyStrings.some(s => compare(s, stringOne) == 0)) {     // Yes, it was found } ``` -- Oriol pEpkey.asc Description: pEpkey.asc ___ es-discuss maili

Re: Embarrassingly Simple Spec Question

2018-05-22 Thread Oriol _
obscure indeed. -- Oriol ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Proposal: allow primitives to be explicitly returned from constructors

2018-04-20 Thread Oriol _
Object(value) { > return value != null && ( > typeof value === "object" || > typeof value === "function" > ) > } No, `typeof` is not reliable, because it's implementation-defined for non-standard non-callable exotic objects. For

Re: Proposal: allow primitives to be explicitly returned from constructors

2018-04-19 Thread Oriol _
. And I don't really see the point, constructors are supposed to construct objects. If you want primitives, you can always use function calls. -- Oriol ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Object.unfreeze, or similar API

2018-03-24 Thread Oriol _
t read the handler spec in advance? Yes, the spec does not allow this. But there was a proposal about doing that in some cases, in order to improve performance. -- Oriol ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Object.unfreeze, or similar API

2018-03-24 Thread Oriol _
Hi Joe, I used a 2nd proxy as the handler in order to only allow the desired traps. Sure, I could have defined all blacklisted traps in an ordinary object, and make them throw an error. But this wouldn't be future-proof in case new traps are eventually added. Whitelisting is safer. -- Oriol

Re: add reverse() method to strings

2018-03-17 Thread Oriol _
Be aware your code breaks pair surrogates, which might be undesirable: ```js var str = "a_\uD83D\uDE80_b"; str.split("").reverse().join(""); // "b_\uDE80\uD83D_a" :( [...str].reverse().join(""); // "b_\uD83D\uDE80_a" :) ``` --Oriol

Re: Expanding Object Shorthand

2018-03-17 Thread Oriol _
> the last point doesn't haven't the same usability as my proposal since with > mine multiple different objects can be selected from at a time I believe that you could use Bob's proposal like this: ```js var obj = {...obj1.{prop1, prop2}, ...obj2.{prop3, prop4}}; ``` --

Re: Object.unfreeze, or similar API

2018-02-19 Thread Oriol _
"getOwnPropertyDescriptor"]; let handler = new Proxy(Object.create(null), { get(_, trap, receiver) { if (!allowed.includes(trap)) return error; } }); this.emit('some:event', new Proxy(obj, handler)); ``` -- Oriol ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: withBreak blocks

2018-02-17 Thread Oriol _
block; } return action({ data: response.data }); } ``` - Oriol ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Native Tensor support

2018-01-27 Thread Oriol _
t;console.log(1);"; document.documentElement.appendChild(s); console.log(2); ``` The output will be `1`, `2`. The script runs immediately, it's not async. - Oriol ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

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 es-d

Re: An idea to extend the functionality of Proxy objects.

2018-01-15 Thread Oriol _
. - Oriol ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Feature Mod: Add metering, parallelism & throttling options to AddEventListenerOptions

2017-11-27 Thread Oriol _
`addEventListener` in not part of ECMAScript. It's defined in the DOM spec. You should send your proposal to the WHATWG. --Oriol ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: How it feels to learn JavaScript in 2016

2017-11-25 Thread Oriol _
something more simple and reliable like ```js function isObject(value) { return Object(value) === value; } function isObject(value) { return new function(){ return value } === value; } ``` --Oriol ___ es-discuss mailing list es-discuss@mozilla.org

Re: New Promise Syntax Proposal

2017-11-06 Thread Oriol _
Consider using an async function: ```js async function promiseFunction() { return someValue; } ``` --Oriol ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Can `new` be optional?

2017-11-05 Thread Oriol _
arg: 2 } ``` --Oriol ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Monkey patching constructors in builtin class hierarchies?

2017-10-24 Thread Oriol _
```js class FooBar extends Element { constructor() { console.log("patched in Element"); let el = document.createElement('foo-bar'); return Object.setPrototypeOf(el, FooBar.prototype); } } ``` -Oriol ___ es-discuss mailing list

Re: Suggestion: Proxy.[[GetOwnProperty]] caching non-configurable, non-writable data descriptors?

2017-10-05 Thread Oriol _
of the value they return, they can also have desirable side-effects. --Oriol ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Strict greater than, greater than or equal, less than and less than or equal comparison operators

2017-09-10 Thread Oriol _
See https://esdiscuss.org/topic/strict-relational-operators --Oriol ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Strawman: `Function.prototype.try` (or `Function.try`)

2017-08-22 Thread Oriol _
Instead of `thrown: false` or `thrown: false`, why not `type: "normal"`, `type: "return"` or `type: "throw"`? This is what completion records use. -Oriol ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Object.seal, read references, and code reliability

2017-08-14 Thread Oriol _
would expect this: ```js let locked = Object.lock({}); let inherits = Object.create(locked); Reflect.get(locked, "foo"); // TypeError Reflect.get(locked, "foo", {}); // TypeError Reflect.get({}, "foo", locked); // undefined Reflect.get(inheri

Re: Operator overloading proposal

2017-07-13 Thread Oriol _
uldn't `!` also be excluded, then? > Future: Extending of operators I don't think this can work if you don't define a way to determine the operands. --Oriol ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Declaration types inside destructuring declarations

2017-07-06 Thread Oriol _
the need to add new syntax for this. --Oriol ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Re: Letting RegExp method return something iterable?

2017-06-18 Thread Oriol _
There is a `String#matchAll` proposal in stage 1. https://github.com/tc39/String.prototype.matchAll<http://%20https://github.com/tc39/String.prototype.matchAll> Oriol ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozil

Re: Object.isEqual

2017-05-01 Thread Oriol _
. And then there are proxies. Taking them into account, I don't think there is any reasonable way to compare objects. So I think it's better if each person writes the code that compares objects according to their needs. --Oriol ___ es-discuss mailing list es-discuss

Re: Proxies fail comparison operator

2017-03-30 Thread Oriol _
enough of a nightmare. --Oriol ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Map/Set.prototype.size is O(n)

2017-03-29 Thread Oriol _
Not only `size`. All `get`, `set`, `has`, etc. algorithms in the spec are O(n). But as explained in http://www.ecma-international.org/ecma-262/7.0/index.html#sec-map-objects, > Map object must be implemented using either hash tables or other mechanisms > that, on average, > provide access

Re: new [[HasProperty]] invariant for non-extensible objects

2017-03-05 Thread Oriol _
own property !!Object.getOwnPropertyDescriptor(p, "foo"); // true // [[HasProperty]] returns false "foo" in p; // false ``` -Oriol ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: new [[HasProperty]] invariant for non-extensible objects

2017-03-05 Thread Oriol _
;foo"); // true delete obj.foo; // [[HasProperty]] returns false "foo" in obj; // false ``` -Oriol ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Queue Feature Request

2017-02-25 Thread Oriol _
); q.pop(); // 2 q.pop(); // 3 q.pop(); // undefined ``` -- Oriol ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: name anonymous functions on property assignments

2017-01-28 Thread Oriol _
> I fixed it by putting the function inside `Object()` You can also use the comma operator: ```js var anon = (0, function () {}); anon.name; // "" ``` ;Oriol ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.or

Re: Determining if an object can be constructed

2017-01-17 Thread Oriol _
to change that. Maybe some day we will have `Object.isConstructor`. ;Oriol ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Accesssing ES6 class constructor function

2017-01-05 Thread Oriol _
ou can usually translate one syntax to the other, but you may need ES6 features like `new.target`, `super` or `setPrototypeOf`. -- Oriol ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: A Result class for functions that may return errors

2016-10-18 Thread Oriol Bugzilla
Not sure if I'm missing something, but wouldn't it be trivial to code that constructor in JS? ```js class Result { constructor (type, value=true) { this[type] = value; } } function add(data) { if (data !== Object(data)) { return new Result('error', new Error('The data is not an

Re: Making Object Literals a sub-class of Object

2016-10-14 Thread Oriol Bugzilla
Object literals (object initializers) are just a convenient way to create a new ordinary object which (initially) inherits from `Object.prototype`, and populate it with some properties. I don't think you should be able to distinguish them from similar objects not created using object

Re: Why Number(symbol) crashes?

2016-10-11 Thread Oriol Bugzilla
In my opinion it's a bit incoherent that each object-coercible type behaves differently when coercing symbols to it. Symbols can be explicitly coerced to strings, but not implicitly: ```js String(Symbol("abc")); // "Symbol(abc)" Symbol("abc") + ""; // TypeError ``` Symbols can't be coerced to

Re: JSON.stringify

2016-09-29 Thread Oriol Bugzilla
But as Mike Samuel mentioned, JSON strings containing U+2028 or U+2029 are not valid JS expressions. I think it would make sense for `JSON.stringify` to escape these. -Oriol ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org

Re: Existential Operator / Null Propagation Operator

2016-09-15 Thread Oriol Bugzilla
I disagree with silently ignoring property access on null/undefined. > Early errors are nice Yes, exactly. Errors should fail early and loudly. That's why the strictness of strict mode is useful. > It's no weirder that `123.foo` not throwing. No, it's entirely different, because numbers

Re: Function composition syntax

2016-09-07 Thread Oriol Bugzilla
orks like this: ``` (f ? g)(x) = f(g(x)) ``` So I think it would be more intuitive to use `<=<`, which would call the right operand first, and then call the left operand with the result of the right one. ,Oriol ___ es-discuss mailing list es-disc

Re: Bug: Reflect.ownKeys(function() {}) differs in V8 strict mode than other cases

2016-09-05 Thread Oriol Bugzilla
can be sure it will be a strict mode function, it will be extensible, and won't have any additional non-configurable own property. Then you will have less problems with proxy invariants. -Oriol ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.

Re: Bug: Reflect.ownKeys(function() {}) differs in V8 strict mode than other cases

2016-09-05 Thread Oriol Bugzilla
in sloppy mode, and Firefox to never add them. So I think both follow the spec. - Oriol ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Proxies and preventExtensions: how to avoid inconsistency in a membrane?

2016-09-04 Thread Oriol Bugzilla
> Could there be a Proxy.hasBeenRevoked(proxy) method? The Proxy constructor only accepts targets and handlers when they are objects and are not revoked proxies. I wonder what's the point of not allowing revoked proxies but allow revocable proxies which may be revoked later. Anyways, this

Re: Why ES6 introduced classes yet `Symbol` not to be used with `new`?

2016-08-14 Thread Oriol Bugzilla
Probably, because symbols are primitive values, and constructors only create and initialize objects. So you are supposed to call it as a function instead of as a a constructor. That said, it might make sense for `new Symbol()` to return a symbol object. But instead, you can use

RE: Array.prototype.includesAll

2016-06-14 Thread Oriol Bugzilla
> There are no items in `[]` so that doesn't seem like a true statement to me. It's true by [Vacuous_truth](https://en.wikipedia.org/wiki/Vacuous_truth). > So, at least consistency pulls towards `false`. You are misunderstanding what `includes` does when there is no argument. ```js

RE: Array.prototype.includesAll

2016-06-14 Thread Oriol Bugzilla
What's the point of using `reduce` instead of `every`? ```js Array.prototype.includesAll = function (...args) { return args.every(item => this.includes(item)); } ``` I disagree with this test ```js expect([2, 3].includesAll()).toBe(false) ``` The array `[2,3]` includes all items in `[]`. So

RE: Array.prototype.includes with multiple arguments

2016-06-10 Thread Oriol Bugzilla
Array.prototype.includes uses the second argument as the starting index. Therefore, these calls would be identical, but you want them to behave differently: ``` ["a"].includes("a", 0); // true -- "a" can be found at position 0 ["a"].includes(...["a", 0]); // false -- 0 can't be found in the

RE: Reflect.create()

2016-05-26 Thread Oriol Bugzilla
I agree with Bergi. > Brendan Eich and think he understood that fairly I can't see that. He says things like "what's to propose?", "what is declare? I don't think core language needs to grow", "What does this have to do with promises?", "I don't see the point" and "It's not making sense,

RE: How about a "named true" and a "named true property"

2016-05-26 Thread Oriol Bugzilla
As Isiah Meadows said, you can just use variables. ``` var removeNode = true; control.dispose(removeNode); ``` ``` var silent = true, disableValidation = true, destroyOldValue = false; model.set('foo', newValue, {silent, disableValidation, destroyOldValue});``` From:

RE: Proposal: Switch position of delay and callback in signature of `setTimeout()`

2016-04-25 Thread Oriol Bugzilla
`setTimeout` is not part of ECMAScript. You should suggest this to WHATWG instead. - Oriol From: m...@adriansieber.com Date: Mon, 25 Apr 2016 17:35:50 + Subject: Proposal: Switch position of delay and callback in signature of `setTimeout()` To: es-discuss@mozilla.org Everytime I

RE: Extending Object

2016-04-23 Thread Oriol Bugzilla
They are no necessary the same: ```js var _Object = window.Object, Object = function() {}; class Foo1 { constructor() {} } class Foo2 extends Object { constructor() { super(); } } _Object.getPrototypeOf(Foo1.prototype); // _Object.prototype _Object.getPrototypeOf(Foo2.prototype); //

Take let variable out of temporal dead zone

2016-04-15 Thread Oriol Bugzilla
ore initialization ``` And `let` variables can't be redeclared: ```js let foo = 123; // SyntaxError: redeclaration of let foo ``` Is this behaviour intended? Is there any way to take `foo` out of the TDZ, so that I can assign values and read them? - Or