summaryrefslogtreecommitdiff
path: root/src/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/index.ts')
-rw-r--r--src/index.ts17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/index.ts b/src/index.ts
index 82eefe8..691d676 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,2 +1,17 @@
+import { fold, map } from 'fp-ts/lib/Either'
+import { identity, pipe } from 'fp-ts/lib/function'
+import { find } from './eval'
+import { parser } from './parser'
-export * from './parser';
+const toSourceString = (r: string | RegExp): string => typeof r === 'string' ? r : r.source
+
+export const filter = <T>(listExp: string | RegExp, list: T[]): T[] =>
+ pipe(
+ listExp,
+ toSourceString,
+ parser,
+ map(([lxp, _]) => find(lxp, list)),
+ fold(([err, _]) => {
+ throw new Error(err)
+ }, identity),
+ )