Skip to content

Commit 6781d9b

Browse files
committed
Extract out fn check
1 parent 0c674bd commit 6781d9b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/utils/compose-middleware.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
const isFunction = fn => typeof fn === 'function'
2+
13
export default function composeMiddleware (middleware) {
24
if (!Array.isArray(middleware)) {
35
throw new TypeError('Middleware stack must be an array!')
46
}
57

68
for (const fn of middleware) {
7-
if (typeof fn !== 'function') {
9+
if (!isFunction(fn)) {
810
throw new TypeError('Middleware must be composed of functions!')
911
}
1012
}
@@ -28,7 +30,7 @@ export default function composeMiddleware (middleware) {
2830
fn = next
2931
}
3032

31-
if (!fn || typeof fn !== 'function') {
33+
if (!fn || !isFunction(fn)) {
3234
return Promise.resolve()
3335
}
3436

0 commit comments

Comments
 (0)