Use String#startsWith instead of String#indexOf
This commit is contained in:
@@ -14,7 +14,7 @@ if (data.type && data.type.names) {
|
|||||||
<div class="anchor" id="<?js= id ?>">
|
<div class="anchor" id="<?js= id ?>">
|
||||||
</div>
|
</div>
|
||||||
<h4 class="name">
|
<h4 class="name">
|
||||||
<?js= data.attribs + (data.scope === 'static' ? longname : name.indexOf('module:') === 0 ? name.split('/').pop() : name) + typeSignature ?>
|
<?js= data.attribs + (data.scope === 'static' ? longname : name.startsWith('module:') ? name.split('/').pop() : name) + typeSignature ?>
|
||||||
<?js= this.partial('stability.tmpl', data) ?>
|
<?js= this.partial('stability.tmpl', data) ?>
|
||||||
</h4>
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
function toShortName(name) {
|
function toShortName(name) {
|
||||||
return name.indexOf('module:') === 0 ? name.split('/').pop() : name;
|
return name.startsWith('module:') ? name.split('/').pop() : name;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getItemCssClass(type) {
|
function getItemCssClass(type) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
var parentParam = null;
|
var parentParam = null;
|
||||||
params.forEach(function(param, i) {
|
params.forEach(function(param, i) {
|
||||||
if (!param) { return; }
|
if (!param) { return; }
|
||||||
if ( parentParam && param.name && param.name.indexOf(parentParam.name + '.') === 0 ) {
|
if (parentParam && param.name && param.name.startsWith(parentParam.name + '.')) {
|
||||||
param.name = param.name.substr(parentParam.name.length+1);
|
param.name = param.name.substr(parentParam.name.length+1);
|
||||||
parentParam.subparams = parentParam.subparams || [];
|
parentParam.subparams = parentParam.subparams || [];
|
||||||
parentParam.subparams.push(param);
|
parentParam.subparams.push(param);
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
if (param.type && param.type.names && param.type.names.includes('undefined')) {
|
if (param.type && param.type.names && param.type.names.includes('undefined')) {
|
||||||
param.optional = true;
|
param.optional = true;
|
||||||
}
|
}
|
||||||
if (param.name.indexOf('var_') == 0) {
|
if (param.name.startsWith('var_')) {
|
||||||
params.hasAttributes = true;
|
params.hasAttributes = true;
|
||||||
param.variable = true;
|
param.variable = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
var parentProp = null;
|
var parentProp = null;
|
||||||
props.forEach(function(prop, i) {
|
props.forEach(function(prop, i) {
|
||||||
if (!prop) { return; }
|
if (!prop) { return; }
|
||||||
if ( parentProp && prop.name && prop.name.indexOf(parentProp.name + '.') === 0 ) {
|
if (parentProp && prop.name && prop.name.startsWith(parentProp.name + '.')) {
|
||||||
prop.name = prop.name.substr(parentProp.name.length+1);
|
prop.name = prop.name.substr(parentProp.name.length+1);
|
||||||
parentProp.subprops = parentProp.subprops || [];
|
parentProp.subprops = parentProp.subprops || [];
|
||||||
parentProp.subprops.push(prop);
|
parentProp.subprops.push(prop);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ returns.forEach(function (ret, i) {
|
|||||||
var name = ret.name || ret.description;
|
var name = ret.name || ret.description;
|
||||||
var startSpacePos = name.indexOf(" ");
|
var startSpacePos = name.indexOf(" ");
|
||||||
|
|
||||||
if (parentReturn !== null && name.indexOf(parentReturn.name + '.') === 0) {
|
if (parentReturn !== null && name.startsWith(parentReturn.name + '.')) {
|
||||||
ret.name = isNamed ? name.substr(parentReturn.name.length + 1) : name.substr(parentReturn.name.length + 1, startSpacePos - (parentReturn.name.length + 1));
|
ret.name = isNamed ? name.substr(parentReturn.name.length + 1) : name.substr(parentReturn.name.length + 1, startSpacePos - (parentReturn.name.length + 1));
|
||||||
|
|
||||||
parentReturn.subReturns = parentReturn.subReturns || [];
|
parentReturn.subReturns = parentReturn.subReturns || [];
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ exports.publish = function (data, opts) {
|
|||||||
return (
|
return (
|
||||||
this.meta &&
|
this.meta &&
|
||||||
this.meta.path &&
|
this.meta.path &&
|
||||||
this.longname.indexOf('<anonymous>') !== 0 &&
|
!this.longname.startsWith('<anonymous>') &&
|
||||||
this.longname !== 'module:ol'
|
this.longname !== 'module:ol'
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ exports.handlers = {
|
|||||||
observable.name = name;
|
observable.name = name;
|
||||||
observable.readonly =
|
observable.readonly =
|
||||||
typeof observable.readonly == 'boolean' ? observable.readonly : true;
|
typeof observable.readonly == 'boolean' ? observable.readonly : true;
|
||||||
if (doclet.name.indexOf('get') === 0) {
|
if (doclet.name.startsWith('get')) {
|
||||||
observable.type = doclet.returns[0].type;
|
observable.type = doclet.returns[0].type;
|
||||||
observable.description = doclet.returns[0].description;
|
observable.description = doclet.returns[0].description;
|
||||||
} else if (doclet.name.indexOf('set') === 0) {
|
} else if (doclet.name.startsWith('set')) {
|
||||||
observable.readonly = false;
|
observable.readonly = false;
|
||||||
}
|
}
|
||||||
if (doclet.stability) {
|
if (doclet.stability) {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ function getKMLImage(href) {
|
|||||||
let url = href;
|
let url = href;
|
||||||
let path = window.location.href;
|
let path = window.location.href;
|
||||||
path = path.slice(0, path.lastIndexOf('/') + 1);
|
path = path.slice(0, path.lastIndexOf('/') + 1);
|
||||||
if (href.indexOf(path) === 0) {
|
if (href.startsWith(path)) {
|
||||||
const regexp = new RegExp(href.replace(path, '') + '$', 'i');
|
const regexp = new RegExp(href.replace(path, '') + '$', 'i');
|
||||||
const kmlFile = zip.file(regexp)[0];
|
const kmlFile = zip.file(regexp)[0];
|
||||||
if (kmlFile) {
|
if (kmlFile) {
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ map.on(['click', 'pointermove'], function (event) {
|
|||||||
}
|
}
|
||||||
const fid = feature.getId();
|
const fid = feature.getId();
|
||||||
|
|
||||||
if (selectElement.value.indexOf('singleselect') === 0) {
|
if (selectElement.value.startsWith('singleselect')) {
|
||||||
selection = {};
|
selection = {};
|
||||||
}
|
}
|
||||||
// add selected feature to lookup
|
// add selected feature to lookup
|
||||||
|
|||||||
@@ -168,11 +168,11 @@ function fromStringInternal_(s) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
color = [r, g, b, a / 255];
|
color = [r, g, b, a / 255];
|
||||||
} else if (s.indexOf('rgba(') == 0) {
|
} else if (s.startsWith('rgba(')) {
|
||||||
// rgba()
|
// rgba()
|
||||||
color = s.slice(5, -1).split(',').map(Number);
|
color = s.slice(5, -1).split(',').map(Number);
|
||||||
normalize(color);
|
normalize(color);
|
||||||
} else if (s.indexOf('rgb(') == 0) {
|
} else if (s.startsWith('rgb(')) {
|
||||||
// rgb()
|
// rgb()
|
||||||
color = s.slice(4, -1).split(',').map(Number);
|
color = s.slice(4, -1).split(',').map(Number);
|
||||||
color.push(1);
|
color.push(1);
|
||||||
@@ -225,7 +225,5 @@ export function isStringColor(s) {
|
|||||||
if (NAMED_COLOR_RE_.test(s)) {
|
if (NAMED_COLOR_RE_.test(s)) {
|
||||||
s = fromNamed(s);
|
s = fromNamed(s);
|
||||||
}
|
}
|
||||||
return (
|
return HEX_COLOR_RE_.test(s) || s.startsWith('rgba(') || s.startsWith('rgb(');
|
||||||
HEX_COLOR_RE_.test(s) || s.indexOf('rgba(') === 0 || s.indexOf('rgb(') === 0
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -822,7 +822,7 @@ function getTypeName(featurePrefix, featureType) {
|
|||||||
featurePrefix = featurePrefix ? featurePrefix : FEATURE_PREFIX;
|
featurePrefix = featurePrefix ? featurePrefix : FEATURE_PREFIX;
|
||||||
const prefix = featurePrefix + ':';
|
const prefix = featurePrefix + ':';
|
||||||
// The featureType already contains the prefix.
|
// The featureType already contains the prefix.
|
||||||
if (featureType.indexOf(prefix) === 0) {
|
if (featureType.startsWith(prefix)) {
|
||||||
return featureType;
|
return featureType;
|
||||||
} else {
|
} else {
|
||||||
return prefix + featureType;
|
return prefix + featureType;
|
||||||
|
|||||||
@@ -864,7 +864,7 @@ class WKB extends FeatureFormat {
|
|||||||
options.dataProjection && getProjection(options.dataProjection);
|
options.dataProjection && getProjection(options.dataProjection);
|
||||||
if (dataProjection) {
|
if (dataProjection) {
|
||||||
const code = dataProjection.getCode();
|
const code = dataProjection.getCode();
|
||||||
if (code.indexOf('EPSG:') === 0) {
|
if (code.startsWith('EPSG:')) {
|
||||||
srid = Number(code.substring(5));
|
srid = Number(code.substring(5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ export function getMapTileUrlTemplate(links, mediaType) {
|
|||||||
}
|
}
|
||||||
if (knownMapMediaTypes[link.type]) {
|
if (knownMapMediaTypes[link.type]) {
|
||||||
fallbackUrlTemplate = link.href;
|
fallbackUrlTemplate = link.href;
|
||||||
} else if (!fallbackUrlTemplate && link.type.indexOf('image/') === 0) {
|
} else if (!fallbackUrlTemplate && link.type.startsWith('image/')) {
|
||||||
fallbackUrlTemplate = link.href;
|
fallbackUrlTemplate = link.href;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {fileURLToPath} from 'url';
|
|||||||
import {spawn} from 'child_process';
|
import {spawn} from 'child_process';
|
||||||
import {walk} from 'walk';
|
import {walk} from 'walk';
|
||||||
|
|
||||||
const isWindows = process.platform.indexOf('win') === 0;
|
const isWindows = process.platform.startsWith('win');
|
||||||
const baseDir = dirname(fileURLToPath(import.meta.url));
|
const baseDir = dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
const sourceDir = path.join(baseDir, '..', 'src');
|
const sourceDir = path.join(baseDir, '..', 'src');
|
||||||
|
|||||||
Reference in New Issue
Block a user