You all know that to create a new Promise you need to define it this way:
new Promise((resolve, reject) => {
...
resolve(someValue)
})
You are passing a callback that defines the specific behavior of your promise.
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()); |
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"time" | |
) | |
func interval() chan float64 { | |
channel := make(chan float64) |
export class PromiseQueue<T> { | |
readonly concurrency: number; | |
#ongoingPromisesCount: number; | |
#toRun: Array<() => Promise<T>>; | |
constructor({ concurrency = 1 } = {}) { | |
this.concurrency = concurrency; | |
this.#ongoingPromisesCount = 0; | |
this.#toRun = []; | |
} |
type TextMarks = | |
| { type: "bold" } | |
| { type: "italic" } | |
| { type: "code" } | |
| { type: "strike" } | |
| { type: "textStyle"; attrs: Partial<CSSStyleDeclaration> } | |
| { | |
type: "link"; | |
attrs: { | |
href: string; |
export type TaskPriority = "user-blocking" | "user-visible" | "background"; | |
export type SchedulerPostTaskOptions = { | |
// This priority is immutable and overrides the | |
// TaskController's priority. | |
priority?: TaskPriority; | |
delay?: number; | |
signal?: TaskSignal; | |
}; |
import { createLiveState, crdtSchema } from "@/lib/live-state"; | |
export type NotebookJSON = { | |
title: string; | |
description: string; | |
cells: TextCell[]; | |
}; | |
const notebookCRDTSchema = { | |
title: crdtSchema.LiveText(), |
import mapValues from 'lodash/mapValues'; | |
export type Step<Anims> = { | |
[K in keyof Anims]: { value: number; progress: number }; | |
}; | |
export type Values<Anims> = { [K in keyof Anims]: number }; | |
export interface SpringOptions { | |
/** |
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 = () => { |
/* ----------------------------------------- * | |
Lazy List Implementation | |
* ----------------------------------------- */ | |
// Haskell-like infinite List, implemented with es6 generators | |
// Lazyness lets you do crazy stuff like | |
List.range(0, Infinity) | |
.drop(1000) | |
.map(n => -n) |