Results for “Types & reliable control flow”
Small, practical examples. Search by task or narrow things down below.
Create a table and insert its first row
SQLite: Define column types and a primary key, then insert one row using an explicit column list.
SQLite✓ Tested
Create an archive from an explicit file list
Linux Commands: Use tar -T for a controlled list of relative archive members.
Linux Commands✓ Tested
Debounce a button with a stable-time check
Accept an input change only after it stays stable for 30 ms.
debounce✓ Tested
Define a function with a typed parameter
Accept a name and return a greeting.
function✓ Tested
Describe an object with an interface
Require named fields on a reusable object shape.
interface✓ Tested
Display a calculated form result
HTML: An output element can name the input controls contributing to its value.
HTML✓ Tested
Exclude generated files from an archive
Linux Commands: Place exclude options before the input paths to control archive membership.
Linux Commands✓ Tested
Expose a disclosure button’s expanded state
HTML: Keep aria-expanded synchronized with the controlled panel’s hidden state.
HTML✓ Tested
Filter and transform an array
Keep active objects and extract their names.
filter✓ Tested
Give an optional property a default
Handle missing object fields with nullish coalescing.
optional✓ Tested
Handle a result with a discriminated union
Separate success data from an error message.
discriminated union✓ Tested
Handle a terminating error
Catch conversion failures and produce a clear fallback.
try catch✓ Tested