Use includes instead of indexOf

This commit is contained in:
Maximilian Krög
2022-08-05 00:36:16 +02:00
parent 5e34b9aa20
commit 0b945f2321
26 changed files with 50 additions and 57 deletions
+4 -5
View File
@@ -167,7 +167,7 @@ class GMLBase extends XMLFeature {
const child = /** @type {Element} */ (node.childNodes[i]);
if (child.nodeType === 1) {
const ft = child.nodeName.split(':').pop();
if (featureType.indexOf(ft) === -1) {
if (!featureType.includes(ft)) {
let key = '';
let count = 0;
const uri = child.namespaceURI;
@@ -206,10 +206,9 @@ class GMLBase extends XMLFeature {
/** @type {Object<string, import("../xml.js").Parser>} */
const parsers = {};
for (let i = 0, ii = featureTypes.length; i < ii; ++i) {
const featurePrefix =
featureTypes[i].indexOf(':') === -1
? defaultPrefix
: featureTypes[i].split(':')[0];
const featurePrefix = featureTypes[i].includes(':')
? featureTypes[i].split(':')[0]
: defaultPrefix;
if (featurePrefix === p) {
parsers[featureTypes[i].split(':').pop()] =
localName == 'featureMembers'
+1 -1
View File
@@ -262,7 +262,7 @@ class MVT extends FeatureFormat {
const pbfLayers = pbf.readFields(layersPBFReader, {});
const features = [];
for (const name in pbfLayers) {
if (layers && layers.indexOf(name) == -1) {
if (layers && !layers.includes(name)) {
continue;
}
const pbfLayer = pbfLayers[name];
+1 -1
View File
@@ -110,7 +110,7 @@ class TopoJSON extends JSONFeature {
const property = this.layerName_;
let feature;
for (const objectName in topoJSONFeatures) {
if (this.layers_ && this.layers_.indexOf(objectName) == -1) {
if (this.layers_ && !this.layers_.includes(objectName)) {
continue;
}
if (topoJSONFeatures[objectName].type === 'GeometryCollection') {
+2 -2
View File
@@ -498,10 +498,10 @@ class WkbWriter {
*/
writeWkbHeader(wkbType, srid) {
wkbType %= 1000; // Assume 1000 is an upper limit for type ID
if (this.layout_.indexOf('Z') >= 0) {
if (this.layout_.includes('Z')) {
wkbType += this.isEWKB_ ? 0x80000000 : 1000;
}
if (this.layout_.indexOf('M') >= 0) {
if (this.layout_.includes('M')) {
wkbType += this.isEWKB_ ? 0x40000000 : 2000;
}
if (this.isEWKB_ && Number.isInteger(srid)) {