(message, func)
| 136 | * @returns {String} |
| 137 | */ |
| 138 | const mapToReference = (message, func) => { |
| 139 | let msgWithReference = ''; |
| 140 | if (func == null || func.substring(0, 4) === 'load') { |
| 141 | msgWithReference = message; |
| 142 | } else { |
| 143 | const methodParts = func.split('.'); |
| 144 | const referenceSection = |
| 145 | methodParts.length > 1 ? `${methodParts[0]}.${methodParts[1]}` : 'p5'; |
| 146 | |
| 147 | const funcName = |
| 148 | methodParts.length === 1 ? func : methodParts.slice(2).join('/'); |
| 149 | |
| 150 | //Whenever func having p5.[Class] is encountered, we need to have the error link as mentioned below else different link |
| 151 | funcName.startsWith('p5.') ? |
| 152 | msgWithReference = `${message} (https://p5js.org/reference/${referenceSection}.${funcName})` : |
| 153 | msgWithReference = `${message} (https://p5js.org/reference/${referenceSection}/${funcName})`; |
| 154 | } |
| 155 | return msgWithReference; |
| 156 | }; |
| 157 | |
| 158 | /** |
| 159 | * Prints out a fancy, colorful message to the console log |
no test coverage detected