FIND YOUR NEXT FEW LINES
The snippet library.
Small, practical examples. Search by task or narrow things down below.
125 snippets foundClear filters
Use the first fulfilled promise result
TypeScript: Promise.any ignores individual rejections until one input fulfills.
TypeScript✓ Tested
Validate a finite numeric value without coercion
TypeScript: Number.isFinite rejects numeric strings as well as NaN and infinity.
TypeScript✓ Tested
Validate a whole ASCII identifier
TypeScript: Use an anchored expression without the multiline flag and reject a trailing line break explicitly.
TypeScript✓ Tested
Validate an unknown value with a type guard
Check a field before treating unknown data as a typed object.
unknown✓ Tested
Visit every item in a collection
TypeScript: Print each element in the collection’s original order.
TypeScript✓ Tested