diff options
| author | Akshay Nair <phenax5@gmail.com> | 2022-01-14 18:36:34 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2022-01-14 18:36:34 +0530 |
| commit | de5d3de99afae3cb7f1dc56fe8781394f8614a50 (patch) | |
| tree | c60099423b221cede73e38aad4dae89ca407bb5a /src/index.ts | |
| parent | 70578d77d284b93f49b2918318c8a972521efb46 (diff) | |
| download | elxr-de5d3de99afae3cb7f1dc56fe8781394f8614a50.tar.gz elxr-de5d3de99afae3cb7f1dc56fe8781394f8614a50.zip | |
refactor: removes filter function
Diffstat (limited to 'src/index.ts')
| -rw-r--r-- | src/index.ts | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/src/index.ts b/src/index.ts index db6630c..6c19fd3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,29 +1,21 @@ import { getOrElseW, map } from 'fp-ts/lib/Either' import { flow, pipe } from 'fp-ts/lib/function' -import {fst} from 'fp-ts/lib/Tuple' +import { fst } from 'fp-ts/lib/Tuple' import * as ev from './eval' import { parser } from './parser' -import {ListExpr} from './types' +import { ListExpr } from './types' -const toSourceString = (r: string | RegExp): string => typeof r === 'string' ? r : r.source +const toSourceString = (r: string | RegExp): string => + typeof r === 'string' ? r : r.source export const liexp: (r: string | RegExp) => ListExpr = flow( toSourceString, parser, map(fst), - getOrElseW(([e, _]) => { throw new Error(e) }) + getOrElseW(([e, _]) => { + throw new Error(e) + }), ) export const matchAll = <T>(exp: string | RegExp, list: T[]) => - pipe( - exp, - liexp, - lxp => ev.matchAll(lxp, list), - ) - -export const filter = <T>(exp: string | RegExp, list: T[]): T[] => - pipe( - exp, - liexp, - lxp => ev.find(lxp, list), - ) + pipe(exp, liexp, lxp => ev.matchAll(lxp, list)) |
