Add LazyWrapper#slice.

This commit is contained in:
John-David Dalton
2014-10-19 22:08:05 -07:00
parent f5a34d5191
commit 6dfc2aca4b
2 changed files with 38 additions and 2 deletions

View File

@@ -10075,6 +10075,17 @@
});
};
LazyWrapper.prototype.slice = function(start, end) {
start = start == null ? 0 : (+start || 0);
var result = start < 0 ? this.takeRight(-start) : this.drop(start);
if (typeof end != 'undefined') {
end = (+end || 0);
result = end < 0 ? result.dropRight(-end) : result.take(end - start);
}
return result;
};
// add `LazyWrapper` methods to `LodashWrapper`
baseForOwn(LazyWrapper.prototype, function(func, methodName) {
var retUnwrapped = /^(?:first|last)$/.test(methodName);