Generate a Clean, Typed Utility Function

Ask Copilot to create a reusable, well-typed utility function with edge cases handled.

category:code-generation
typescript
utilities
clean-code
0

Prompt

You are a senior engineer. Generate a clean, reusable utility function that does the following:
  
  [describe the behaviour, inputs, and expected output here]
  
  Requirements:
  - Use TypeScript.
  - Strongly type all parameters and return values.
  - Handle null/undefined and common edge cases.
  - Add a short JSDoc comment explaining the function.
  - Keep the implementation small and focused.
  
  After writing the function, add 2–3 usage examples as inline comments.