import curryN from './utils/curry_n.ts';import type { PH } from './utils/types.ts';
type Trim_2 = (t: string) => string;
type Trim_1 = (str: string) => string;
type Trim = & ((str: string) => Trim_2) & ((str: PH, t: string) => Trim_1) & ((str: string, t: string) => string);
function escapeRegEx(str: string) { return str.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');}
function _trim(str: string, t: string) { t = escapeRegEx(t); const regEx = new RegExp(`^(${t})+|(${t})+$`, 'g'); return t ? str.replace(regEx, '') : str.trim();}
export const trim: Trim = curryN(2, _trim);