Re: [Proposal] New syntax for lazy getters

2018-06-27 Thread Isiah Meadows
I agree the main proposal is long and complex, but this kind of addition could be designed with little effort to "fall out of the grid", since it has so much in common with classes already (properties, getters/setters, methods). The main question is with properties, but those are easy to just

Re: [Proposal] New syntax for lazy getters

2018-06-27 Thread Augusto Moura
On June 27, 2018 09:23, kai zhu wrote: > what would happen if you tried to JSON.stringify foo? a core-value of javascript to industry is as an idiot-proof/least-surprise language for serializing json-data across browser <-> server. junior-programmers who naively employ hard-to-serialize things

Re: Re: [Proposal] ignoreCase method

2018-06-27 Thread Isiah Meadows
I would be a fan of adding a `string.compare(other, {ignoreCase = false, unicode = false})` that purely works by character code/code point and is required to return 1, 0, or -1. That would be easier to spec, and is more generally useful when you're working with strings for computers, not people.

Re: [Proposal] ignoreCase method

2018-06-27 Thread T.J. Crowder
On Wed, Jun 27, 2018 at 6:03 PM, Oriol _ wrote: >> (`.localeCompare(stringOne, undefined, {sensitivity: "base"})` **is** > fairly verbose, so I'd probably have a utility function for it.) > > I would just create a collator outside the loop: I meant verbose to write every time you need to do a

Re: [Proposal] ignoreCase method

2018-06-27 Thread Oriol _
> (`.localeCompare(stringOne, undefined, {sensitivity: "base"})` **is** fairly verbose, so I'd probably have a utility function for it.) I would just create a collator outside the loop: ```js const stringOne = "Matheus"; const manyStrings = ['robert', 'lucas', 'matheus']; const {compare} = new

Re: Re: [Proposal] ignoreCase method

2018-06-27 Thread T.J. Crowder
On Wed, Jun 27, 2018 at 4:37 PM, Robert Wozniak wrote: > ...it does compare case sensitive strings but > it doesn’t compare strings in an array and to do it, you will have to > execute the method as many times as strings in an array That's not a problem. For the "does this string match any in

Re: Re: [Proposal] ignoreCase method

2018-06-27 Thread T.J. Crowder
On Wed, Jun 27, 2018 at 4:37 PM, Robert Wozniak wrote: > ...Second thing, “localeCompare” returns numbers: 0, 1, -1, -2 depends > on the result, a method proposed by me returns true or false. This makes your method markedly less useful than `localeCompare`. It's really useful to know not just

Re: Re: [Proposal] ignoreCase method

2018-06-27 Thread Robert Wozniak
Hi, I think you’re right, It could be simpler to do it like that. I have checked “localeCompare”, it does compare case sensitive strings but it doesn’t compare strings in an array and to do it, you will have to execute the method as many times as strings in an array. By using ignoreCase

Re: [Proposal] New syntax for lazy getters

2018-06-27 Thread Isiah Meadows
If you're wanting to propose new places for decorators, you'd have much better luck here: https://github.com/tc39/proposal-decorators I do agree this is an obvious place for a decorator, and it is probably the ideal way of specifying it for object properties, but your larger proposal of adding

Re: [Proposal] ignoreCase method

2018-06-27 Thread Isiah Meadows
BTW, have you tried `string.localeCompare(other, null, {sensitivity: "base"})` or `sensitivity: "accent"`? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare - Isiah Meadows m...@isiahmeadows.com www.isiahmeadows.com On Wed, Jun 27, 2018

Re: [Proposal] New syntax for lazy getters

2018-06-27 Thread kai zhu
> What it's doesn't cover (and in my opinion should be the focus of a new > proposal) is Decorators for literal objects. Something like the code below is > yet not proposed: > > ``` js > const foo = { > @lazy bar: 3, > }; > ``` what would happen if you tried to JSON.stringify foo? a

Re: [Proposal] ignoreCase method

2018-06-27 Thread Michael Luder-Rosefield
Would it not be simpler to simply change the signature from `function(value, arrayOfStrings)` to `function(...values)`? I'd also suggest that a better, more general purpose formulation of comparing a string against multiple values might be to use #match. Something like: ``` const checkString =

[Proposal] ignoreCase method

2018-06-27 Thread Robert Wozniak
Hi everyone, ignoreCase - JavaScript proposal It's a proposal to implement a new function to compare two strings but without case sensitivity. The proposal is bringing an important function, which is being used in Java. Many times in my career I had to compare two strings but ignore case