Results for “Iteration & sequences”
Small, practical examples. Search by task or narrow things down below.
Recover from an expected promise rejection
TypeScript: Return a fallback from catch so later handlers receive an ordinary resolved value.
TypeScript✓ Tested
Run cleanup after a promise settles
JavaScript: finally runs after success or failure and normally preserves the original outcome.
JavaScript✓ Tested
Run cleanup after a promise settles
TypeScript: finally runs after success or failure and normally preserves the original outcome.
TypeScript✓ Tested
Run dependent async steps in order
JavaScript: Await one result before using it as the input of the next calculation.
JavaScript✓ Tested
Run dependent async steps in order
TypeScript: Await one result before using it as the input of the next calculation.
TypeScript✓ Tested
Transform a resolved promise result
JavaScript: A then handler returns the value passed to the next promise in the chain.
JavaScript✓ Tested
Transform a resolved promise result
TypeScript: A then handler returns the value passed to the next promise in the chain.
TypeScript✓ Tested
Use the first fulfilled promise result
JavaScript: Promise.any ignores individual rejections until one input fulfills.
JavaScript✓ Tested
Use the first fulfilled promise result
TypeScript: Promise.any ignores individual rejections until one input fulfills.
TypeScript✓ Tested
Count set bits in an unsigned integer
C: Clearing the lowest set bit on each iteration counts only one iteration per set bit.
C✓ Tested
Count Unicode code points in a string
JavaScript: String iteration combines surrogate pairs, unlike the UTF-16 length property.
JavaScript✓ Tested
Count Unicode code points in a string
TypeScript: String iteration combines surrogate pairs, unlike the UTF-16 length property.
TypeScript✓ Tested