Build a composeAsync Utility That Chains Async Functions Right to Left

Implement a composeAsync(...fns) function that composes async functions right-to-left (reverse of pipe) — the rightmost function is called first with the input, and each result is passed to the next function leftward. Each function in the chain may return a value or a Promise, and the final output should be a Promise resolving to the composed result. Also support chaining via a .then()-like API on the composed function itself.

Examples
Input: []
Output:
Hints

Build a composeAsync Utility That Chains Async Functions Right to Left

Implement a composeAsync(...fns) function that composes async functions right-to-left (reverse of pipe) — the rightmost function is called first with the input, and each result is passed to the next function leftward. Each function in the chain may return a value or a Promise, and the final output should be a Promise resolving to the composed result. Also support chaining via a .then()-like API on the composed function itself.