module /** */ import { ParsingState } from "../state" ; import { ResultKind } from "../result" ; import { ParjserBase } from "../parser" ; import { Parjser } from "../parjser" ; param length export function stringLen ( length ) { return new class StringLen extends ParjserBase { type = "stringLen" ; expecting = `expecting ${ length } characters` ; _apply ( ps ) { let { position , input } = ps ; if ( input . length < position + length ) { ps . kind = ResultKind . SoftFail ; return ; } ps . position += length ; ps . value = input . substr ( position , length ) ; ps . kind = ResultKind . Ok ; } } ( ) ; }