function* operationsWithThunk(thunk, input = 0) {
  let result = input * 2; // First operation
  result = yield thunk(result); // Call the hook, which can be sync or async
  result *= 2; // Operation on the hook's result
  // Check if the result is divisible by N, and if so, recurse
  if (result < 1000) {
    result = yield* operationsWithThunk(thunk, result); // Recurse with yield*
  }
  return result;
}
@template {number|Promise<number>} TResult
@param {(arg: number) => TResult} thunk
@param {number} [input]
@returns {Generator<TResult, number, number>}