# selection.Selection.oneOrUndefined

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

```
selection.Selection.oneOrUndefined(criteria: : WhereOf<Model>) -> Model | undefined
```

The single member, or undefined when there is none.

`one` without the empty case: several still throws, because that says the
criteria were wrong rather than that the answer is absent.

## Example

```ts
snapshot.sessions.oneOrUndefined({ name: "work" })?.id;
```
