INNER CODE UNIT · TypeScript

unwrapArray

cloudposse/atmos · .github/actions/stopwatch/src/index.ts:123

function unwrapArray<T>(response: unknown): T[] {
  if (!Array.isArray(response)) {
    throw new Error("GitHub API returned an unexpected paginated response");
  }
  return response as T[];
}

/** Builds an unwrapping function for a paginated response property. */
function unwrapProperty<T>(property: string): (response: unknown) => T[] {
  return (response: unknown): T[] => {
    if (typeof response !== "object" || response === null || !Array.isArray(Reflect.get(response, property))) {
      throw new Error(`GitHub API response did not contain ${property}`);
    }
    return Reflect.get(response, property) as T[];
  };
}

/** Collects completed PR workflow timings and publishes the sticky comment. */

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…