File size: 590 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/**
 * Throws an error if the condition is not met.
 *
 * The error is exhaustive in development, and becomes generic in production.
 *
 * This is used to make development a better experience to provide guidance as
 * to where the error comes from.
 */
export function invariant(
  condition: boolean,
  message: string | (() => string)
): asserts condition {
  if (condition) {
    return;
  }

  if (!__DEV__) {
    throw new Error('Invariant failed');
  }

  if (__DEV__) {
    throw new Error(
      `[InstantSearch] ${typeof message === 'function' ? message() : message}`
    );
  }
}