Skip to content

Commit

Permalink
chore: ECMAScript 2016, replace Array.prototype.indexOf by Array.prot…
Browse files Browse the repository at this point in the history
…otype.includes
  • Loading branch information
gchoqueux committed Dec 4, 2018
1 parent 5562ccd commit 82665f7
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Core/Picking.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function screenCoordsToNodeId(view, tileLayer, viewCoords, radius) {
const unpack = unpack1K(depthRGBA, 256 ** 3);

const _id = Math.round(unpack);
if (ids.indexOf(_id) < 0) {
if (!ids.includes(_id)) {
ids.push(_id);
}
});
Expand Down Expand Up @@ -120,7 +120,7 @@ export default {
const _ids = screenCoordsToNodeId(_view, layer, viewCoords, radius);

const extractResult = (node) => {
if (_ids.indexOf(node.id) >= 0 && node instanceof TileMesh) {
if (_ids.includes(node.id) && node instanceof TileMesh) {
results.push({
object: node,
layer,
Expand Down
2 changes: 1 addition & 1 deletion src/Core/System/Capabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function _WebGLShader(renderer, type, string) {
}

function isFirefox() {
return navigator && navigator.userAgent && navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
return navigator && navigator.userAgent && navigator.userAgent.toLowerCase().includes('firefox');
}

export default {
Expand Down
5 changes: 2 additions & 3 deletions src/Core/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ View.prototype.addLayer = function addLayer(layer, parentLayer) {
layer.whenReady.then((layer) => {
this.notifyChange(parentLayer || layer, false);
if (!this._frameRequesters[MAIN_LOOP_EVENTS.UPDATE_END] ||
this._frameRequesters[MAIN_LOOP_EVENTS.UPDATE_END].indexOf(this._allLayersAreReadyCallback) == -1) {
!this._frameRequesters[MAIN_LOOP_EVENTS.UPDATE_END].includes(this._allLayersAreReadyCallback)) {
this.addFrameRequester(MAIN_LOOP_EVENTS.UPDATE_END, this._allLayersAreReadyCallback);
}
resolve(layer);
Expand Down Expand Up @@ -452,8 +452,7 @@ View.prototype.addFrameRequester = function addFrameRequester(when, frameRequest
* @param {FrameRequester} frameRequester
*/
View.prototype.removeFrameRequester = function removeFrameRequester(when, frameRequester) {
const index = this._frameRequesters[when].indexOf(frameRequester);
if (index >= 0) {
if (this._frameRequesters[when].includes(frameRequester)) {
this._delayedFrameRequesterRemoval.push({ when, frameRequester });
} else {
console.error('Invalid call to removeFrameRequester: frameRequester isn\'t registered');
Expand Down
2 changes: 1 addition & 1 deletion src/Parser/B3dmParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function filterUnsupportedSemantics(obj) {
}
for (const name of names) {
const semantic = obj.gltfShader.boundUniforms[name].semantic;
if (supported.indexOf(semantic) < 0) {
if (!supported.includes(semantic)) {
delete obj.gltfShader.boundUniforms[name];
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Parser/GeoJsonParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ function readFeature(crsIn, crsOut, json, filteringExtent, options, featureMerge

// copy other properties
for (const key of Object.keys(json)) {
if (keyProperties.indexOf(key.toLowerCase()) < 0) {
if (!keyProperties.includes(key.toLowerCase())) {
properties[key] = json[key];
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Renderer/Shader/ShaderUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const reMain = new RegExp('[^\\w]*main[^\\w]*(void)?[^\\w]*{');
export default {
patchMaterialForLogDepthSupport(material) {
// Check if the shader does not already use the log depth buffer
if (material.vertexShader.indexOf('USE_LOGDEPTHBUF') !== -1
|| material.vertexShader.indexOf('logdepthbuf_pars_vertex') !== -1) {
if (material.vertexShader.includes('USE_LOGDEPTHBUF')
|| material.vertexShader.includes('logdepthbuf_pars_vertex')) {
return;
}

Expand Down

0 comments on commit 82665f7

Please sign in to comment.