Closed
Bug 446252
Opened 16 years ago
Closed 11 years ago
Borrow and enhance String Methods from .Net to JavaScript
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: BijuMailList, Unassigned)
References
()
Details
Per bug 305064 comment #18 > > 5. > > There also other useful methods > > http://msdn.microsoft.com/en-us/library/system.string_members.aspx > > like StartsWith/EndsWith, IndexOfAny, > > PadLeft/PadRight (or better PadStart/PadEnd/PadCenter) > > bug 76946 talks about StartsWith/EndsWith. As for the others, > you can file bugs them. There are a list of nice String Methods in .Net (http://msdn.microsoft.com/en-us/library/system.string_members.aspx) which we may borrow and enhance to use in JavaScript eg:- 1. PadLeft/PadRight (or better PadStart/PadEnd/PadCenter) - PadLeft is something I used for years to generate things like bill#, product#, contract# etc. to get '0' padded number as in 'PO000454', 'INV09854', 'KIT-0067-00378' etc 2. Compare(String, String, StringComparison) / Equals(String, StringComparison) - it will be nice if we can compare two strings by giving ignore case rules or the by the name from Java equalsIgnoreCase http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html 3. IndexOfAny, LastIndexOfAny - We have indexOf and lastIndexOf of in JavaScript but many times we will be interested in looking for first occurrence of a list of "NEEDLES in haystack" rather than one string in haystack also it may be good if we can IGNORE CASE like above as needed.
Comment 1•16 years ago
|
||
Why borrow from .NET only. There are many very useful string functions in lets say PHP: http://se.php.net/manual/en/ref.strings.php Personally I use quit a few of them, and make use of a library of JS implementations of PHP functions. Eg. levenshtein is great to check if someone has altered the suggested text in a form field "enough".
Comment 2•16 years ago
|
||
There are many, many libraries to imitate. I don't have anything against the .NET ones _per se_. I'm not in favor of native methods where scripted ones would do. Unnecessary attack surface, increasingly bogus performance reasoning (trace-tree JIT coming), code footprint micro-bloat (it wasn't the last cookie I ate that made me fat). It would be better to look at JS ("Ajax") libraries that are populare today, and intersect their string method sets. Anyone up for that? /be
Comment 3•11 years ago
|
||
New methods need to come from the spec.
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•