Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F4502975
test_promise.cjs
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
897 B
Referenced Files
None
Subscribers
None
test_promise.cjs
View Options
console.log('Test 1: Promise Constructor');
let p = new Promise((resolve, reject) => {
resolve(42);
});
console.log('p is Promise: ' + (p instanceof Promise));
p.then(v => {
console.log('Resolved with ' + v);
});
console.log('Test 2: Chaining');
let p2 = new Promise(resolve => resolve(10));
p2.then(v => {
return v * 2;
}).then(v => {
console.log('Chained result: ' + v); // Should be 20
});
console.log('Test 3: Catch');
let p3 = new Promise((_, reject) => reject('error'));
p3.catch(e => {
console.log('Caught: ' + e);
});
console.log('Test 4: Static resolve');
Promise.resolve('static').then(v => {
console.log('Static resolve: ' + v);
});
console.log('Test 5: Promise.try');
Promise.try(() => {
return 'try';
}).then(v => {
console.log('Try result: ' + v);
});
console.log('Test 6: Finally');
Promise.resolve('fin').finally(() => {
console.log('Finally called');
});
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, May 3, 9:19 AM (1 d, 12 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
523863
Default Alt Text
test_promise.cjs (897 B)
Attached To
Mode
rANT Ant
Attached
Detach File
Event Timeline
Log In to Comment