occulto/src/utils/base.ts
2022-10-14 17:32:05 +02:00

28 lines
468 B
TypeScript

/**
* @internal
*/
export const isBrowser = typeof window !== 'undefined'
/**
* @internal
*/
export type PromiseOrValue<T> = T | Promise<T>
export type TypedArray =
| Int8Array
| Uint8Array
| Uint8ClampedArray
| Int16Array
| Uint16Array
| Int32Array
| Uint32Array
| BigInt64Array
| BigUint64Array
/**
* @internal
*/
export function split<T>({ node, browser }: { node: () => T; browser: () => T }) {
return isBrowser ? browser() : node()
}