• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / supabase-js / 6234159930

19 Sep 2023 10:10AM UTC coverage: 65.385%. First build
6234159930

Pull #854

github

GitHub
Merge ccf4cab47 into 8cf2b9688
Pull Request #854:

47 of 92 branches covered (51.09%)

Branch coverage included in aggregate %.

6 of 9 new or added lines in 1 file covered. (66.67%)

89 of 116 relevant lines covered (76.72%)

4.35 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/lib/helpers.ts
1
// helpers.ts
2
import { SupabaseClientOptions } from './types'
3

4
export function uuid() {
4✔
5
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
1✔
6
    var r = (Math.random() * 16) | 0,
31✔
7
      v = c == 'x' ? r : (r & 0x3) | 0x8
31✔
8
    return v.toString(16)
31✔
9
  })
10
}
11

12
export function stripTrailingSlash(url: string): string {
4✔
13
  return url.replace(/\/$/, '')
9✔
14
}
15

16
export const isBrowser = () => typeof window !== 'undefined'
4✔
17

18
export function applySettingDefaults<
4✔
19
  Database = any,
20
  SchemaName extends string & keyof Database = 'public' extends keyof Database
21
    ? 'public'
22
    : string & keyof Database
23
>(
24
  options: SupabaseClientOptions<SchemaName>,
25
  defaults: SupabaseClientOptions<any>
26
): SupabaseClientOptions<SchemaName> {
27
  const {
28
    db: dbOptions,
29
    auth: authOptions,
30
    realtime: realtimeOptions,
31
    global: globalOptions,
32
  } = options
8✔
33
  const {
34
    db: DEFAULT_DB_OPTIONS,
35
    auth: DEFAULT_AUTH_OPTIONS,
36
    realtime: DEFAULT_REALTIME_OPTIONS,
37
    global: DEFAULT_GLOBAL_OPTIONS,
38
  } = defaults
8✔
39

40
  return {
8✔
41
    db: {
42
      ...DEFAULT_DB_OPTIONS,
43
      ...dbOptions,
44
    },
45
    auth: {
46
      ...DEFAULT_AUTH_OPTIONS,
47
      ...authOptions,
48
    },
49
    realtime: {
50
      ...DEFAULT_REALTIME_OPTIONS,
51
      ...realtimeOptions,
52
    },
53
    global: {
54
      ...DEFAULT_GLOBAL_OPTIONS,
55
      ...globalOptions,
56
    },
57
  }
58
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc