Last active
December 31, 2019 14:29
-
-
Save WimJongeneel/f8a637e894a6ca7bdf3ea4527d45f0e9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fromArray = <T extends object>(a: Array<T>): IQueryable<T> => { | |
const exprs: Expr[] = [] | |
const value = [...a] | |
return { | |
where(predicate) { | |
exprs.push(predicate(builder()).GetExpr()) | |
return this | |
}, | |
toArray() { | |
const result = exprs.reduce((res, e) => res.filter(i => runExpr(e, i)), value) | |
return Promise.resolve(result) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment