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

realm / realm-js / 5354418719

23 Jun 2023 08:36AM UTC coverage: 85.663%. Remained the same
5354418719

push

github

kraenhansen
An attempt to fix async tests

845 of 1050 branches covered (80.48%)

Branch coverage included in aggregate %.

2244 of 2556 relevant lines covered (87.79%)

755.49 hits per line

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

42.86
/packages/realm/src/safeGlobalThis.ts
1
////////////////////////////////////////////////////////////////////////////
2
//
3
// Copyright 2023 Realm Inc.
4
//
5
// Licensed under the Apache License, Version 2.0 (the "License");
6
// you may not use this file except in compliance with the License.
7
// You may obtain a copy of the License at
8
//
9
// http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing, software
12
// distributed under the License is distributed on an "AS IS" BASIS,
13
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
// See the License for the specific language governing permissions and
15
// limitations under the License.
16
//
17
////////////////////////////////////////////////////////////////////////////
18

19
// Exports a globalThis which is polyfilled for iOS 11/12
20
// From https://github.com/zloirock/core-js/blob/v3.27.2/packages/core-js/internals/global.js
21

22
// eslint-disable-next-line @typescript-eslint/no-explicit-any
23
const check = function (it: any) {
1✔
24
  return it && it.Math === Math && it;
1✔
25
};
26

27
/** @internal */
28
// eslint-disable-next-line no-restricted-globals
29
export const safeGlobalThis: typeof globalThis & Record<string, unknown> =
30
  // eslint-disable-next-line no-restricted-globals
31
  check(typeof globalThis === "object" && globalThis) ||
1!
32
  // @ts-expect-error We're relying on an identifier that might not be there
33
  check(typeof window === "object" && window) ||
×
34
  // eslint-disable-next-line no-restricted-globals -- safe
35
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
36
  // @ts-ignore allow `self`
37
  check(typeof self === "object" && self) ||
×
38
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
39
  // @ts-ignore allow `global`
40
  check(typeof global === "object" && global) ||
×
41
  // eslint-disable-next-line no-new-func -- fallback
42
  (function () {
43
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
44
    // @ts-ignore allow `this`
45
    return this;
×
46
  })() ||
47
  Function("return this")();
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