Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F7539162
promise_advanced.cjs
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
promise_advanced.cjs
View Options
// Test Promise.all with multiple concurrent fetches
async function test_promise_all() {
console.log('Testing Promise.all with concurrent fetches...');
const promises = [fetch('https://httpbin.org/delay/1'), fetch('https://httpbin.org/get'), fetch('https://httpbin.org/user-agent')];
const responses = await Promise.all(promises);
console.log('All requests completed!');
console.log('Response count:', responses.length);
}
// Test Promise.race
async function test_promise_race() {
console.log('Testing Promise.race...');
const promises = [fetch('https://httpbin.org/delay/2'), fetch('https://httpbin.org/get'), fetch('https://httpbin.org/delay/3')];
const winner = await Promise.race(promises);
console.log('Race winner status:', winner.status);
}
// Test with timers and promises
async function test_timer_integration() {
console.log('Testing timer integration with await...');
const start = Date.now();
await new Promise(resolve => setTimeout(resolve, 100));
const elapsed = Date.now() - start;
console.log('Timer completed in', elapsed, 'ms');
}
// Run tests
void test_promise_all();
console.log('---');
void test_promise_race();
console.log('---');
void test_timer_integration();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jun 17, 1:15 PM (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
518939
Default Alt Text
promise_advanced.cjs (1 KB)
Attached To
Mode
rANT Ant
Attached
Detach File
Event Timeline
Log In to Comment