mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 19:07:49 +00:00
Ensure _.flow and _.flowRight return an identity function when no arguments are provided. [closes #938]
This commit is contained in:
@@ -7207,7 +7207,7 @@
|
|||||||
length = funcs.length;
|
length = funcs.length;
|
||||||
|
|
||||||
if (!length) {
|
if (!length) {
|
||||||
return function() {};
|
return function() { return arguments[0]; };
|
||||||
}
|
}
|
||||||
if (!arrayEvery(funcs, isFunction)) {
|
if (!arrayEvery(funcs, isFunction)) {
|
||||||
throw new TypeError(FUNC_ERROR_TEXT);
|
throw new TypeError(FUNC_ERROR_TEXT);
|
||||||
@@ -7252,7 +7252,7 @@
|
|||||||
fromIndex = funcs.length - 1;
|
fromIndex = funcs.length - 1;
|
||||||
|
|
||||||
if (fromIndex < 0) {
|
if (fromIndex < 0) {
|
||||||
return function() {};
|
return function() { return arguments[0]; };
|
||||||
}
|
}
|
||||||
if (!arrayEvery(funcs, isFunction)) {
|
if (!arrayEvery(funcs, isFunction)) {
|
||||||
throw new TypeError(FUNC_ERROR_TEXT);
|
throw new TypeError(FUNC_ERROR_TEXT);
|
||||||
|
|||||||
@@ -2023,15 +2023,15 @@
|
|||||||
notStrictEqual(func(_.noop), _.noop);
|
notStrictEqual(func(_.noop), _.noop);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('`_.' + methodName + '` should return a noop function when no arguments are provided', 2, function() {
|
test('`_.' + methodName + '` should return an identity function when no arguments are provided', 2, function() {
|
||||||
var combined = func();
|
var combined = func();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
strictEqual(combined(), undefined);
|
strictEqual(combined('a'), 'a');
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
ok(false, e.message);
|
ok(false, e.message);
|
||||||
}
|
}
|
||||||
notStrictEqual(combined, _.noop);
|
notStrictEqual(combined, _.identity);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('`_.' + methodName + '` should return a wrapped value when chaining', 1, function() {
|
test('`_.' + methodName + '` should return a wrapped value when chaining', 1, function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user