Skip to content

Commit 1d7b74b

Browse files
committed
Replace isArray.js with native Array.isArray function
1 parent 56373c4 commit 1d7b74b

24 files changed

+55
-76
lines changed

Apps/Sandcastle/gallery/Clustering.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
var pickedLabel = viewer.scene.pick(movement.position);
150150
if (Cesium.defined(pickedLabel)) {
151151
var ids = pickedLabel.id;
152-
if (Cesium.isArray(ids)) {
152+
if (Array.isArray(ids)) {
153153
for (var i = 0; i < ids.length; ++i) {
154154
ids[i].billboard.color = Cesium.Color.RED;
155155
}

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Change Log
55

66
##### Deprecated :hourglass_flowing_sand:
77
* The property `Scene.sunColor` has been deprecated and will be removed in Cesium 1.69. Use `scene.light.color` and `scene.light.intensity` instead. [#8493](https://github.com/AnalyticalGraphicsInc/cesium/pull/8493)
8+
* The `isArray` function has been deprecated and will be removed in Cesium 1.69. Use the native `Array.isArray` function instead. [#8526](https://github.com/AnalyticalGraphicsInc/cesium/pull/8526)
89

910
##### Additions :tada:
1011

Source/Core/PolylinePipeline.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import Ellipsoid from './Ellipsoid.js';
77
import EllipsoidGeodesic from './EllipsoidGeodesic.js';
88
import EllipsoidRhumbLine from './EllipsoidRhumbLine.js';
99
import IntersectionTests from './IntersectionTests.js';
10-
import isArray from './isArray.js';
1110
import CesiumMath from './Math.js';
1211
import Matrix4 from './Matrix4.js';
1312
import Plane from './Plane.js';
@@ -260,7 +259,7 @@ import Plane from './Plane.js';
260259
var length = positions.length;
261260
var ellipsoid = defaultValue(options.ellipsoid, Ellipsoid.WGS84);
262261
var height = defaultValue(options.height, 0);
263-
var hasHeightArray = isArray(height);
262+
var hasHeightArray = Array.isArray(height);
264263

265264
if (length < 1) {
266265
return [];
@@ -351,7 +350,7 @@ import Plane from './Plane.js';
351350
var length = positions.length;
352351
var ellipsoid = defaultValue(options.ellipsoid, Ellipsoid.WGS84);
353352
var height = defaultValue(options.height, 0);
354-
var hasHeightArray = isArray(height);
353+
var hasHeightArray = Array.isArray(height);
355354

356355
if (length < 1) {
357356
return [];

Source/Core/isArray.js

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import defined from './defined.js';
66
*
77
* @param {*} value The value to test.
88
* @returns {Boolean} true if the value is an array, false otherwise.
9+
* @deprecated See https://github.com/AnalyticalGraphicsInc/cesium/issues/8526.
10+
* Use `Array.isArray` instead
911
*/
1012
var isArray = Array.isArray;
1113
if (!defined(isArray)) {

Source/Core/objectToQuery.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import defined from './defined.js';
22
import DeveloperError from './DeveloperError.js';
3-
import isArray from './isArray.js';
43

54
/**
65
* Converts an object representing a set of name/value pairs into a query string,
@@ -36,7 +35,7 @@ import isArray from './isArray.js';
3635
var value = obj[propName];
3736

3837
var part = encodeURIComponent(propName) + '=';
39-
if (isArray(value)) {
38+
if (Array.isArray(value)) {
4039
for (var i = 0, len = value.length; i < len; ++i) {
4140
result += part + encodeURIComponent(value[i]) + '&';
4241
}

Source/Core/queryToObject.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import defined from './defined.js';
22
import DeveloperError from './DeveloperError.js';
3-
import isArray from './isArray.js';
43

54
/**
65
* Parses a query string into an object, where the keys and values of the object are the
@@ -50,7 +49,7 @@ import isArray from './isArray.js';
5049
if (typeof resultValue === 'string') {
5150
// expand the single value to an array
5251
result[name] = [resultValue, value];
53-
} else if (isArray(resultValue)) {
52+
} else if (Array.isArray(resultValue)) {
5453
resultValue.push(value);
5554
} else {
5655
result[name] = value;

Source/DataSources/CzmlDataSource.js

+11-12
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import Event from '../Core/Event.js';
1919
import ExtrapolationType from '../Core/ExtrapolationType.js';
2020
import getFilenameFromUri from '../Core/getFilenameFromUri.js';
2121
import HermitePolynomialApproximation from '../Core/HermitePolynomialApproximation.js';
22-
import isArray from '../Core/isArray.js';
2322
import Iso8601 from '../Core/Iso8601.js';
2423
import JulianDate from '../Core/JulianDate.js';
2524
import LagrangePolynomialApproximation from '../Core/LagrangePolynomialApproximation.js';
@@ -776,7 +775,7 @@ import WallGraphics from './WallGraphics.js';
776775
return;
777776
}
778777

779-
if (isArray(packetData)) {
778+
if (Array.isArray(packetData)) {
780779
for (var i = 0, len = packetData.length; i < len; ++i) {
781780
processProperty(type, object, propertyName, packetData[i], interval, sourceUri, entityCollection);
782781
}
@@ -950,7 +949,7 @@ import WallGraphics from './WallGraphics.js';
950949
return;
951950
}
952951

953-
if (isArray(packetData)) {
952+
if (Array.isArray(packetData)) {
954953
for (var i = 0, len = packetData.length; i < len; ++i) {
955954
processPositionProperty(object, propertyName, packetData[i], interval, sourceUri, entityCollection);
956955
}
@@ -1086,7 +1085,7 @@ import WallGraphics from './WallGraphics.js';
10861085
return;
10871086
}
10881087

1089-
if (isArray(packetData)) {
1088+
if (Array.isArray(packetData)) {
10901089
for (var i = 0, len = packetData.length; i < len; ++i) {
10911090
processMaterialProperty(object, propertyName, packetData[i], interval, sourceUri, entityCollection);
10921091
}
@@ -1148,7 +1147,7 @@ import WallGraphics from './WallGraphics.js';
11481147
}
11491148

11501149
var propertyData = propertiesData[key];
1151-
if (isArray(propertyData)) {
1150+
if (Array.isArray(propertyData)) {
11521151
for (var i = 0, len = propertyData.length; i < len; ++i) {
11531152
processProperty(getPropertyType(propertyData[i]), entity.properties, key, propertyData[i], undefined, sourceUri, entityCollection);
11541153
}
@@ -1200,7 +1199,7 @@ import WallGraphics from './WallGraphics.js';
12001199
return;
12011200
}
12021201

1203-
if (isArray(packetData)) {
1202+
if (Array.isArray(packetData)) {
12041203
for (var i = 0, length = packetData.length; i < length; ++i) {
12051204
processArrayPacketData(object, propertyName, packetData[i], entityCollection);
12061205
}
@@ -1233,7 +1232,7 @@ import WallGraphics from './WallGraphics.js';
12331232
return;
12341233
}
12351234

1236-
if (isArray(packetData)) {
1235+
if (Array.isArray(packetData)) {
12371236
for (var i = 0, length = packetData.length; i < length; ++i) {
12381237
processPositionArrayPacketData(object, propertyName, packetData[i], entityCollection);
12391238
}
@@ -1283,7 +1282,7 @@ import WallGraphics from './WallGraphics.js';
12831282
return;
12841283
}
12851284

1286-
if (isArray(packetData)) {
1285+
if (Array.isArray(packetData)) {
12871286
for (var i = 0, length = packetData.length; i < length; ++i) {
12881287
processPositionArrayOfArraysPacketData(object, propertyName, packetData[i], entityCollection);
12891288
}
@@ -1299,7 +1298,7 @@ import WallGraphics from './WallGraphics.js';
12991298
}
13001299

13011300
var intervals;
1302-
if (isArray(packetData)) {
1301+
if (Array.isArray(packetData)) {
13031302
for (var i = 0, len = packetData.length; i < len; ++i) {
13041303
if (!defined(intervals)) {
13051304
intervals = new TimeIntervalCollection();
@@ -1617,7 +1616,7 @@ import WallGraphics from './WallGraphics.js';
16171616
var i, len;
16181617
var nodeTransformationsData = modelData.nodeTransformations;
16191618
if (defined(nodeTransformationsData)) {
1620-
if (isArray(nodeTransformationsData)) {
1619+
if (Array.isArray(nodeTransformationsData)) {
16211620
for (i = 0, len = nodeTransformationsData.length; i < len; ++i) {
16221621
processNodeTransformations(model, nodeTransformationsData[i], interval, sourceUri, entityCollection);
16231622
}
@@ -1628,7 +1627,7 @@ import WallGraphics from './WallGraphics.js';
16281627

16291628
var articulationsData = modelData.articulations;
16301629
if (defined(articulationsData)) {
1631-
if (isArray(articulationsData)) {
1630+
if (Array.isArray(articulationsData)) {
16321631
for (i = 0, len = articulationsData.length; i < len; ++i) {
16331632
processArticulations(model, articulationsData[i], interval, sourceUri, entityCollection);
16341633
}
@@ -2389,7 +2388,7 @@ import WallGraphics from './WallGraphics.js';
23892388
CzmlDataSource._processCzml = function(czml, entityCollection, sourceUri, updaterFunctions, dataSource) {
23902389
updaterFunctions = defaultValue(updaterFunctions, CzmlDataSource.updaters);
23912390

2392-
if (isArray(czml)) {
2391+
if (Array.isArray(czml)) {
23932392
for (var i = 0, len = czml.length; i < len; ++i) {
23942393
processCzmlPacket(czml[i], entityCollection, updaterFunctions, sourceUri, dataSource);
23952394
}

Source/DataSources/PolygonGraphics.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ import defined from '../Core/defined.js';
33
import defineProperties from '../Core/defineProperties.js';
44
import DeveloperError from '../Core/DeveloperError.js';
55
import Event from '../Core/Event.js';
6-
import isArray from '../Core/isArray.js';
76
import PolygonHierarchy from '../Core/PolygonHierarchy.js';
87
import ConstantProperty from './ConstantProperty.js';
98
import createMaterialPropertyDescriptor from './createMaterialPropertyDescriptor.js';
109
import createPropertyDescriptor from './createPropertyDescriptor.js';
1110

1211
function createPolygonHierarchyProperty(value) {
13-
if (isArray(value)) {
12+
if (Array.isArray(value)) {
1413
// convert array of positions to PolygonHierarchy object
1514
value = new PolygonHierarchy(value);
1615
}

Source/DataSources/exportKml.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import defined from '../Core/defined.js';
88
import defineProperties from '../Core/defineProperties.js';
99
import DeveloperError from '../Core/DeveloperError.js';
1010
import Ellipsoid from '../Core/Ellipsoid.js';
11-
import isArray from '../Core/isArray.js';
1211
import Iso8601 from '../Core/Iso8601.js';
1312
import JulianDate from '../Core/JulianDate.js';
1413
import CesiumMath from '../Core/Math.js';
@@ -949,7 +948,7 @@ import ScaledPositionProperty from './ScaledPositionProperty.js';
949948
var hierarchy = valueGetter.get(hierarchyProperty);
950949

951950
// Polygon hierarchy can sometimes just be an array of positions
952-
var positions = isArray(hierarchy) ? hierarchy : hierarchy.positions;
951+
var positions = Array.isArray(hierarchy) ? hierarchy : hierarchy.positions;
953952

954953
// Polygon boundaries
955954
var outerBoundaryIs = kmlDoc.createElement('outerBoundaryIs');
@@ -1206,7 +1205,7 @@ import ScaledPositionProperty from './ScaledPositionProperty.js';
12061205
}
12071206

12081207
function getCoordinates(coordinates, ellipsoid) {
1209-
if (!isArray(coordinates)) {
1208+
if (!Array.isArray(coordinates)) {
12101209
coordinates = [coordinates];
12111210
}
12121211

Source/Scene/ClassificationPrimitive.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import defineProperties from '../Core/defineProperties.js';
66
import destroyObject from '../Core/destroyObject.js';
77
import DeveloperError from '../Core/DeveloperError.js';
88
import GeometryInstance from '../Core/GeometryInstance.js';
9-
import isArray from '../Core/isArray.js';
109
import DrawCommand from '../Renderer/DrawCommand.js';
1110
import Pass from '../Renderer/Pass.js';
1211
import RenderState from '../Renderer/RenderState.js';
@@ -173,7 +172,7 @@ import StencilOperation from './StencilOperation.js';
173172
this.appearance = options.appearance;
174173

175174
var readOnlyAttributes;
176-
if (defined(geometryInstances) && isArray(geometryInstances) && geometryInstances.length > 1) {
175+
if (defined(geometryInstances) && Array.isArray(geometryInstances) && geometryInstances.length > 1) {
177176
readOnlyAttributes = ClassificationPrimitiveReadOnlyInstanceAttributes;
178177
}
179178

@@ -1002,7 +1001,7 @@ import StencilOperation from './StencilOperation.js';
10021001
var primitiveOptions = this._primitiveOptions;
10031002

10041003
if (!defined(this._primitive)) {
1005-
var instances = isArray(this.geometryInstances) ? this.geometryInstances : [this.geometryInstances];
1004+
var instances = Array.isArray(this.geometryInstances) ? this.geometryInstances : [this.geometryInstances];
10061005
var length = instances.length;
10071006

10081007
var i;

Source/Scene/Expression.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import Color from '../Core/Color.js';
66
import defined from '../Core/defined.js';
77
import defineProperties from '../Core/defineProperties.js';
88
import DeveloperError from '../Core/DeveloperError.js';
9-
import isArray from '../Core/isArray.js';
109
import CesiumMath from '../Core/Math.js';
1110
import RuntimeError from '../Core/RuntimeError.js';
1211
import jsep from '../ThirdParty/jsep.js';
@@ -1569,7 +1568,7 @@ import ExpressionNodeType from './ExpressionNodeType.js';
15691568
var value = this._value;
15701569

15711570
if (defined(this._left)) {
1572-
if (isArray(this._left)) {
1571+
if (Array.isArray(this._left)) {
15731572
// Left can be an array if the type is LITERAL_COLOR or LITERAL_VECTOR
15741573
left = getExpressionArray(this._left, attributePrefix, shaderState, this);
15751574
} else {
@@ -1585,7 +1584,7 @@ import ExpressionNodeType from './ExpressionNodeType.js';
15851584
test = this._test.getShaderExpression(attributePrefix, shaderState, this);
15861585
}
15871586

1588-
if (isArray(this._value)) {
1587+
if (Array.isArray(this._value)) {
15891588
// For ARRAY type
15901589
value = getExpressionArray(this._value, attributePrefix, shaderState, this);
15911590
}

Source/Scene/GroundPolylinePrimitive.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import DeveloperError from '../Core/DeveloperError.js';
88
import GeometryInstance from '../Core/GeometryInstance.js';
99
import GeometryInstanceAttribute from '../Core/GeometryInstanceAttribute.js';
1010
import GroundPolylineGeometry from '../Core/GroundPolylineGeometry.js';
11-
import isArray from '../Core/isArray.js';
1211
import DrawCommand from '../Renderer/DrawCommand.js';
1312
import Pass from '../Renderer/Pass.js';
1413
import RenderState from '../Renderer/RenderState.js';
@@ -596,7 +595,7 @@ import StencilOperation from './StencilOperation.js';
596595
var that = this;
597596
var primitiveOptions = this._primitiveOptions;
598597
if (!defined(this._primitive)) {
599-
var geometryInstances = isArray(this.geometryInstances) ? this.geometryInstances : [this.geometryInstances];
598+
var geometryInstances = Array.isArray(this.geometryInstances) ? this.geometryInstances : [this.geometryInstances];
600599
var geometryInstancesLength = geometryInstances.length;
601600
var groundInstances = new Array(geometryInstancesLength);
602601

Source/Scene/GroundPrimitive.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import defineProperties from '../Core/defineProperties.js';
99
import destroyObject from '../Core/destroyObject.js';
1010
import DeveloperError from '../Core/DeveloperError.js';
1111
import GeometryInstance from '../Core/GeometryInstance.js';
12-
import isArray from '../Core/isArray.js';
1312
import OrientedBoundingBox from '../Core/OrientedBoundingBox.js';
1413
import Rectangle from '../Core/Rectangle.js';
1514
import when from '../ThirdParty/when.js';
@@ -119,7 +118,7 @@ import ShadowVolumeAppearance from './ShadowVolumeAppearance.js';
119118
var appearance = options.appearance;
120119
var geometryInstances = options.geometryInstances;
121120
if (!defined(appearance) && defined(geometryInstances)) {
122-
var geometryInstancesArray = isArray(geometryInstances) ? geometryInstances : [geometryInstances];
121+
var geometryInstancesArray = Array.isArray(geometryInstances) ? geometryInstances : [geometryInstances];
123122
var geometryInstanceCount = geometryInstancesArray.length;
124123
for (var i = 0; i < geometryInstanceCount; i++) {
125124
var attributes = geometryInstancesArray[i].attributes;
@@ -619,7 +618,7 @@ import ShadowVolumeAppearance from './ShadowVolumeAppearance.js';
619618
var geometry;
620619
var instanceType;
621620

622-
var instances = isArray(this.geometryInstances) ? this.geometryInstances : [this.geometryInstances];
621+
var instances = Array.isArray(this.geometryInstances) ? this.geometryInstances : [this.geometryInstances];
623622
var length = instances.length;
624623
var groundInstances = new Array(length);
625624

Source/Scene/Material.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import defined from '../Core/defined.js';
88
import defineProperties from '../Core/defineProperties.js';
99
import destroyObject from '../Core/destroyObject.js';
1010
import DeveloperError from '../Core/DeveloperError.js';
11-
import isArray from '../Core/isArray.js';
1211
import loadCRN from '../Core/loadCRN.js';
1312
import loadKTX from '../Core/loadKTX.js';
1413
import Matrix2 from '../Core/Matrix2.js';
@@ -993,7 +992,7 @@ import when from '../ThirdParty/when.js';
993992
uniformType = 'sampler2D';
994993
}
995994
} else if (type === 'object') {
996-
if (isArray(uniformValue)) {
995+
if (Array.isArray(uniformValue)) {
997996
if (uniformValue.length === 4 || uniformValue.length === 9 || uniformValue.length === 16) {
998997
uniformType = 'mat' + Math.sqrt(uniformValue.length);
999998
}

Source/Scene/Model.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import getAbsoluteUri from '../Core/getAbsoluteUri.js';
2020
import getMagic from '../Core/getMagic.js';
2121
import getStringFromTypedArray from '../Core/getStringFromTypedArray.js';
2222
import IndexDatatype from '../Core/IndexDatatype.js';
23-
import isArray from '../Core/isArray.js';
2423
import loadCRN from '../Core/loadCRN.js';
2524
import loadImageFromTypedArray from '../Core/loadImageFromTypedArray.js';
2625
import loadKTX from '../Core/loadKTX.js';
@@ -1141,7 +1140,7 @@ import ShadowMode from './ShadowMode.js';
11411140
},
11421141
set : function(value) {
11431142
//>>includeStart('debug', pragmas.debug);
1144-
if (defined(value) && (!isArray(value) || value.length !== 9)) {
1143+
if (defined(value) && (!Array.isArray(value) || value.length !== 9)) {
11451144
throw new DeveloperError('sphericalHarmonicCoefficients must be an array of 9 Cartesian3 values.');
11461145
}
11471146
//>>includeEnd('debug');

0 commit comments

Comments
 (0)