import { memoize1 } from "@thi.ng/memoize/memoize1" ; import type { Stringer } from "./api.js" ; example param chars export const trim = memoize1 < string , Stringer < string > > ( ( chars = " \t\n\r" ) => { chars = `(${ chars . split ( "" ) . map ( ( x ) => `\\${ x }` ) . join ( "|" ) })` ; const re = new RegExp ( `(^${ chars }+)|(${ chars }+$)` , "g" ) ; return ( x ) => x . replace ( re , "" ) ; } ) ;