mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 16:17:50 +00:00
Ensure _.compose returns a noop function when no arguments are provided.
This commit is contained in:
@@ -5372,6 +5372,9 @@
|
||||
funcsLength = funcs.length,
|
||||
length = funcsLength;
|
||||
|
||||
if (!length) {
|
||||
return function() {};
|
||||
}
|
||||
while (length--) {
|
||||
if (!isFunction(funcs[length])) {
|
||||
throw new TypeError(funcErrorText);
|
||||
|
||||
11
test/test.js
11
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();
|
||||
|
||||
Reference in New Issue
Block a user