Replace goog.isNumber

This commit is contained in:
Peter Robins
2016-07-01 09:35:54 +00:00
parent 6d41e87ff5
commit 3eea9d4558
7 changed files with 23 additions and 23 deletions

View File

@@ -117,7 +117,7 @@ ol.DeviceOrientation.prototype.orientationChange_ = function(originalEvent) {
// event.absolute is undefined in iOS. // event.absolute is undefined in iOS.
if (typeof event.absolute === 'boolean' && event.absolute) { if (typeof event.absolute === 'boolean' && event.absolute) {
this.set(ol.DeviceOrientationProperty.HEADING, alpha); this.set(ol.DeviceOrientationProperty.HEADING, alpha);
} else if (goog.isNumber(event.webkitCompassHeading) && } else if (typeof event.webkitCompassHeading === 'number' &&
event.webkitCompassAccuracy != -1) { event.webkitCompassAccuracy != -1) {
var heading = ol.math.toRadians(event.webkitCompassHeading); var heading = ol.math.toRadians(event.webkitCompassHeading);
this.set(ol.DeviceOrientationProperty.HEADING, heading); this.set(ol.DeviceOrientationProperty.HEADING, heading);

View File

@@ -57,7 +57,7 @@ ol.format.EsriJSON.readGeometry_ = function(object, opt_options) {
return null; return null;
} }
var type; var type;
if (goog.isNumber(object.x) && goog.isNumber(object.y)) { if (typeof object.x === 'number' && typeof object.y === 'number') {
type = ol.geom.GeometryType.POINT; type = ol.geom.GeometryType.POINT;
} else if (object.points) { } else if (object.points) {
type = ol.geom.GeometryType.MULTI_POINT; type = ol.geom.GeometryType.MULTI_POINT;
@@ -145,8 +145,8 @@ ol.format.EsriJSON.convertRings_ = function(rings, layout) {
* @return {ol.geom.Geometry} Point. * @return {ol.geom.Geometry} Point.
*/ */
ol.format.EsriJSON.readPointGeometry_ = function(object) { ol.format.EsriJSON.readPointGeometry_ = function(object) {
goog.asserts.assert(goog.isNumber(object.x), 'object.x should be number'); goog.asserts.assert(typeof object.x === 'number', 'object.x should be number');
goog.asserts.assert(goog.isNumber(object.y), 'object.y should be number'); goog.asserts.assert(typeof object.y === 'number', 'object.y should be number');
var point; var point;
if (object.m !== undefined && object.z !== undefined) { if (object.m !== undefined && object.z !== undefined) {
point = new ol.geom.Point([object.x, object.y, object.z, object.m], point = new ol.geom.Point([object.x, object.y, object.z, object.m],
@@ -493,7 +493,7 @@ ol.format.EsriJSON.prototype.readFeatureFromObject = function(
if (opt_options && opt_options.idField && if (opt_options && opt_options.idField &&
esriJSONFeature.attributes[opt_options.idField]) { esriJSONFeature.attributes[opt_options.idField]) {
goog.asserts.assert( goog.asserts.assert(
goog.isNumber(esriJSONFeature.attributes[opt_options.idField]), typeof esriJSONFeature.attributes[opt_options.idField] === 'number',
'objectIdFieldName value should be a number'); 'objectIdFieldName value should be a number');
feature.setId(/** @type {number} */( feature.setId(/** @type {number} */(
esriJSONFeature.attributes[opt_options.idField])); esriJSONFeature.attributes[opt_options.idField]));

View File

@@ -82,7 +82,7 @@ ol.inherits(ol.pointer.MsSource, ol.pointer.EventSource);
*/ */
ol.pointer.MsSource.prototype.prepareEvent_ = function(inEvent) { ol.pointer.MsSource.prototype.prepareEvent_ = function(inEvent) {
var e = inEvent; var e = inEvent;
if (goog.isNumber(inEvent.pointerType)) { if (typeof inEvent.pointerType === 'number') {
e = this.dispatcher.cloneEvent(inEvent, inEvent); e = this.dispatcher.cloneEvent(inEvent, inEvent);
e.pointerType = this.POINTER_TYPES[inEvent.pointerType]; e.pointerType = this.POINTER_TYPES[inEvent.pointerType];
} }

View File

@@ -281,7 +281,7 @@ ol.render.canvas.Replay.prototype.replay_ = function(
++i; ++i;
break; break;
case ol.render.canvas.Instruction.CIRCLE: case ol.render.canvas.Instruction.CIRCLE:
goog.asserts.assert(goog.isNumber(instruction[1]), goog.asserts.assert(typeof instruction[1] === 'number',
'second instruction should be a number'); 'second instruction should be a number');
d = /** @type {number} */ (instruction[1]); d = /** @type {number} */ (instruction[1]);
var x1 = pixelCoordinates[d]; var x1 = pixelCoordinates[d];
@@ -299,10 +299,10 @@ ol.render.canvas.Replay.prototype.replay_ = function(
++i; ++i;
break; break;
case ol.render.canvas.Instruction.DRAW_IMAGE: case ol.render.canvas.Instruction.DRAW_IMAGE:
goog.asserts.assert(goog.isNumber(instruction[1]), goog.asserts.assert(typeof instruction[1] === 'number',
'second instruction should be a number'); 'second instruction should be a number');
d = /** @type {number} */ (instruction[1]); d = /** @type {number} */ (instruction[1]);
goog.asserts.assert(goog.isNumber(instruction[2]), goog.asserts.assert(typeof instruction[2] === 'number',
'third instruction should be a number'); 'third instruction should be a number');
dd = /** @type {number} */ (instruction[2]); dd = /** @type {number} */ (instruction[2]);
var image = /** @type {HTMLCanvasElement|HTMLVideoElement|Image} */ var image = /** @type {HTMLCanvasElement|HTMLVideoElement|Image} */
@@ -371,25 +371,25 @@ ol.render.canvas.Replay.prototype.replay_ = function(
++i; ++i;
break; break;
case ol.render.canvas.Instruction.DRAW_TEXT: case ol.render.canvas.Instruction.DRAW_TEXT:
goog.asserts.assert(goog.isNumber(instruction[1]), goog.asserts.assert(typeof instruction[1] === 'number',
'2nd instruction should be a number'); '2nd instruction should be a number');
d = /** @type {number} */ (instruction[1]); d = /** @type {number} */ (instruction[1]);
goog.asserts.assert(goog.isNumber(instruction[2]), goog.asserts.assert(typeof instruction[2] === 'number',
'3rd instruction should be a number'); '3rd instruction should be a number');
dd = /** @type {number} */ (instruction[2]); dd = /** @type {number} */ (instruction[2]);
goog.asserts.assert(typeof instruction[3] === 'string', goog.asserts.assert(typeof instruction[3] === 'string',
'4th instruction should be a string'); '4th instruction should be a string');
text = /** @type {string} */ (instruction[3]); text = /** @type {string} */ (instruction[3]);
goog.asserts.assert(goog.isNumber(instruction[4]), goog.asserts.assert(typeof instruction[4] === 'number',
'5th instruction should be a number'); '5th instruction should be a number');
var offsetX = /** @type {number} */ (instruction[4]) * pixelRatio; var offsetX = /** @type {number} */ (instruction[4]) * pixelRatio;
goog.asserts.assert(goog.isNumber(instruction[5]), goog.asserts.assert(typeof instruction[5] === 'number',
'6th instruction should be a number'); '6th instruction should be a number');
var offsetY = /** @type {number} */ (instruction[5]) * pixelRatio; var offsetY = /** @type {number} */ (instruction[5]) * pixelRatio;
goog.asserts.assert(goog.isNumber(instruction[6]), goog.asserts.assert(typeof instruction[6] === 'number',
'7th instruction should be a number'); '7th instruction should be a number');
rotation = /** @type {number} */ (instruction[6]); rotation = /** @type {number} */ (instruction[6]);
goog.asserts.assert(goog.isNumber(instruction[7]), goog.asserts.assert(typeof instruction[7] === 'number',
'8th instruction should be a number'); '8th instruction should be a number');
scale = /** @type {number} */ (instruction[7]) * pixelRatio; scale = /** @type {number} */ (instruction[7]) * pixelRatio;
goog.asserts.assert(typeof instruction[8] === 'boolean', goog.asserts.assert(typeof instruction[8] === 'boolean',
@@ -469,10 +469,10 @@ ol.render.canvas.Replay.prototype.replay_ = function(
++i; ++i;
break; break;
case ol.render.canvas.Instruction.MOVE_TO_LINE_TO: case ol.render.canvas.Instruction.MOVE_TO_LINE_TO:
goog.asserts.assert(goog.isNumber(instruction[1]), goog.asserts.assert(typeof instruction[1] === 'number',
'2nd instruction should be a number'); '2nd instruction should be a number');
d = /** @type {number} */ (instruction[1]); d = /** @type {number} */ (instruction[1]);
goog.asserts.assert(goog.isNumber(instruction[2]), goog.asserts.assert(typeof instruction[2] === 'number',
'3rd instruction should be a number'); '3rd instruction should be a number');
dd = /** @type {number} */ (instruction[2]); dd = /** @type {number} */ (instruction[2]);
x = pixelCoordinates[d]; x = pixelCoordinates[d];
@@ -508,13 +508,13 @@ ol.render.canvas.Replay.prototype.replay_ = function(
case ol.render.canvas.Instruction.SET_STROKE_STYLE: case ol.render.canvas.Instruction.SET_STROKE_STYLE:
goog.asserts.assert(typeof instruction[1] === 'string', goog.asserts.assert(typeof instruction[1] === 'string',
'2nd instruction should be a string'); '2nd instruction should be a string');
goog.asserts.assert(goog.isNumber(instruction[2]), goog.asserts.assert(typeof instruction[2] === 'number',
'3rd instruction should be a number'); '3rd instruction should be a number');
goog.asserts.assert(typeof instruction[3] === 'string', goog.asserts.assert(typeof instruction[3] === 'string',
'4rd instruction should be a string'); '4rd instruction should be a string');
goog.asserts.assert(typeof instruction[4] === 'string', goog.asserts.assert(typeof instruction[4] === 'string',
'5th instruction should be a string'); '5th instruction should be a string');
goog.asserts.assert(goog.isNumber(instruction[5]), goog.asserts.assert(typeof instruction[5] === 'number',
'6th instruction should be a number'); '6th instruction should be a number');
goog.asserts.assert(instruction[6], goog.asserts.assert(instruction[6],
'7th instruction should not be null'); '7th instruction should not be null');

View File

@@ -258,8 +258,8 @@ ol.reproj.Tile.prototype.reproject_ = function() {
} else { } else {
var z = this.wrappedTileCoord_[0]; var z = this.wrappedTileCoord_[0];
var size = this.targetTileGrid_.getTileSize(z); var size = this.targetTileGrid_.getTileSize(z);
var width = goog.isNumber(size) ? size : size[0]; var width = typeof size === 'number' ? size : size[0];
var height = goog.isNumber(size) ? size : size[1]; var height = typeof size === 'number' ? size : size[1];
var targetResolution = this.targetTileGrid_.getResolution(z); var targetResolution = this.targetTileGrid_.getResolution(z);
var sourceResolution = this.sourceTileGrid_.getResolution(this.sourceZ_); var sourceResolution = this.sourceTileGrid_.getResolution(this.sourceZ_);

View File

@@ -72,7 +72,7 @@ ol.size.toSize = function(size, opt_size) {
if (Array.isArray(size)) { if (Array.isArray(size)) {
return size; return size;
} else { } else {
goog.asserts.assert(goog.isNumber(size)); goog.asserts.assert(typeof size === 'number');
if (opt_size === undefined) { if (opt_size === undefined) {
opt_size = [size, size]; opt_size = [size, size];
} else { } else {

View File

@@ -781,7 +781,7 @@ ol.View.createRotationConstraint_ = function(options) {
return ol.RotationConstraint.createSnapToZero(); return ol.RotationConstraint.createSnapToZero();
} else if (constrainRotation === false) { } else if (constrainRotation === false) {
return ol.RotationConstraint.none; return ol.RotationConstraint.none;
} else if (goog.isNumber(constrainRotation)) { } else if (typeof constrainRotation === 'number') {
return ol.RotationConstraint.createSnapToN(constrainRotation); return ol.RotationConstraint.createSnapToN(constrainRotation);
} else { } else {
goog.asserts.fail( goog.asserts.fail(