Add ol.base.checkKeys
This commit is contained in:
@@ -16,3 +16,24 @@ ol.error = function(message) {
|
||||
* @define {boolean}
|
||||
*/
|
||||
ol.error.VERBOSE_ERRORS = true;
|
||||
|
||||
/**
|
||||
* @define {boolean}
|
||||
*/
|
||||
ol.CHECK_KEYS = true;
|
||||
|
||||
/**
|
||||
* @param {Object} obj Object.
|
||||
* @param {!Array.<string>} allowedKeys Allowed keys.
|
||||
*/
|
||||
ol.base.checkKeys = function(obj, allowedKeys) {
|
||||
if (ol.CHECK_KEYS) {
|
||||
var keys = goog.object.getKeys(obj);
|
||||
goog.array.forEach(allowedKeys, function(allowedKey) {
|
||||
goog.array.remove(keys, allowedKey);
|
||||
});
|
||||
if (!goog.array.isEmpty(keys)) {
|
||||
ol.error('object contains invalid keys: ' + keys.join(', '));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user