Commit 0b65c0b6 authored by timothy@apple.com's avatar timothy@apple.com

Add a helper function to the Inspector's Array prototype

that will remove any identical values/objects from the array.

Reviewed by Kevin McCullough.

* page/inspector/utilities.js:
(Array.prototype.remove): Iterate over the array and strict
compare to the passed in value. If they match, splice that index
out of the array. If onlyFirst is true, return after the first splice.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@33398 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent dec8c517
2008-05-13 Timothy Hatcher <timothy@apple.com>
Add a helper function to the Inspector's Array prototype
that will remove any identical values/objects from the array.
Reviewed by Kevin McCullough.
* page/inspector/utilities.js:
(Array.prototype.remove): Iterate over the array and strict
compare to the passed in value. If they match, splice that index
out of the array. If onlyFirst is true, return after the first splice.
2008-05-13 Timothy Hatcher <timothy@apple.com> 2008-05-13 Timothy Hatcher <timothy@apple.com>
Adds a JavaScriptCallFrame object and JavaScript binding with an IDL. Adds a JavaScriptCallFrame object and JavaScript binding with an IDL.
...@@ -747,6 +747,18 @@ HTMLTextAreaElement.prototype.moveCursorToEnd = function() ...@@ -747,6 +747,18 @@ HTMLTextAreaElement.prototype.moveCursorToEnd = function()
this.setSelectionRange(length, length); this.setSelectionRange(length, length);
} }
Array.prototype.remove = function(value, onlyFirst)
{
var length = this.length;
for (var i = 0; i < length; ++i) {
if (this[i] === value) {
this.splice(i, 1);
if (onlyFirst)
break;
}
}
}
String.sprintf = function(format) String.sprintf = function(format)
{ {
return String.vsprintf(format, Array.prototype.slice.call(arguments, 1)); return String.vsprintf(format, Array.prototype.slice.call(arguments, 1));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment