UNPKG

707 BPlain TextView Raw
1/* eslint no-console: 0 */
2const isDev = process.env.NODE_ENV !== 'production';
3
4export const warn = (condition: boolean, format: string, ...args: any[]) => {
5 if (isDev && typeof console !== 'undefined' && console.warn) {
6 if (format === undefined) {
7 console.warn('LogUtils requires an error message argument');
8 }
9
10 if (!condition) {
11 if (format === undefined) {
12 console.warn(
13 'Minified exception occurred; use the non-minified dev environment ' +
14 'for the full error message and additional helpful warnings.',
15 );
16 } else {
17 let argIndex = 0;
18
19 console.warn(format.replace(/%s/g, () => args[argIndex++]));
20 }
21 }
22 }
23};