diff --git a/src/compile/selection/inputs.ts b/src/compile/selection/inputs.ts index 8e8e6c3afd..5259fcea00 100644 --- a/src/compile/selection/inputs.ts +++ b/src/compile/selection/inputs.ts @@ -55,7 +55,7 @@ const inputBindings: SelectionCompiler<'point'> = { signals: (model, selCmpt, signals) => { const name = selCmpt.name; const proj = selCmpt.project; - const signal: NewSignal = signals.filter(s => s.name === name + TUPLE)[0]; + const signal: NewSignal = signals.find(s => s.name === name + TUPLE); const fields = name + TUPLE_FIELDS; const values = proj.items.map(p => varName(`${name}_${p.field}`)); const valid = values.map(v => `${v} !== null`).join(' && '); diff --git a/src/compile/selection/interval.ts b/src/compile/selection/interval.ts index 12456bfa31..1c8a7aed05 100644 --- a/src/compile/selection/interval.ts +++ b/src/compile/selection/interval.ts @@ -47,7 +47,7 @@ const interval: SelectionCompiler<'interval'> = { } const filters = array((evt.between[0].filter ??= [])); - if (filters.indexOf(filterExpr) < 0) { + if (!filters.includes(filterExpr)) { filters.push(filterExpr); } } diff --git a/src/compile/selection/nearest.ts b/src/compile/selection/nearest.ts index 1a66f0032c..9c835ac727 100644 --- a/src/compile/selection/nearest.ts +++ b/src/compile/selection/nearest.ts @@ -58,7 +58,7 @@ const nearest: SelectionCompiler<'point'> = { const name = mark.name ?? ''; if (name === model.component.mark[0].name) { index = i; - } else if (name.indexOf(VORONOI) >= 0) { + } else if (name.includes(VORONOI)) { exists = true; } }); diff --git a/src/compile/selection/scales.ts b/src/compile/selection/scales.ts index 0c2b577713..60f9b7f59a 100644 --- a/src/compile/selection/scales.ts +++ b/src/compile/selection/scales.ts @@ -57,9 +57,9 @@ const scaleBindings: SelectionCompiler<'interval'> = { // state is captured by the top-level signals that we insert and "push // outer" to from within the units. We need to reassemble this state into // the top-level named signal, except no single selCmpt has a global view. - const namedSg: NewSignal = signals.filter(s => s.name === selCmpt.name)[0]; + const namedSg: NewSignal = signals.find(s => s.name === selCmpt.name); let update = namedSg.update; - if (update.indexOf(VL_SELECTION_RESOLVE) >= 0) { + if (update.includes(VL_SELECTION_RESOLVE)) { namedSg.update = `{${bound .map(proj => `${stringValue(replacePathInField(proj.field))}: ${proj.signals.data}`) .join(', ')}}`; diff --git a/src/compile/selection/translate.ts b/src/compile/selection/translate.ts index 25cce1a447..8431ae10b0 100644 --- a/src/compile/selection/translate.ts +++ b/src/compile/selection/translate.ts @@ -80,7 +80,7 @@ function onDelta( const delta = name + DELTA; const channel = proj.channel as ScaleChannel; const boundScales = scalesCompiler.defined(selCmpt); - const signal = signals.filter(s => s.name === proj.signals[boundScales ? 'data' : 'visual'])[0]; + const signal = signals.find(s => s.name === proj.signals[boundScales ? 'data' : 'visual']); const sizeSg = model.getSizeSignalRef(size).signal; const scaleCmpt = model.getScaleComponent(channel); const scaleType = scaleCmpt && scaleCmpt.get('type'); diff --git a/src/compile/selection/zoom.ts b/src/compile/selection/zoom.ts index a75a370fc5..a326dd6969 100644 --- a/src/compile/selection/zoom.ts +++ b/src/compile/selection/zoom.ts @@ -82,7 +82,7 @@ function onDelta( const name = selCmpt.name; const channel = proj.channel as ScaleChannel; const boundScales = scalesCompiler.defined(selCmpt); - const signal = signals.filter(s => s.name === proj.signals[boundScales ? 'data' : 'visual'])[0]; + const signal = signals.find(s => s.name === proj.signals[boundScales ? 'data' : 'visual']); const sizeSg = model.getSizeSignalRef(size).signal; const scaleCmpt = model.getScaleComponent(channel); const scaleType = scaleCmpt && scaleCmpt.get('type');