Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib/BufferedDuplex.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Duplex, Transform } from 'readable-stream'
import { Buffer } from 'buffer'
import { IClientOptions } from './client'

/**
Expand Down
6 changes: 4 additions & 2 deletions src/lib/get-timer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import isBrowser, { isWebWorker } from './is-browser'
import isBrowser, { isWebWorker, isReactNativeBrowser } from './is-browser'
import { clearTimeout as clearT, setTimeout as setT } from 'worker-timers'
import type { TimerVariant } from './shared'

Expand Down Expand Up @@ -30,7 +30,9 @@ const getTimer = (variant: TimerVariant): Timer => {
}
case 'auto':
default: {
return isBrowser && !isWebWorker ? workerTimer : nativeTimer
return isBrowser && !isWebWorker && !isReactNativeBrowser
? workerTimer
: nativeTimer
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/lib/is-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ const isBrowser =

export const isWebWorker = isWebWorkerEnv()

export const isReactNativeBrowser = isReactNativeEnv()

export default isBrowser
11 changes: 6 additions & 5 deletions src/lib/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ export function applyMixin(
}
}
}
export const nextTick = process
? process.nextTick
: (callback: () => void) => {
setTimeout(callback, 0)
}
export const nextTick =
typeof process?.nextTick === 'function'
? process.nextTick
: (callback: () => void) => {
setTimeout(callback, 0)
}