import type { StackContext } from "./api.js" ; import { $n , $ } from "./safe.js" ; param ctx export const ismatch = ( ctx ) => { const stack = ctx [ 0 ] ; const n = stack . length - 2 ; $n ( n , 0 ) ; stack [ n ] = new RegExp ( stack [ n + 1 ] ) . test ( stack [ n ] ) ; stack . length -- ; return ctx ; } ; param ctx export const fromjson = ( ctx ) => { const stack = ctx [ 0 ] ; $ ( stack , 1 ) ; stack . push ( JSON . parse ( stack . pop ( ) ) ) ; return ctx ; } ; param ctx export const tojson = ( ctx ) => { const stack = ctx [ 0 ] ; $ ( stack , 1 ) ; stack . push ( JSON . stringify ( stack . pop ( ) , null , 4 ) ) ; return ctx ; } ;