Results for “du”
Small, practical examples. Search by task or narrow things down below.
Count the items in a collection
TypeScript: Read the collection’s length instead of hard-coding the loop limit.
TypeScript✓ Tested
Count Unicode code points in a string
TypeScript: String iteration combines surrogate pairs, unlike the UTF-16 length property.
TypeScript✓ Tested
Count words using a Map
Update a keyed counter without losing its value type.
Map✓ Tested
Create a small file at build time
Docker / Compose: Create a small file at build time with a complete introductory Dockerfile.
Docker / Compose✓ Tested
Create independent rows in a matrix
TypeScript: Use a mapping function to create each row instead of sharing one array with fill.
TypeScript✓ Tested
Debounce a button with a stable-time check
Accept an input change only after it stays stable for 30 ms.
debounce✓ Tested
Declare a preferred canonical URL
HTML: A canonical link identifies the preferred public URL for duplicate representations of a document.
HTML✓ Tested
Decode a percent-encoded URL component
TypeScript: decodeURIComponent reverses percent encoding and throws for malformed sequences.
TypeScript✓ Tested
Delegate iteration to another iterable
TypeScript: yield-star forwards items from another iterable while retaining generator composition.
TypeScript✓ Tested
Describe an object with an interface
Require named fields on a reusable object shape.
interface✓ Tested
Detect an invalid Date object
TypeScript: An invalid Date has a NaN time value.
TypeScript✓ Tested
Detect NaN without converting the input
TypeScript: Number.isNaN tests the special numeric value instead of applying string-to-number conversion.
TypeScript✓ Tested