I tried this and there is a newline before function. So it needs to be

```js
type.toString().match(/^\s*function\s*([^\s(]+)/)[1];
```