useEffect(() => {
})
<>
<Child log1 />
{console.log("log3")}
<Child log2 />
>
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
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"time" | |
) | |
func interval() chan float64 { | |
channel := make(chan float64) |
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 TransactionCreator = (editor: EditorAPI) => Transaction; | |
const rebaseSteps = (stepsToRebase: Step[], committedSteps: Step[]): Step[] => { | |
if (!committedSteps.length) { | |
return stepsToRebase; | |
} | |
const committedStepsMaps = committedSteps.map((s) => s.getMap()); | |
const stepsToRebaseMaps = stepsToRebase.map((s) => s.getMap()); |
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 TextMarks = | |
| { type: "bold" } | |
| { type: "italic" } | |
| { type: "code" } | |
| { type: "strike" } | |
| { type: "textStyle"; attrs: Partial<CSSStyleDeclaration> } | |
| { | |
type: "link"; | |
attrs: { | |
href: string; |
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
import { createLiveState, crdtSchema } from "@/lib/live-state"; | |
export type NotebookJSON = { | |
title: string; | |
description: string; | |
cells: TextCell[]; | |
}; | |
const notebookCRDTSchema = { | |
title: crdtSchema.LiveText(), |
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 RafState<Args> = | |
| { type: 'waiting'; latestArgs: Args; rafId: number } | |
| { type: 'idle' }; | |
export const animationFrameThrottle = <Args extends any[]>( | |
callback: (...args: Args) => unknown, | |
): ((...args: Args) => void) & { cancel: () => void } => { | |
let state: RafState<Args> = { type: 'idle' }; | |
const cancel = () => { |
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
export function usePrevious<T>(value: T): T | undefined { | |
const ref = React.useRef<T>(); | |
React.useEffect(() => { | |
ref.current = value; | |
}); | |
return ref.current; | |
} |
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
import { arg0, Call, Constant, Eval, Fn, Objects, Tuples } from "../src/index"; | |
type Ok<A> = { tag: "Ok"; value: A }; | |
type Err<B> = { tag: "Err"; value: B }; | |
type Result<A, B> = Ok<A> | Err<B>; | |
type ParseError<expected = unknown, encountered = unknown> = { | |
expected: expected; |
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 MergeParameters3<T extends readonly UnknownFunction[]> = H.Pipe< | |
T, | |
[ | |
H.Let<"parametersList", H.Tuples.Map<H.Functions.Parameters>>, | |
H.Let< | |
"longestLength", | |
H.ComposeLeft< | |
[ | |
H.Get<"parametersList">, | |
H.Tuples.Map<H.Tuples.Length>, |
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
// a conditional type is just type-level code branching | |
// A extends B means "A is assignable to B" | |
type Test1 = "hello" extends string ? true : false; | |
// ^? | |
type Test2 = 2 extends string ? true : false; | |
// ^? |
NewerOlder