• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { p, foo, pFuncCall, arrowFunc, pArrowCall } from "./no_await_js_promise_export";
17
18async function awaitPromise() {
19  return await p;
20}
21
22async function awaitFunctionCall() {
23  return await foo();
24}
25
26async function awaitFuncResult() {
27  return await pFuncCall;
28}
29
30async function awaitArrowCall() {
31  return await arrowFunc();
32}
33
34async function awaitArrowResult() {
35  return await pArrowCall;
36}
37
38class ExampleClass {
39  async classMethod() {
40    return await p;
41  }
42
43  handler = async () => {
44    return await pFuncCall;
45  };
46}
47
48const exampleObj = {
49  async objMethod() {
50    return await pArrowCall;
51  },
52
53  arrowHandler: async () => {
54    return await foo();
55  }
56};
57
58(async function() {
59  console.log("IIFE result:", await p);
60})();
61
62(async () => {
63  console.log("IIFE Arrow result:", await arrowFunc());
64})();