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
/** | |
* Builds a path from a template and replaces the params | |
* | |
* @function createPath | |
* @param path The configured path (e.g. /foo/:bar) | |
* @param params The param values you want to replace it with (e.g. \{bar: 'baz'\}) | |
* @param search Any query string values that you want to add | |
* @category routing | |
*/ | |
export const createPath = ( |
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
// https://medium.com/@reidev275/creating-a-type-safe-dsl-for-filtering-in-typescript-53fe68a7942e | |
export type Filter<A> = | |
| { kind: 'Equals'; field: keyof A; val: A[keyof A] } | |
| { kind: 'Greater'; field: keyof A; val: A[keyof A] } | |
| { kind: 'Less'; field: keyof A; val: A[keyof A] } | |
| { kind: 'And'; a: Filter<A>; b: Filter<A> } | |
| { kind: 'Or'; a: Filter<A>; b: Filter<A> } | |
export const equals = <A, K extends keyof A>( | |
field: K, |
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
$ cat ~/.gitconfig | |
[user] | |
useConfigOnly = true |
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
export const parseJSON = <T = {}>(json: string) => { | |
return new Promise<T>((resolve, reject) => { | |
try { | |
resolve(JSON.parse(json)); | |
} catch (error) { | |
reject(error); | |
} | |
}); | |
}; |
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
{ | |
"printWidth": 100, | |
"tabWidth": 2, | |
"useTabs": false, | |
"semi": false, | |
"singleQuote": true, | |
"trailingComma": "es5", | |
"bracketSpacing": true, | |
"jsxBracketSameLine": false, | |
"jsxSingleQuote": true, |