String.prototype.until

2012-01-02 Thread Adam Shannon
for ES.next. It could be defined as acting the same way as the following code: String.prototype.until = function (needle) { return this.substr(0, this.indexOf(needle)); } -- Adam Shannon Web Developer University of Northern Iowa Sophomore -- Computer Science B.S. Mathematics http://ashannon.us

Re: String.prototype.until

2012-01-02 Thread Michael A. Smith
the starting index? String.prototype.until = function (start, needle) { return + (this.substr(start, this.indexOf(needle)) || this); } (The [ +] part is probably not necessary, but it makes it easier to see the implementation work in the console.) Michael A. Smith Web Developer True Action

Re: String.prototype.until

2012-01-02 Thread Axel Rauschmayer
as the following code: String.prototype.until = function (needle) { return this.substr(0, this.indexOf(needle)); } -- Dr. Axel Rauschmayer a...@rauschma.de home: rauschma.de twitter: twitter.com/rauschma blog: 2ality.com ___ es-discuss mailing list es

Re: String.prototype.until

2012-01-02 Thread Adam Shannon
Yes, I see the use for returning the entire string if the needle isn't found. I was also thinking about a dynamic start position, which is why I'd favor something like this. String.prototype.until = function (needle, start) { start ?? 0; return this.substr(start, this.indexOf(needle

Re: String.prototype.until

2012-01-02 Thread Adam Shannon
the beginning until the first encounter with another substring. This promoted me to write a simple function, called until and I wondered if it would be something to add with the other string extras for ES.next. It could be defined as acting the same way as the following code: String.prototype.until

Re: String.prototype.until

2012-01-02 Thread Axel Rauschmayer
string extras for ES.next. It could be defined as acting the same way as the following code: String.prototype.until = function (needle) { return this.substr(0, this.indexOf(needle)); } -- Dr. Axel Rauschmayer a...@rauschma.de home: rauschma.de twitter: twitter.com/rauschma blog