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
| type FnMapperR<T> = { | |
| [K in keyof T]: (...args: any[]) => T[K] | |
| } | |
| type FnMapper2<T, U, R> = { | |
| [K in keyof U]: (t: T, u: U[K]) => R | |
| } | |
| declare function module <S, G, A, M> (module: { | |
| namespaced?: boolean, |
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 ({ shouldRecord, invertAction, isUndo, isRedo }) => { | |
| const history = [] | |
| return store => next => action => { | |
| if (isUndo(action)) { | |
| const invert = invertAction(lastUndoable(history)) | |
| history.push(invert) | |
| next(invert) | |
| return | |
| } |
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
| el.addEventListener('mousemove', event => { | |
| const rect = event.currentTarget.getBoundingClientRect() | |
| const pos = { | |
| left: event.clientX - rect.left, | |
| top: event.clientY - rect.top | |
| } | |
| }) |
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 function traverse<T, U>(obj: Dictionary<T>, f: (t: T) => Array<U>) : Array<Dictionary<U>> { | |
| return sequence( | |
| mapValues(obj, t => { | |
| return f(t) | |
| }) | |
| ) | |
| } | |
| export function sequence<T>(obj: Dictionary<Array<T>>) : Array<Dictionary<T>> { | |
| function loop<T>(acc: Array<Dictionary<T>>, obj: Dictionary<Array<T>>) : Array<Dictionary<T>> { |
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
| import { | |
| INIT_SOME_DATA, | |
| ADD_SOME_DATA, | |
| MOVE_SOME_DATA, | |
| REMOVE_SOME_DATA, | |
| UPDATE_SOME_DATA | |
| } from '../mutation_types' | |
| import { ISomeData } from '../model/some_data' |
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
| // use shorter name in local | |
| const ADD = `ADD_TOAST_MESSAGE` | |
| const REMOVE = `REMOVE_TOAST_MESSAGE` | |
| // export as longer name with suffix | |
| export { | |
| ADD as ADD_TOAST_MESSAGE, | |
| REMOVE as REMOVE_TOAST_MESSAGE | |
| } |
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
| type Subscriber<T> = (val: T) => void | |
| type Unsubscriber = () => void | |
| export default class Observable<T> { | |
| private subscribers: Subscriber<T>[] = [] | |
| private unsubscriber: Unsubscriber | |
| private _value: T | |
| constructor(source?: (cb: Subscriber<T>) => Unsubscriber) { | |
| if (source) { |
NewerOlder