We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent eb4e888 commit b55b10cCopy full SHA for b55b10c
src/types.js
@@ -26,9 +26,15 @@ module.exports = function enforce(type, value) {
26
}
27
28
default: {
29
- if (value.constructor.toString().match(/function (.*?)\(/)[1] === type.name) return
+ if (getName(value.constructor) === getName(type)) return
30
31
32
33
- throw new TypeError('Expected ' + (type.name || type) + ', got ' + value)
+ throw new TypeError('Expected ' + (getName(type) || type) + ', got ' + value)
34
+}
35
+
36
+function getName(fn) {
37
+ // Why not fn.name: https://kangax.github.io/compat-table/es6/#function_name_property
38
+ var match = fn.toString().match(/function (.*?)\(/)
39
+ return match ? match[1] : null
40
0 commit comments