Skip to content

Commit b4fb081

Browse files
istarkovtimdorr
authored andcommitted
remove compose filtering (reduxjs#2167)
1 parent e09b2d1 commit b4fb081

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/compose.js

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

1212
export default function compose(...funcs) {
13-
funcs = funcs.filter(func => typeof func === 'function')
14-
1513
if (funcs.length === 0) {
1614
return arg => arg
1715
}

test/compose.spec.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ describe('Utils', () => {
2121
expect(compose(c, a, b)(final)('')).toBe('cab')
2222
})
2323

24-
it('composes only functions', () => {
24+
it('throws at runtime if argument is not a function', () => {
2525
const square = x => x * x
2626
const add = (x, y) => x + y
27-
28-
expect(compose(square, add, false)(1, 2)).toBe(9)
29-
expect(compose(square, add, undefined)(1, 2)).toBe(9)
30-
expect(compose(square, add, true)(1, 2)).toBe(9)
31-
expect(compose(square, add, NaN)(1, 2)).toBe(9)
32-
expect(compose(square, add, '42')(1, 2)).toBe(9)
27+
28+
expect(() => compose(square, add, false)(1, 2)).toThrow()
29+
expect(() => compose(square, add, undefined)(1, 2)).toThrow()
30+
expect(() => compose(square, add, true)(1, 2)).toThrow()
31+
expect(() => compose(square, add, NaN)(1, 2)).toThrow()
32+
expect(() => compose(square, add, '42')(1, 2)).toThrow()
3333
})
3434

3535
it('can be seeded with multiple arguments', () => {
@@ -41,7 +41,6 @@ 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)
4544
expect(compose()()).toBe(undefined)
4645
})
4746

0 commit comments

Comments
 (0)