Skip to content

Commit 6b4983e

Browse files
committed
refactor: replace indexOf(...) === -1 checks with Array.includes
1 parent fb97af4 commit 6b4983e

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

lib/config-parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function parseMap(map, context) {
129129
* @private
130130
*/
131131
function checkWhitelist(str, whitelist, context) {
132-
if (whitelist.indexOf(str) === -1) {
132+
if (!whitelist.includes(str)) {
133133
throw new ImplementationError(
134134
'Invalid "' + str + '" (allowed: ' + whitelist.join(', ') + ')' + context.errorContext
135135
);

lib/request-resolver.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ function processRequestOptions(req, attrNode, context) {
400400
].join('')
401401
);
402402
}
403-
if (filteredAttrNode.filter.indexOf(filter.operator) === -1) {
403+
if (!filteredAttrNode.filter.includes(filter.operator)) {
404404
throw new RequestError(
405405
[
406406
'Can not filter by attribute "' + filter.attribute.join('.') + '" ',
@@ -437,7 +437,7 @@ function processRequestOptions(req, attrNode, context) {
437437
);
438438
}
439439

440-
if (subFilter.filter.indexOf(filter.operator) === -1) {
440+
if (!subFilter.filter.includes(filter.operator)) {
441441
throw new RequestError(
442442
`Can not filter by sub-resource attribute "${filter.attribute.join('.')}"` +
443443
(context.attrPath.length > 0 ? ` (in "${context.attrPath.join('.')}")` : '') +
@@ -608,7 +608,7 @@ function processRequestOptions(req, attrNode, context) {
608608
].join('')
609609
);
610610
}
611-
if (orderedAttrNode.order.indexOf(orderPart.direction) === -1) {
611+
if (!orderedAttrNode.order.includes(orderPart.direction)) {
612612
throw new RequestError(
613613
[
614614
'Attribute "' + orderPart.attribute.join('.') + '" ',
@@ -1027,7 +1027,7 @@ function resolveResourceTree(resourceTree, parentDataSourceName) {
10271027
let selectedDataSource = primaryName;
10281028
const possibleDataSources = Object.keys(attrInfo.subResourceAttrNode.resolvedParentKey);
10291029

1030-
if (possibleDataSources.indexOf(selectedDataSource) === -1) {
1030+
if (!possibleDataSources.includes(selectedDataSource)) {
10311031
// just select first possible one - optimize?
10321032
selectedDataSource = possibleDataSources[0];
10331033
attrInfo.subResourceAttrNode.parentDataSource = selectedDataSource;

0 commit comments

Comments
 (0)