import type { Fn2 } from "@thi.ng/api" ; import { NO_OP } from "@thi.ng/api/api" ; import { illegalState } from "@thi.ng/errors/illegal-state" ; import type { Stack } from "./api.js" ; export let $ ; export let $n ; export const safeMode = ( state ) => { if ( state ) { $n = ( m , n ) => m < n && illegalState ( `stack underflow` ) ; $ = ( stack , n ) => $n ( stack . length , n ) ; } else { $ = $n = NO_OP ; } } ; safeMode ( true ) ;