Hyperlinkv0.8.0-beta.28

Ordering

Ordering.Reducerconsteffect/Ordering.ts:170
Reducer_.Reducer<Ordering>

Reducer for combining Orderings.

When to use

Use to combine multiple comparison results in priority order, such as checking secondary criteria only when earlier criteria compare as equal.

Details

If any of the Orderings is non-zero, the result is the first non-zero Ordering. If all the Orderings are zero, the result is zero.

Gotchas

combineAll stops consuming the iterable as soon as it finds a non-zero Ordering.

ordering
Source effect/Ordering.ts:17013 lines
export const Reducer: Reducer_.Reducer<Ordering> = Reducer_.make<Ordering>(
  (self, that) => self !== 0 ? self : that,
  0,
  (collection) => {
    let ordering: Ordering = 0
    for (ordering of collection) {
      if (ordering !== 0) {
        return ordering
      }
    }
    return ordering
  }
)