|
1 |
| -import colors from '@colors/colors'; |
| 1 | +import pc from 'picocolors'; |
2 | 2 |
|
3 | 3 | import { createError } from '~/utils/createError';
|
4 | 4 | import { throwError } from '~/utils/throwError';
|
@@ -30,15 +30,15 @@ export function assertType<I extends KeyValuePair>(variable: I, expectedType: Al
|
30 | 30 | const { stackTrace, functionName, filePath, packageName } = createError(true);
|
31 | 31 |
|
32 | 32 | let output = '';
|
33 |
| - output += '\n' + colors.bold.red(packageName); |
34 |
| - output += '\n' + colors.white(`Function called from the file: ${colors.red(filePath)}`); |
35 |
| - output += '\n' + colors.white(`Function called: ${colors.yellow(functionName)}`); |
36 |
| - output += '\n' + colors.white(`Variable name: ${colors.green(key)}`); |
37 |
| - output += '\n' + colors.white(`Variable value: ${colors.blue(String(value))}`); |
38 |
| - output += '\n' + colors.white(`Variable type: ${colors.cyan(typeof value)}`); |
39 |
| - output += '\n' + colors.white(`Expected type: ${colors.magenta(expectedType)}`); |
40 |
| - output += '\n\n' + colors.gray(stackTrace); |
41 |
| - output += '\n\n' + colors.gray('This error was thrown by the assertType() function from @lawlzer/helpers.'); |
| 33 | + output += `\n ${pc.white(pc.bold(packageName))}`; |
| 34 | + output += `\n ${pc.white(`Function called from the file: ${pc.red(filePath)}`)}`; |
| 35 | + output += `\n ${pc.white(`Function called: ${pc.yellow(functionName)}`)}`; |
| 36 | + output += `\n ${pc.white(`Variable name: ${pc.green(key)}`)}`; |
| 37 | + output += `\n ${pc.white(`Variable value: ${pc.blue(String(value))}`)}`; |
| 38 | + output += `\n ${pc.white(`Variable type: ${pc.cyan(typeof value)}`)}`; |
| 39 | + output += `\n ${pc.white(`Expected type: ${pc.magenta(expectedType)}`)}`; |
| 40 | + output += `\n\n' ${pc.gray(stackTrace)}`; |
| 41 | + output += `\n\n' ${pc.gray('This error was thrown by the assertType() function from @lawlzer/helpers.')}`; |
42 | 42 |
|
43 | 43 | throw output;
|
44 | 44 | }
|
0 commit comments