mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 07:47:49 +00:00
Ensure func is a function before querying the weakmap. [closes #1319]
This commit is contained in:
committed by
John-David Dalton
parent
a5e2caf40b
commit
2e50d11be5
@@ -3998,7 +3998,7 @@
|
||||
* @returns {*} Returns the metadata for `func`.
|
||||
*/
|
||||
var getData = !metaMap ? noop : function(func) {
|
||||
return metaMap.get(func);
|
||||
return typeof func == 'function' ? metaMap.get(func) : undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
14
test/test.js
14
test/test.js
@@ -3379,6 +3379,20 @@
|
||||
fn = function(a, b) { return slice.call(arguments); },
|
||||
isCurry = methodName == 'curry';
|
||||
|
||||
test('`_.' + methodName + '` should not error on functions with the same name as lodash methods', 1, function() {
|
||||
function run(a, b) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
var curried = func(run);
|
||||
|
||||
try {
|
||||
var actual = curried(1)(2);
|
||||
} catch(e) {}
|
||||
|
||||
strictEqual(actual, 3);
|
||||
});
|
||||
|
||||
test('`_.' + methodName + '` should work as an iteratee for methods like `_.map`', 2, function() {
|
||||
var array = [fn, fn, fn],
|
||||
object = { 'a': fn, 'b': fn, 'c': fn };
|
||||
|
||||
Reference in New Issue
Block a user