UNPKG

parjs

Version:

A parser-combinator library for JavaScript.

20 lines (19 loc) 917 B
/** @module parjs/combinators */ /** */ import { ParjsCombinator, UserState } from "../../index"; /** * A user state object or a projection to the external user state. */ export declare type UserStateOrProjection = UserState | ((externalState: UserState) => UserState); /** * When the source parser is applied, the user state will be switched for a * different object. After it has finished, the previous user state will be * restored. This effectively isolates the source parser's user state. * * If the given paramter is a function, it will be called on the pre-existing user * state to determine the new user state. If it's a non-fuction object, it will * be used as the user state instead. * * @param innerStateOrCtor The new internal user state or a projection on the * existing user state. */ export declare function replaceState<T>(innerStateOrCtor: UserStateOrProjection): ParjsCombinator<T, T>;