Underscore.js: Updated chained calls to first() so that they return a _ChainSingle<T> instead of _Chain<T>. This causes a future call to value() to return a single T rather than an array of T which matches underscore's behavior.

This commit is contained in:
Bo Miller
2014-07-29 23:49:35 -04:00
parent 11c40b45e0
commit 70ff4da3ee
2 changed files with 5 additions and 1 deletions

View File

@@ -328,4 +328,8 @@ function chain_tests() {
.flatten()
.find(num => num % 2 == 0)
.value();
var firstVal: number = _.chain([1, 2, 3])
.first()
.value();
}

View File

@@ -2620,7 +2620,7 @@ interface _Chain<T> {
* Wrapped type `any[]`.
* @see _.first
**/
first(): _Chain<T>;
first(): _ChainSingle<T>;
/**
* Wrapped type `any[]`.