transcontextual safe type checks
This commit is contained in:
parent
8c58f462fc
commit
e2c0949dd5
|
@ -47,15 +47,15 @@ function mergeFunctionArgs (argv, start, end) {
|
||||||
const handlers = []
|
const handlers = []
|
||||||
|
|
||||||
for (let i = start; i < end; i++) {
|
for (let i = start; i < end; i++) {
|
||||||
if (argv[i] instanceof Array) {
|
if (Array.isArray(argv[i])) {
|
||||||
const arr = argv[i]
|
const arr = argv[i]
|
||||||
for (let j = 0; j < arr.length; j++) {
|
for (let j = 0; j < arr.length; j++) {
|
||||||
if (!(arr[j] instanceof Function)) {
|
if ((typeof arr[j] !== 'function')) {
|
||||||
throw new TypeError('Invalid argument type: ' + typeof (arr[j]))
|
throw new TypeError('Invalid argument type: ' + typeof (arr[j]))
|
||||||
}
|
}
|
||||||
handlers.push(arr[j])
|
handlers.push(arr[j])
|
||||||
}
|
}
|
||||||
} else if (argv[i] instanceof Function) {
|
} else if (typeof argv[i] === 'function') {
|
||||||
handlers.push(argv[i])
|
handlers.push(argv[i])
|
||||||
} else {
|
} else {
|
||||||
throw new TypeError('Invalid argument type: ' + typeof (argv[i]))
|
throw new TypeError('Invalid argument type: ' + typeof (argv[i]))
|
||||||
|
|
Loading…
Reference in New Issue