8000 Ensure `_.sample` handles falsey `collection` arguments. · lodash/lodash@8c07a67 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8c07a67

Browse files
committed
Ensure _.sample handles falsey collection arguments.
1 parent 0f9687c commit 8c07a67

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lodash.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3895,7 +3895,7 @@
38953895
collection = collection.split('');
38963896
}
38973897
if (n == null || guard) {
3898-
return collection[random(length - 1)];
3898+
return collection ? collection[random(length - 1)] : undefined;
38993899
}
39003900
var result = shuffle(collection);
39013901
result.length = nativeMin(nativeMax(0, n), result.length);

0 commit comments

Comments
 (0)
0