Basic usage

Sometimes you have an enum or union type, possibly a status, that has inherint order and you need to work with values as though they’re ordered. The series function takes many values and returns an object that let’s you do ordered logic on those values.

import { series } from 'radash'

type Weekday = 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday';

const weekdays = series<Weekday>(

weekdays.min('tuesday', 'thursday') // => 'tuesday'
weekdays.max('wednesday', 'monday') // => 'wednesday''wednesday') // => 'thursday'
weekdays.previous('tuesday') // => 'monday'
weekdays.first() // => 'monday'
weekdays.last() // => 'friday''friday') // => null'friday', weekdays.first()) // => 'monday'


This _.series function is 100% covered by tests. See them and contribute at GitHub.


See the source for _.series on GitHub.