Enumerate ol.Array properties

This commit is contained in:
Tom Payne
2012-07-06 20:40:19 +02:00
committed by Tom Payne
parent d70869c702
commit 7b6fb0b4ca

View File

@@ -51,6 +51,14 @@ ol.ArrayEvent = function(type, index, opt_prev, opt_target) {
goog.inherits(ol.ArrayEvent, goog.events.Event); goog.inherits(ol.ArrayEvent, goog.events.Event);
/**
* @enum {string}
*/
ol.ArrayProperty = {
LENGTH: 'length'
};
/** /**
* @constructor * @constructor
@@ -73,13 +81,6 @@ ol.Array = function(opt_array) {
goog.inherits(ol.Array, ol.Object); goog.inherits(ol.Array, ol.Object);
/**
* @const
* @type {string}
*/
ol.Array.LENGTH = 'length';
/** /**
* @param {ol.Array|Array} arg Argument. * @param {ol.Array|Array} arg Argument.
* @return {ol.Array} Array. * @return {ol.Array} Array.
@@ -96,7 +97,7 @@ ol.Array.create = function(arg) {
/** /**
*/ */
ol.Array.prototype.clear = function() { ol.Array.prototype.clear = function() {
while (this[ol.Array.LENGTH]) { while (this[ol.ArrayProperty.LENGTH]) {
this.pop(); this.pop();
} }
}; };
@@ -131,7 +132,7 @@ ol.Array.prototype.getAt = function(index) {
* @return {number} Length. * @return {number} Length.
*/ */
ol.Array.prototype.getLength = function() { ol.Array.prototype.getLength = function() {
return /** @type {number} */ (this.get(ol.Array.LENGTH)); return /** @type {number} */ (this.get(ol.ArrayProperty.LENGTH));
}; };
@@ -191,7 +192,7 @@ ol.Array.prototype.removeAt = function(index) {
* @param {*} elem Element. * @param {*} elem Element.
*/ */
ol.Array.prototype.setAt = function(index, elem) { ol.Array.prototype.setAt = function(index, elem) {
var n = this[ol.Array.LENGTH]; var n = this[ol.ArrayProperty.LENGTH];
if (index < n) { if (index < n) {
var prev = this.array_[index]; var prev = this.array_[index];
this.array_[index] = elem; this.array_[index] = elem;