import type { IReset } from "@thi.ng/api" ; import { AGen } from "./agen.js" ; export const alt = ( n = 1 ) => new Alt ( n , - n ) ; export const altT = < T > ( a , b ) => new Alt ( a , b ) ; export const altB = ( x = true ) => new Alt ( x , ! x ) ; export class Alt < T > extends AGen < T > implements IReset { protected _flip = true ; constructor ( protected _a , protected _b ) { super ( _b ) ; } reset ( ) { this . _flip = true ; return this ; } next ( ) { return ( this . _val = ( this . _flip = ! this . _flip ) ? this . _b : this . _a ) ; } }