Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

lifecycle.ts

46 lines1.1 KB

1export type Framework = 'react' | 'solid' | 'vue'
2​
3export type MountedApp = {
4 router: unknown
5 unmount: () => void
6}
7​
8export type MountTestApp = (container: HTMLDivElement) => MountedApp
9​
10const frameworkNames = {
11 react: 'React',
12 solid: 'Solid',
13 vue: 'Vue',
14} satisfies Record<Framework, string>
15​
16export function noop() {}
17​
18export function warnClientMemoryDevMode(framework: Framework) {
19 if (process.env.NODE_ENV !== 'production') {
20 console.warn(
21 `memory client benchmark is running without NODE_ENV=production; ${frameworkNames[framework]} dev overhead will dominate results.`,
22 )
23 }
25​
26export function createBenchContainer() {
27 const container = document.createElement('div')
28 document.body.append(container)
29​
30 return container
32​
33export function removeBenchContainer(container: HTMLDivElement | undefined) {
34 container?.remove()
36​
37export function nextAnimationFrame() {
38 return new Promise<void>((resolve) => {
39 requestAnimationFrame(() => resolve())
40 })
42​
43export async function drainMicrotasks() {
44 await Promise.resolve()
45 await Promise.resolve()