(script?: string|Function)
| 114 | * @param script WebDriver command script |
| 115 | */ |
| 116 | export function transformCommandScript (script?: string|Function) { |
| 117 | if (!script) { |
| 118 | return script |
| 119 | } |
| 120 | let name = undefined |
| 121 | if (typeof script === 'string') { |
| 122 | name = FIRST_FUNCTION_REGEX.exec(script) |
| 123 | // reset the static RegExp globals to avoid leaking `script` |
| 124 | FIRST_FUNCTION_REGEX.exec('') |
| 125 | } else if (typeof script === 'function') { |
| 126 | name = script.name |
| 127 | script = script.toString() |
| 128 | } else { |
| 129 | return `<${typeof script}>` |
| 130 | } |
| 131 | |
| 132 | if (typeof name === 'string' && name) { |
| 133 | return `<script fn ${name}(...)> [${Buffer.byteLength(script, 'utf-8')} bytes]` |
| 134 | } |
| 135 | return `<script> [${Buffer.byteLength(script, 'utf-8')} bytes]` |
| 136 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…