diff --git a/lodash.js b/lodash.js index de6facfa0..d19e6b84d 100644 --- a/lodash.js +++ b/lodash.js @@ -5372,6 +5372,9 @@ funcsLength = funcs.length, length = funcsLength; + if (!length) { + return function() {}; + } while (length--) { if (!isFunction(funcs[length])) { throw new TypeError(funcErrorText); diff --git a/test/test.js b/test/test.js index b1f5586b4..021c25e28 100644 --- a/test/test.js +++ b/test/test.js @@ -1503,6 +1503,17 @@ notStrictEqual(_.compose(_.noop), _.noop); }); + test('should return a noop function when no arguments are provided', 2, function() { + var composed = _.compose(); + + try { + strictEqual(composed(), undefined); + } catch(e) { + ok(false); + } + notStrictEqual(composed, _.noop); + }); + test('should return a wrapped value when chaining', 1, function() { if (!isNpm) { var actual = _(_.noop).compose();