function invariant()

in packages/fbjs/src/__forks__/invariant.js [30:53]


function invariant(
  condition: mixed,
  format: string,
  ...args: Array<mixed>
): void {
  validateFormat(format);

  if (!condition) {
    let error;
    if (format === undefined) {
      error = new Error(
        'Minified exception occurred; use the non-minified dev environment ' +
          'for the full error message and additional helpful warnings.',
      );
    } else {
      let argIndex = 0;
      error = new Error(format.replace(/%s/g, () => String(args[argIndex++])));
      error.name = 'Invariant Violation';
    }

    (error: any).framesToPop = 1; // Skip invariant's own stack frame.
    throw error;
  }
}