mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
Ensure _.sample handles falsey collection arguments.
This commit is contained in:
@@ -3895,7 +3895,7 @@
|
||||
collection = collection.split('');
|
||||
}
|
||||
if (n == null || guard) {
|
||||
return collection[random(length - 1)];
|
||||
return collection ? collection[random(length - 1)] : undefined;
|
||||
}
|
||||
var result = shuffle(collection);
|
||||
result.length = nativeMin(nativeMax(0, n), result.length);
|
||||
|
||||
Reference in New Issue
Block a user