Browse Source

perf: preinitialize typeCheck RegExp (#10990)

dev
Sebastian Speitel 4 years ago
committed by GitHub
parent
commit
2488a6a1e9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/core/util/props.js

4
src/core/util/props.js

@ -174,13 +174,15 @@ function assertType (value: any, type: Function): {
}
}
const functionTypeCheckRE = /^\s*function (\w+)/
/**
* Use function string name to check built-in types,
* because a simple equality check will fail when running
* across different vms / iframes.
*/
function getType (fn) {
const match = fn && fn.toString().match(/^\s*function (\w+)/)
const match = fn && fn.toString().match(functionTypeCheckRE)
return match ? match[1] : ''
}

Loading…
Cancel
Save