aboutsummaryrefslogtreecommitdiff
path: root/src/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/index.ts')
-rw-r--r--src/index.ts5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/index.ts b/src/index.ts
index 5bcb4f9..1a52c95 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -3,7 +3,7 @@ import { flow, pipe } from 'fp-ts/function'
import { fst } from 'fp-ts/Tuple'
import * as ev from './eval'
import { parser } from './parser'
-import { ListExpr } from './types'
+import { index, ListExpr } from './types'
const toSourceString = (r: string | RegExp): string =>
typeof r === 'string' ? r : r.source
@@ -19,3 +19,6 @@ export const liexp: (r: string | RegExp) => ListExpr = flow(
export const matchAll = <T>(exp: string | RegExp, list: T[]) =>
pipe(exp, liexp, lxp => ev.matchAll(lxp, list))
+
+export const replaceAll = <T>(exp: string | RegExp, replacer: (v: T, m: ev.MatchGroupIndexed<T>, i: index) => T[], list: T[]) =>
+ pipe(exp, liexp, lxp => ev.replaceAll(lxp, replacer, list))