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
type ThemeColor = string; | |
type Theme = { id: number, color: ThemeColor } | |
type State = { themes?: [Theme] } | |
type ExtractFirstArgument<T> = | |
T extends (T1: infer T1) => infer R | |
? (T extends (t1: infer T1, t2: infer T2, t3: infer T3) => infer R | |
? Extract<T2, undefined> extends never | |
? () => R | |
: (Extract<T3, undefined> extends never |
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
const defaultMiddleware = next => (...args) => next(...args) | |
const compose = (() => { | |
const base = (f, g) => (...args) => f(g(...args)); | |
return (...funcs) => funcs.reduce(base) | |
})(); | |
const applyMiddlewares = (middlewares, func) => compose(...middlewares)(func); | |
const recursive = (func, middlewares = [defaultMiddleware]) => { |
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
{ | |
const flatten = array => [].concat(...array) | |
const uniq = array => array.reduce((filtered, element) => ( | |
filtered.includes(element) | |
? filtered | |
: [...filtered, element] | |
), []) | |
const normalize = array => uniq(flatten(array)).sort() |
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
type TypesDefinition = | |
| StringConstructor | |
| BooleanConstructor | |
| DateConstructor | |
type FieldDefinition = { | |
type: TypesDefinition, | |
required?: boolean, | |
default?: boolean, | |
} |