Selection
An immutable, ordered set of tmux objects read at one instant.
Source and package
- Qualified name
-
Selection - Module
- selection
- Package
- libtmux
- Source
- packages/libtmux/src/selection.ts
-
Description#
A Selection is deliberately not an Array. It is
Iterableand it never changes, so the answer it gave a moment ago is still the answer now — which is what lets a snapshot be reasoned about at all.toArray()is the one crossing to array semantics, and everything Array offers that this does not lives on the other side of it.Two ways to narrow, never overloaded into each other:
where()takes declarative criteria that are data — serializable, inspectable, sendable over a wire — andfilter()takes an ordinary predicate. Reach forwhere()unless the question genuinely needs to run code.
Members12#
- one method The single member, or the single one matching
criteria. - exists method Whether anything matches. Cheaper to read than comparing a count to zero.
- filter method Keep the members
predicateaccepts. - first method The first member, or the first matching
criteria. - oneOrUndefined method The single member, or undefined when there is none.
- where method Keep the members matching declarative criteria.
- [Symbol.iterator] method Iterate in tmux's own order.
- at method The member at
index, or undefined when the index is out of range. - count method How many members match
criteria, or how many there are without it. - length: number property How many members this holds. Unlike
count(), it takes no criteria. - map method Apply
transformto each member, in order. - toArray method A plain array of the members, in order.
Guides#
Pages that discuss Selection.
- Concepts
- Topics