sync-iterable-with-thenable-async-mapped-awaits-once.js (693B)
1 // |reftest| async 2 // Copyright (C) 2023 Igalia, S.L. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 5 /*--- 6 esid: sec-array.fromasync 7 description: > 8 Sync-iterable input with thenables awaits each input once with async mapping callback. 9 includes: [asyncHelpers.js] 10 flags: [async] 11 features: [Array.fromAsync] 12 ---*/ 13 14 asyncTest(async function () { 15 const expectedValue = {}; 16 let awaitCounter = 0; 17 const inputThenable = { 18 then (resolve, reject) { 19 awaitCounter++; 20 resolve(expectedValue); 21 }, 22 }; 23 const input = [ inputThenable ].values(); 24 await Array.fromAsync(input, async v => v); 25 assert.sameValue(awaitCounter, 1); 26 });