Remove workaround for Array.prototype.includes

This commit is contained in:
Tim Schaub
2022-07-26 17:57:41 -06:00
parent 14133a05a8
commit 44289a3a31
10 changed files with 75 additions and 65 deletions
+2 -3
View File
@@ -22,7 +22,6 @@ import {
pushSerializeAndPop,
} from '../xml.js';
import {get as getProjection} from '../proj.js';
import {includes} from '../array.js';
import {
readDateTime,
readDecimal,
@@ -172,7 +171,7 @@ class GPX extends XMLFeature {
* @return {import("../Feature.js").default} Feature.
*/
readFeatureFromNode(node, opt_options) {
if (!includes(NAMESPACE_URIS, node.namespaceURI)) {
if (!NAMESPACE_URIS.includes(node.namespaceURI)) {
return null;
}
const featureReader = FEATURE_READER[node.localName];
@@ -195,7 +194,7 @@ class GPX extends XMLFeature {
* @return {Array<import("../Feature.js").default>} Features.
*/
readFeaturesFromNode(node, opt_options) {
if (!includes(NAMESPACE_URIS, node.namespaceURI)) {
if (!NAMESPACE_URIS.includes(node.namespaceURI)) {
return [];
}
if (node.localName == 'gpx') {
+5 -6
View File
@@ -3,7 +3,6 @@
*/
import {assert} from '../asserts.js';
import {includes} from '../array.js';
/**
* @typedef {Object} PreferredOptions
@@ -249,10 +248,10 @@ function generateVersion3Options(iiifInfo) {
iiifInfo.imageInfo.preferredFormats.length > 0
? iiifInfo.imageInfo.preferredFormats
.filter(function (format) {
return includes(['jpg', 'png', 'gif'], format);
return ['jpg', 'png', 'gif'].includes(format);
})
.reduce(function (acc, format) {
return acc === undefined && includes(formats, format)
return acc === undefined && formats.includes(format)
? format
: acc;
}, undefined)
@@ -460,16 +459,16 @@ class IIIFInfo {
sizes: imageOptions.sizes,
format:
options.format !== undefined &&
includes(imageOptions.formats, options.format)
imageOptions.formats.includes(options.format)
? options.format
: imageOptions.preferredFormat !== undefined
? imageOptions.preferredFormat
: 'jpg',
supports: imageOptions.supports,
quality:
options.quality && includes(imageOptions.qualities, options.quality)
options.quality && imageOptions.qualities.includes(options.quality)
? options.quality
: includes(imageOptions.qualities, 'native')
: imageOptions.qualities.includes('native')
? 'native'
: 'default',
resolutions: Array.isArray(imageOptions.resolutions)
+9 -9
View File
@@ -37,7 +37,7 @@ import {
} from '../xml.js';
import {asArray} from '../color.js';
import {assert} from '../asserts.js';
import {extend, includes} from '../array.js';
import {extend} from '../array.js';
import {get as getProjection} from '../proj.js';
import {
readBoolean,
@@ -631,7 +631,7 @@ class KML extends XMLFeature {
* @return {import("../Feature.js").default} Feature.
*/
readFeatureFromNode(node, opt_options) {
if (!includes(NAMESPACE_URIS, node.namespaceURI)) {
if (!NAMESPACE_URIS.includes(node.namespaceURI)) {
return null;
}
const feature = this.readPlacemark_(node, [
@@ -651,7 +651,7 @@ class KML extends XMLFeature {
* @return {Array<import("../Feature.js").default>} Features.
*/
readFeaturesFromNode(node, opt_options) {
if (!includes(NAMESPACE_URIS, node.namespaceURI)) {
if (!NAMESPACE_URIS.includes(node.namespaceURI)) {
return [];
}
let features;
@@ -730,14 +730,14 @@ class KML extends XMLFeature {
*/
readNameFromNode(node) {
for (let n = node.firstElementChild; n; n = n.nextElementSibling) {
if (includes(NAMESPACE_URIS, n.namespaceURI) && n.localName == 'name') {
if (NAMESPACE_URIS.includes(n.namespaceURI) && n.localName == 'name') {
return readString(n);
}
}
for (let n = node.firstElementChild; n; n = n.nextElementSibling) {
const localName = n.localName;
if (
includes(NAMESPACE_URIS, n.namespaceURI) &&
NAMESPACE_URIS.includes(n.namespaceURI) &&
(localName == 'Document' ||
localName == 'Folder' ||
localName == 'Placemark' ||
@@ -803,7 +803,7 @@ class KML extends XMLFeature {
const networkLinks = [];
for (let n = node.firstElementChild; n; n = n.nextElementSibling) {
if (
includes(NAMESPACE_URIS, n.namespaceURI) &&
NAMESPACE_URIS.includes(n.namespaceURI) &&
n.localName == 'NetworkLink'
) {
const obj = pushParseAndPop({}, NETWORK_LINK_PARSERS, n, []);
@@ -813,7 +813,7 @@ class KML extends XMLFeature {
for (let n = node.firstElementChild; n; n = n.nextElementSibling) {
const localName = n.localName;
if (
includes(NAMESPACE_URIS, n.namespaceURI) &&
NAMESPACE_URIS.includes(n.namespaceURI) &&
(localName == 'Document' || localName == 'Folder' || localName == 'kml')
) {
extend(networkLinks, this.readNetworkLinksFromNode(n));
@@ -867,7 +867,7 @@ class KML extends XMLFeature {
readRegionFromNode(node) {
const regions = [];
for (let n = node.firstElementChild; n; n = n.nextElementSibling) {
if (includes(NAMESPACE_URIS, n.namespaceURI) && n.localName == 'Region') {
if (NAMESPACE_URIS.includes(n.namespaceURI) && n.localName == 'Region') {
const obj = pushParseAndPop({}, REGION_PARSERS, n, []);
regions.push(obj);
}
@@ -875,7 +875,7 @@ class KML extends XMLFeature {
for (let n = node.firstElementChild; n; n = n.nextElementSibling) {
const localName = n.localName;
if (
includes(NAMESPACE_URIS, n.namespaceURI) &&
NAMESPACE_URIS.includes(n.namespaceURI) &&
(localName == 'Document' || localName == 'Folder' || localName == 'kml')
) {
extend(regions, this.readRegionFromNode(n));
+2 -2
View File
@@ -4,7 +4,7 @@
import GML2 from './GML2.js';
import XMLFeature from './XMLFeature.js';
import {assign} from '../obj.js';
import {extend, includes} from '../array.js';
import {extend} from '../array.js';
import {makeArrayPusher, makeStructureNS, pushParseAndPop} from '../xml.js';
/**
@@ -100,7 +100,7 @@ class WMSGetFeatureInfo extends XMLFeature {
const toRemove = layerIdentifier;
const layerName = layerElement.localName.replace(toRemove, '');
if (this.layers_ && !includes(this.layers_, layerName)) {
if (this.layers_ && !this.layers_.includes(layerName)) {
continue;
}