INNER CODE UNIT · TypeScript

shuffleArray

austin-starks/Promptimizer · src/utils/index.ts:64

export function shuffleArray(array: any[]): any[] {
  for (let i = array.length - 1; i > 0; i--) {
    const j = Math.floor(Math.random() * (i + 1));
    [array[i], array[j]] = [array[j], array[i]];
  }
  return array;
}

export class PromiseAllWithErrorsError<T> extends Error {
  successes: T[];
  errors: string[];

  constructor(successes: T[], errors: string[]) {
    super(`Errors: ${errors.join("; ")}`);
    this.name = "PromiseAllWithErrorsError";
    this.successes = successes;
    this.errors = errors;
  }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…