JSDOC / codingstandards for Array/String extention functions

git-svn-id: http://svn.openlayers.org/trunk/openlayers@142 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-05-18 13:06:26 +00:00
parent 18f911af50
commit 312e7cb7a8

View File

@@ -448,22 +448,50 @@ OpenLayers.Bounds.fromString = function(str) {
String.prototype.startsWith = function(sStart){
return (this.substr(0,sStart.length) == sStart);
};
/**
* @returns A trimmed version of the string - all leading and
* trailing spaces removed
* @type String
*/
String.prototype.trim = function() {
var b=0,e=this.length -1;
while(this.substr(b,1) == " ") {b++;}
while(this.substr(e,1) == " ") {e--;}
return this.substring(b,e+1);
var b = 0;
while(this.substr(b,1) == " ") {
b++;
}
var e = this.length - 1;
while(this.substr(e,1) == " ") {
e--;
}
return this.substring(b, e+1);
};
Array.prototype.remove = function(rem) {
for(var i=0; i<this.length; i++) {
if(this[i]==rem) {
/** Remove an object from an array. Iterates through the array
* to find the item, then removes it.
*
* @param {Object} item
*
* @returns A reference to the array
* @type Array
*/
Array.prototype.remove = function(item) {
for(var i=0; i < this.length; i++) {
if(this[i] == item) {
this.splice(i,1);
//break;more than once??
}
}
return this;
}
Array.prototype.copy = function() {
/**
* @returns A fresh copy of the array
* @type Array
*/
Array.prototype.copyOf = function() {
var copy = new Array();
for (var i = 0; i < this.length; i++) {
copy[i] = this[i];
@@ -471,13 +499,25 @@ Array.prototype.copy = function() {
return copy;
};
Array.prototype.prepend = function(the_item) {
this.splice(0,0,the_item);
/**
* @param {Object} item
*/
Array.prototype.prepend = function(item) {
this.splice(0, 0, item);
};
Array.prototype.append=function(the_item){
this[this.length]=the_item;
/**
* @param {Object} item
*/
Array.prototype.append = function(item){
this[this.length] = item;
};
/**
*/
Array.prototype.clear = function() {
this.length = 0;
};
Array.prototype.clear=function() {this.length=0;};