Skip to content

Commit

Permalink
remove compose filtering (reduxjs#2167)
Browse files Browse the repository at this point in the history
  • Loading branch information
istarkov authored and seantcoyote committed Jan 14, 2018
1 parent 16fb40e commit 4de7d48
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 0 additions & 2 deletions src/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
*/

export default function compose(...funcs) {
funcs = funcs.filter(func => typeof func === 'function')

if (funcs.length === 0) {
return arg => arg
}
Expand Down
15 changes: 7 additions & 8 deletions test/compose.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ describe('Utils', () => {
expect(compose(c, a, b)(final)('')).toBe('cab')
})

it('composes only functions', () => {
it('throws at runtime if argument is not a function', () => {
const square = x => x * x
const add = (x, y) => x + y
expect(compose(square, add, false)(1, 2)).toBe(9)
expect(compose(square, add, undefined)(1, 2)).toBe(9)
expect(compose(square, add, true)(1, 2)).toBe(9)
expect(compose(square, add, NaN)(1, 2)).toBe(9)
expect(compose(square, add, '42')(1, 2)).toBe(9)

expect(() => compose(square, add, false)(1, 2)).toThrow()
expect(() => compose(square, add, undefined)(1, 2)).toThrow()
expect(() => compose(square, add, true)(1, 2)).toThrow()
expect(() => compose(square, add, NaN)(1, 2)).toThrow()
expect(() => compose(square, add, '42')(1, 2)).toThrow()
})

it('can be seeded with multiple arguments', () => {
Expand All @@ -41,7 +41,6 @@ describe('Utils', () => {
it('returns the first given argument if given no functions', () => {
expect(compose()(1, 2)).toBe(1)
expect(compose()(3)).toBe(3)
expect(compose(false,4,'test')(3)).toBe(3)
expect(compose()()).toBe(undefined)
})

Expand Down

0 comments on commit 4de7d48

Please sign in to comment.