Skip to content

Commit 3ae7c91

Browse files
committed
fixed condition where multiple bad values would be filtered out and have nothing to return
1 parent 7677804 commit 3ae7c91

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/compose.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
*/
1111

1212
export default function compose(...funcs) {
13+
funcs = funcs.filter(func => typeof func === 'function')
14+
1315
if (funcs.length === 0) {
1416
return arg => arg
1517
}
1618

17-
funcs = funcs.filter(func => typeof func === 'function')
18-
1919
if (funcs.length === 1) {
2020
return funcs[0]
2121
}

test/compose.spec.js

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ describe('Utils', () => {
4141
it('returns the first given argument if given no functions', () => {
4242
expect(compose()(1, 2)).toBe(1)
4343
expect(compose()(3)).toBe(3)
44+
expect(compose(false,4,"test")(3)).toBe(3)
4445
expect(compose()()).toBe(undefined)
4546
})
4647

0 commit comments

Comments
 (0)