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 16let GeneratedImportVar_1 = ESValue.load('./no_await_js_promise_export'); 17let p = GeneratedImportVar_1.getProperty('p'); 18let foo = GeneratedImportVar_1.getProperty('foo'); 19let pFuncCall = GeneratedImportVar_1.getProperty('pFuncCall'); 20let arrowFunc = GeneratedImportVar_1.getProperty('arrowFunc'); 21let pArrowCall = GeneratedImportVar_1.getProperty('pArrowCall'); 22 23 24async function awaitPromise() { 25 return await p.toPromise(); 26} 27 28async function awaitFunctionCall() { 29 return await foo.invoke().toPromise(); 30} 31 32async function awaitFuncResult() { 33 return await pFuncCall.toPromise(); 34} 35 36async function awaitArrowCall() { 37 return await arrowFunc(); 38} 39 40async function awaitArrowResult() { 41 return await pArrowCall.toPromise(); 42} 43 44class ExampleClass { 45 async classMethod() { 46 return await p.toPromise(); 47 } 48 49 handler = async () => { 50 return await pFuncCall.toPromise(); 51 }; 52} 53 54const exampleObj = { 55 async objMethod() { 56 return await pArrowCall.toPromise(); 57 }, 58 59 arrowHandler: async () => { 60 return await foo.invoke().toPromise(); 61 } 62}; 63 64(async () => { 65 console.log("IIFE result:", await p); 66})(); 67 68(async () => { 69 console.log("IIFE Arrow result:", await arrowFunc()); 70})();