# selection.Selection.filter

- **Module:** selection
- **Package:** libtmux
- **Language:** TypeScript
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-ts/blob/073b9d7dedad900bff6f5ec0ea47794e40225870/packages/libtmux/src/selection.ts#L483
- **Page:** https://libtmux.org/en/ts/latest/reference/selection-selection-filter/

```
filter<Narrowed extends Model>(
  predicate: (
    value: Model,
    index: number,
    values: readonly Model[],
  ) => value is Narrowed,
  thisArg?: unknown,
): Selection<Narrowed>

filter(
  predicate: (
    value: Model,
    index: number,
    values: readonly Model[],
  ) => unknown,
  thisArg?: unknown,
): Selection<Model>
```

Keep the members `predicate` accepts.

For a question that has to run code. When the question can be expressed as
criteria, [`where`](/en/ts/latest/reference/selection-selection-where/) says the same thing as data — which can be logged, sent
to another process, or stored.

## Examples

```ts
snapshot.panes.filter((entry) => entry.currentCommand?.startsWith("v") === true);
```

## Type parameters

- `Narrowed` (bound `Model`) (for `filter(predicate, thisArg) [overload 1]`)
- [`Model`](/en/ts/latest/reference/selection-selection/#selection.Selection.type-parameter.Model), declared by [`Selection<Model>`](/en/ts/latest/reference/selection-selection/)

## Parameters

- `predicate` (`(value: Model, index: number, values: readonly Model[]) => value is Narrowed`) (for `filter(predicate, thisArg) [overload 1]`)
- `thisArg?` (`unknown`)
- `predicate` (`(value: Model, index: number, values: readonly Model[]) => unknown`) (for `filter(predicate, thisArg) [overload 2]`)

## Guides

Pages that discuss `filter`.

- [Filtering and queries](/en/ts/latest/concepts/queries/)
