Ensure _.sample chains correctly.

This commit is contained in:
John-David Dalton
2014-09-16 01:07:33 -07:00
parent 3ab19e81ac
commit f05f60f929
2 changed files with 8 additions and 7 deletions

View File

@@ -9587,11 +9587,12 @@
lodash.sample = sample;
lodash.prototype.sample = function(n, guard) {
if (!this.__chain__ && (n == null || guard)) {
n = guard ? null : n;
if (!this.__chain__ && n == null) {
return lodash.sample(this.value());
}
return this.tap(function(value) {
lodash.sample(value);
return this.thru(function(value) {
return lodash.sample(value, n);
});
};