Permalink
Browse files

remove compose filtering (#2167)

  • Loading branch information...
1 parent e09b2d1 commit b4fb08133c95094a4b293a9ab434d1d5dd657527 @istarkov istarkov committed with timdorr Dec 30, 2016
Showing with 7 additions and 10 deletions.
  1. +0 −2 src/compose.js
  2. +7 −8 test/compose.spec.js
View
@@ -10,8 +10,6 @@
*/
export default function compose(...funcs) {
- funcs = funcs.filter(func => typeof func === 'function')
-
if (funcs.length === 0) {
return arg => arg
}
View
@@ -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', () => {
@@ -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)
})

0 comments on commit b4fb081

Please sign in to comment.