-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reword some docstrings with added examples or clearer formulations. Add many functional style utils regarding promises and errors.
- Loading branch information
Showing
4 changed files
with
282 additions
and
120 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { curry } from "lodash/fp"; | ||
|
||
import { GraphQLYogaError } from "Util/error"; | ||
import { throv } from "Util/misc"; | ||
|
||
interface Assert { | ||
<T, C extends T>( | ||
condition: ((_: T) => _ is C) | ((_: T) => boolean), | ||
message: string, | ||
code: string | ||
): <U extends T>(value: U) => U & C; | ||
} | ||
export const assert: Assert = curry( | ||
(cond: (_: unknown) => boolean, msg: string, code: string, val: unknown) => | ||
cond(val) | ||
? val | ||
: throv(new GraphQLYogaError(msg, { extensions: { code } })) | ||
); |
This file contains 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
Oops, something went wrong.