-
Notifications
You must be signed in to change notification settings - Fork 112
/
Copy pathutils.ts
21 lines (15 loc) · 880 Bytes
/
utils.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import type { ModuleConfiguration } from './types'
export const boolToText = (value: boolean): 'enabled' | 'disabled' => value ? 'enabled' : 'disabled'
export const envToBool = (env: string | undefined): boolean => Boolean(env && env.toLowerCase() !== 'false' && env !== '0')
export const canInitialize = (options: ModuleConfiguration): boolean => Boolean(options.initialize && options.dsn)
export const clientSentryEnabled = (options: ModuleConfiguration): boolean => !options.disabled && !options.disableClientSide
export const serverSentryEnabled = (options: ModuleConfiguration): boolean => !options.disabled && !options.disableServerSide
export function callOnce (fn: (...args: any[]) => any): (...args: any[]) => any {
let called = false
return function callOnceWrapper (...subargs) {
if (!called) {
called = true
return fn(...subargs)
}
}
}