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
| class Test { | |
| constructor(){/*...*/} | |
| set(data){ | |
| this.#data = data | |
| } | |
| get(){ | |
| return this.#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
| import { Store, ActionCreator } from '.' | |
| import { identity } from './shared' | |
| function declareEffect(cb) {} | |
| type Step = { | |
| type: 'next' | 'catch' | string | |
| reducer: (promise: Promise<any>) => Promise<any> | |
| } | |
| class Flow { |
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 M = [any, any]; | |
| type Delete<k, m extends M> = k extends m[0] | |
| ? m extends [k, any] | |
| ? never | |
| : m | |
| : m[0] extends k | |
| ? [unknown, unknown] | |
| : m; | |
| type Add<k, v, m extends M> = [k, v] | Delete<k, m>; | |
| type Get<k, m extends M> = k extends m[0] |
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
| { | |
| "workbench.colorTheme": "FlatUI Dark", | |
| "editor.fontFamily": "Iosevka", | |
| "editor.fontLigatures": true, | |
| "editor.fontSize": 18, | |
| "editor.tokenColorCustomizations": { | |
| "[FlatUI Dark]": { | |
| "textMateRules": [ | |
| { | |
| "scope": ["string"], |
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
| declare const IS_ACTION_FETCH: unique symbol | |
| /** | |
| * Fetch fabric with statuses actions | |
| * @param {(payload: Payload) => Promise<Result>} fetcher | |
| * @param {{ | |
| * onDone?: (result: Result, store: Store) => void | |
| * onFail?: (error: unknown, store: Store) => void | |
| * }} hooks | |
| * @returns {{ |
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
| // // BEFORE | |
| // export const doSome = declareAction( | |
| // (payload, store) => some() | |
| // ) | |
| // export const myAtom = declareAtom(initState, on => [ | |
| // on(doSome, (state, payload) => state + payload), | |
| // ]) | |
| // // NOW |
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 * as t from "types"; | |
| // STATIC: any | |
| // RUNTIME: string | |
| const someInput /*: any*/ = "input"; | |
| // runtime contract for value | |
| const SomeUnion = t.OR(t.String, t.Number); |
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 cursorManager = new CursorManager({}); | |
| const someCursor = cursorManager.view(["root", "child"]); | |
| someCursor.write(true); | |
| cursorManager.read(console.log); | |
| // { root: { child: 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
| type Key = /*unique*/ string | |
| type ActionType = string | |
| type StateCtx = Record<Key, unknown> | |
| type Subscriber<T> = (value: T) => unknown | |
| type ObserverType<Target> = Target extends | |
| | Observer<infer T> | |
| | Computed<infer T, any[]> | |
| ? T | |
| : never |