import type { ParseState , IReader } from "../api.js" ; class ArrayReader < T > implements IReader < T > { constructor ( protected _src ) { } read ( state ) { return this . _src [ state . p ] ; } next ( state ) { if ( state . done ) return ; state . last = this . _src [ state . p ] ; state . done = ++ state . p >= this . _src . length ; } isDone ( state ) { return ( state . done = state . p >= this . _src . length ) ; } format ( state ) { return `offset ${ state . p }` ; } } export const defArrayReader = < T > ( input ) => new ArrayReader ( input ) ;