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
+1 -1
View File
@@ -461,7 +461,7 @@ exports.publish = function (taffyData, opts, tutorials) {
data().each(function (doclet) {
const url = helper.longnameToUrl[doclet.longname];
if (url.indexOf('#') > -1) {
if (url.includes('#')) {
doclet.id = helper.longnameToUrl[doclet.longname].split(/#/).pop();
} else {
doclet.id = doclet.name;
@@ -79,7 +79,7 @@
<?js if (doc.kind == 'class') {
var subclasses = self.find(function() {
return this.augments && this.augments.indexOf(doc.longname) > -1;
return this.augments && this.augments.includes(doc.longname);
})
if (subclasses.length) {
?>
+1 -1
View File
@@ -6,7 +6,7 @@
<p class="code-caption"><?js= example.caption ?></p>
<?js } ?>
<?js if (example.code.toString().indexOf('<pre>') === -1) { ?>
<?js if (!example.code.toString().includes('<pre>')) { ?>
<pre class="prettyprint"><code><?js= example.code ?></code></pre>
<?js } else { ?>
<?js= example.code.replace(/<pre>/g, '<pre class="prettyprint">') ?>
+2 -2
View File
@@ -23,7 +23,7 @@
var colspan = 2;
params.forEach(function(param) {
if (!param) { return; }
if (param.type && param.type.names && param.type.names.indexOf('undefined') !== -1) {
if (param.type && param.type.names && param.type.names.includes('undefined')) {
param.optional = true;
}
if (param.name.indexOf('var_') == 0) {
@@ -70,7 +70,7 @@
<?js if (!param.subparams) {?>
<td class="type">
<?js if (param.type && param.type.names) {?>
<?js= self.partial('type.tmpl', param.type.names) + (param.optional && typeof param.defaultvalue === 'undefined' && param.type.names.indexOf('undefined') === -1 ? ' | undefined' : '') ?>
<?js= self.partial('type.tmpl', param.type.names) + (param.optional && typeof param.defaultvalue === 'undefined' && !param.type.names.includes('undefined') ? ' | undefined' : '') ?>
<?js if (typeof param.defaultvalue !== 'undefined') { ?>
(defaults to <?js= self.htmlsafe(param.defaultvalue) ?>)
<?js } ?>
+1 -1
View File
@@ -59,7 +59,7 @@ exports.publish = function (data, opts) {
if (
constructor &&
constructor.substr(-1) === '_' &&
constructor.indexOf('module:') === -1
!constructor.includes('module:')
) {
assert.strictEqual(
doc.inherited,
+3 -3
View File
@@ -37,7 +37,7 @@ function includeAugments(doclet) {
if (doclet.fires && cls.fires) {
for (let i = 0, ii = cls.fires.length; i < ii; ++i) {
const fires = cls.fires[i];
if (doclet.fires.indexOf(fires) == -1) {
if (!doclet.fires.includes(fires)) {
doclet.fires.push(fires);
}
}
@@ -58,7 +58,7 @@ function includeAugments(doclet) {
doclet.fires = [];
}
cls.fires.forEach(function (f) {
if (doclet.fires.indexOf(f) == -1) {
if (!doclet.fires.includes(f)) {
doclet.fires.push(f);
}
});
@@ -68,7 +68,7 @@ function includeAugments(doclet) {
doclet.observables = [];
}
cls.observables.forEach(function (f) {
if (doclet.observables.indexOf(f) == -1) {
if (!doclet.observables.includes(f)) {
doclet.observables.push(f);
}
});
+1 -1
View File
@@ -76,7 +76,7 @@ function shouldProcessString(tagName, text) {
let shouldProcess = true;
// we only want to process `@author` and `@see` tags that contain Markdown links
if ((tagName === 'author' || tagName === 'see') && text.indexOf('[') === -1) {
if ((tagName === 'author' || tagName === 'see') && !text.includes('[')) {
shouldProcess = false;
}
+2 -2
View File
@@ -42,14 +42,14 @@ exports.handlers = {
cls.observables = [];
}
observable = observables[doclet.observable];
if (observable.type && cls.observables.indexOf(observable) == -1) {
if (observable.type && !cls.observables.includes(observable)) {
cls.observables.push(observable);
}
if (!cls.fires) {
cls.fires = [];
}
event = 'module:ol/Object.ObjectEvent#event:change:' + name;
if (cls.fires.indexOf(event) == -1) {
if (!cls.fires.includes(event)) {
cls.fires.push(event);
}
}