Re: Object.unfreeze, or similar API

2018-02-19 Thread Jordan Harband
The entire purpose of Object.freeze is that the frozen object *can never be altered again* (in the ways that freeze restricts, at least). Allowing an object to be unfrozen would violate that very critical security property. The same is true with seal and preventExtensions. Once locked down, an

Re: Proposal to add symbol: "hasInstanceStrict"

2018-02-19 Thread Aleksander Efremov
And still one question about `function decorators` . They will be work if in function parameters uses destructuring? ``` @rttc(PrimitiveNumber, PrimitiveString, PrimitiveBoolean) function a (b, { c, d }) {} ``` 20 февр. 2018 г. 0:13 пользователь "mr.efrem" написал: > And

Object.unfreeze, or similar API

2018-02-19 Thread Raul-Sebastian Mihăilă
Note that if you want to use the Proxy that way you will probably want to implement the setPrototypeOf and preventExtensions traps as well since, together with set, defineProperty and deleteProperty, they are the traps whose associated internal methods can have side effects on the target when the

Re: For-has-in loop

2018-02-19 Thread Mike Samuel
On Mon, Feb 19, 2018 at 1:50 PM, Sebastian Malton wrote: > I would like to propose that the following be valid since it is a very > common use case. > > ``` > for (const field has in object) { > > } > ``` > > Would be equivalent to: > > ``` > for (const field in

Re: Object.unfreeze, or similar API

2018-02-19 Thread Oriol _
> So, what if there was a way to unfreeze an object in the scope in which the > object was frozen? I don't think the behavior of object operations should depend on the scope in which they are used. And I could understand undoing [[PreventExtensions]], just switch [[Extensible]] back to true

Re: For-has-in loop

2018-02-19 Thread Isiah Meadows
And I find it kind of absurd that engines don't yet optimize away the intermediate array allocation (even though it's literally almost equal to `for ... in` in performance). - Isiah Meadows m...@isiahmeadows.com Looking for web consulting? Or a new website? Send me an email and we can get

Re: Object.unfreeze, or similar API

2018-02-19 Thread /#!/JoePea
That's actually very useful, thanks! I have plenty of cases where I wished I could pass an object without cloning it to ensure it isn't mutated from outside. And instead of creating the Proxy right when I will emit an event (for example), I could just store the proxy somewhere so it is long-lived

Re: Proposal to add symbol: "hasInstanceStrict"

2018-02-19 Thread mr.efrem
And still one question about `function decorators` . They will be work if in function parameters uses destructuring? ``` @rttc(PrimitiveNumber, PrimitiveString, PrimitiveBoolean) function a (b, { c, d }) {} ``` Исходное сообщение От: "T.J. Crowder"

Re: Object.unfreeze, or similar API

2018-02-19 Thread Michał Wadas
You can just do: const proxy = new Proxy(obj, { set() { throw new Error(); }, defineProperty() { throw new Error();}, deleteProperty() { throw new Error(); } }) this.emit('some:event', proxy) Though, it seems like an exotic use case. On Mon, Feb 19, 2018 at 8:56 PM, /#!/JoePea

Re: Partial regexp matching

2018-02-19 Thread Mike Samuel
On Mon, Feb 19, 2018 at 1:15 PM, Isiah Meadows wrote: > > > > > We can't base a distinction between yes and maybe on whether a > > zero-width $ assertion is triggered if there are paths to completion > > that do not pass through that assertion. > > > > > > const re =

Re: Re: Async Class

2018-02-19 Thread Dimitrian Nine
"ES classes are about 90% sugar" "ES classes aren't like traditional classes" Yes and i just want to more sugar for them - just simple. ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: For-has-in loop

2018-02-19 Thread Peter Jaszkowiak
You could use Object.keys, Object.entries, or Object.values on the right side of `of` instead. On Feb 19, 2018 11:50, "Sebastian Malton" wrote: > I would like to propose that the following be valid since it is a very > common use case. > > ``` > for (const field has in

For-has-in loop

2018-02-19 Thread Sebastian Malton
I would like to propose that the following be valid since it is a very common use case. ```for (const field has in object) {    }```Would be equivalent to:```for (const field in object) {    if (!object.hasOwnPropety(field)) {        continue;    }    }```

Re: Re: Async Class

2018-02-19 Thread Isiah Meadows
I just thought I'd politely point out here that JS isn't a purely OO language (it's even less so class-based OO - ES classes are about 90% sugar over prototype-based inheritance\*). Also, C#, the language that *first* had this kind of syntax, [also doesn't have this][1]. Constructors should be

Re: Partial regexp matching

2018-02-19 Thread Isiah Meadows
Inline. On Mon, Feb 19, 2018 at 12:39 PM, Mike Samuel wrote: > > > On Mon, Feb 19, 2018 at 11:43 AM, Isiah Meadows > wrote: >> >> Yes, and I specifically want the conservative variant - I'd want a >> "maybe" for "foo" in that example. >> >> (For

Re: Re: Async Class

2018-02-19 Thread Dimitrian Nine
"why a static factory" I answered earlier: <> Yes, you can, but for me more easy to work with classes. And i just want to extend the functionality for work with async - that all. ___

Re: Partial regexp matching

2018-02-19 Thread Mike Samuel
On Mon, Feb 19, 2018 at 11:43 AM, Isiah Meadows wrote: > Yes, and I specifically want the conservative variant - I'd want a > "maybe" for "foo" in that example. > > (For context, my test framework determines *while running a test* > whether that test has children, and

Re: Proposal to add symbol: "hasInstanceStrict"

2018-02-19 Thread Aleksander Efremov
I also mentioned in my first message that I offered to do call that symbol when appears assignmen of variable or const: when appears creating and assignment parameters of function and also when appears assignment of result function to the variable or const. I just left it in the single example.

Re: Proposal to add symbol: "hasInstanceStrict"

2018-02-19 Thread Aleksander Efremov
I gave `fetch` you just for example that function result which I want to check. Also on the Node.js I wanted be to check results of `http` module. It just examples of black boxes which impossible to check via decorators how you offered. `fetch` I assumed to use with `await`. 19 февр. 2018 г.

Re: Re: Async Class

2018-02-19 Thread Isiah Meadows
I'm still struggling through this thread to see why a static factory method/function with a private constructor/class doesn't suffice for this, or in this case, just procedural functions? (That's what I normally do, [even in ES5][1].) ```js // filter-img.js export async function create(path) {

Re: Proposal to add symbol: "hasInstanceStrict"

2018-02-19 Thread T.J. Crowder
On Mon, Feb 19, 2018 at 4:50 PM, Aleksander Efremov wrote: > In my first example you can found what I mean. Yes, I looked at your first example (and every other example in the thread) before replying. As it had nothing to do with `fetch`, but you specifically mentioned

Re: Proposal to add symbol: "hasInstanceStrict"

2018-02-19 Thread Aleksander Efremov
Yes, that's it. 19 февр. 2018 г. 20:53 пользователь "Mike Samuel" написал: On Mon, Feb 19, 2018 at 11:50 AM, Aleksander Efremov wrote: > In my first example you can found what I mean. There not only function. > Just instead of that function can be

Re: Proposal to add symbol: "hasInstanceStrict"

2018-02-19 Thread Mike Samuel
On Mon, Feb 19, 2018 at 11:50 AM, Aleksander Efremov wrote: > In my first example you can found what I mean. There not only function. > Just instead of that function can be black box results which we must check > on assignment to const. > Are you referring to the use of

Re: Proposal to add symbol: "hasInstanceStrict"

2018-02-19 Thread Aleksander Efremov
In my first example you can found what I mean. There not only function. Just instead of that function can be black box results which we must check on assignment to const. 19 февр. 2018 г. 20:42 пользователь "T.J. Crowder" < tj.crow...@farsightsoftware.com> написал: > On Mon, Feb 19, 2018 at 4:35

Re: Partial regexp matching

2018-02-19 Thread Isiah Meadows
Yes, and I specifically want the conservative variant - I'd want a "maybe" for "foo" in that example. (For context, my test framework determines *while running a test* whether that test has children, and checks whether to allocate them when defining them. For me, I only need "yes/maybe" and "no",

Re: Proposal to add symbol: "hasInstanceStrict"

2018-02-19 Thread T.J. Crowder
On Mon, Feb 19, 2018 at 4:35 PM, Aleksander Efremov wrote: > > How do you offer to check a assignment of result of `fetch` to > the variable (const) ? For it also exists decorator? I'm not sure I know what you mean. If you could provide a code example of what you're asking

Re: Proposal to add symbol: "hasInstanceStrict"

2018-02-19 Thread Aleksander Efremov
How do you offer to check a assignment of result of `fetch` to the variable (const) ? For it also exists decorator? 19 февр. 2018 г. 18:25 пользователь "T.J. Crowder" < tj.crow...@farsightsoftware.com> написал: On Mon, Feb 19, 2018 at 1:59 PM, Александр Ефремов wrote: > > A

Re: Proposal to add symbol: "hasInstanceStrict"

2018-02-19 Thread Mike Samuel
On Mon, Feb 19, 2018 at 9:25 AM, T.J. Crowder < tj.crow...@farsightsoftware.com> wrote: > On Mon, Feb 19, 2018 at 1:59 PM, Александр Ефремов > wrote: > > When [decorators][1] land, provided they land with a means of [decorating > functions][2] (either as part of that proposal

Re: Proposal to add symbol: "hasInstanceStrict"

2018-02-19 Thread T.J. Crowder
On Mon, Feb 19, 2018 at 1:59 PM, Александр Ефремов wrote: > > A reasons for this proposal: > 1. I don’t want to use static type checking (Flow or TypeScript) > because on my experience there more a time spend on the > describing all types and etc. than it gives favor. > 2. I

Re: Proposal to add symbol: "hasInstanceStrict"

2018-02-19 Thread Александр Ефремов
A reasons for this proposal: 1. I don’t want to use static type checking (Flow or TypeScript) because on my experience there more a time spend on the describing all types and etc. than it gives favor. 2. I want to validate API payloads and other sources of data when it’s need. I’m sure that