mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-07 16:30:12 +08:00
Merge pull request #7515 from andreialecu/patch-1
underscore: fix _.chain(Dictionary), _.values(Dictionary), _(Dictionary)
This commit is contained in:
@@ -479,3 +479,25 @@ _.chain(obj).map(function (value, key) {
|
||||
empty[key] = value;
|
||||
console.log("vk", value, key);
|
||||
});
|
||||
|
||||
function strong_typed_values_tests() {
|
||||
var dictionaryLike: { [k: string] : {title: string, value: number} } = {
|
||||
'test' : { title: 'item1', value: 5 },
|
||||
'another' : { title: 'item2', value: 8 },
|
||||
'third' : { title: 'item3', value: 10 }
|
||||
};
|
||||
|
||||
_.chain(dictionaryLike).values().filter((r) => {
|
||||
return r.value >= 8;
|
||||
}).map((r) => {
|
||||
return [r.title, true];
|
||||
}).object().value();
|
||||
|
||||
var x: number = _(dictionaryLike).chain().filter((x) => {
|
||||
console.log(x.title);
|
||||
console.log(x.value.toFixed());
|
||||
return x.title == 'item1';
|
||||
}).size().value();
|
||||
|
||||
_.values<{title: string, value: number}>(dictionaryLike);
|
||||
}
|
||||
|
||||
Vendored
+10
-1
@@ -76,6 +76,7 @@ interface UnderscoreStatic {
|
||||
* as the first parameter can be invoked through this function.
|
||||
* @param key First argument to Underscore object functions.
|
||||
**/
|
||||
<T>(value: _.Dictionary<T>): Underscore<T>;
|
||||
<T>(value: Array<T>): Underscore<T>;
|
||||
<T>(value: T): Underscore<T>;
|
||||
|
||||
@@ -1233,6 +1234,13 @@ interface UnderscoreStatic {
|
||||
**/
|
||||
allKeys(object: any): string[];
|
||||
|
||||
/**
|
||||
* Return all of the values of the object's properties.
|
||||
* @param object Retrieve the values of all the properties on this object.
|
||||
* @return List of all the values on `object`.
|
||||
**/
|
||||
values<T>(object: _.Dictionary<T>): T[];
|
||||
|
||||
/**
|
||||
* Return all of the values of the object's properties.
|
||||
* @param object Retrieve the values of all the properties on this object.
|
||||
@@ -1700,6 +1708,7 @@ interface UnderscoreStatic {
|
||||
* @return Wrapped `obj`.
|
||||
**/
|
||||
chain<T>(obj: T[]): _Chain<T>;
|
||||
chain<T>(obj: _.Dictionary<T>): _Chain<T>;
|
||||
chain<T extends {}>(obj: T): _Chain<T>;
|
||||
}
|
||||
|
||||
@@ -2914,7 +2923,7 @@ interface _Chain<T> {
|
||||
* Wrapped type `any`.
|
||||
* @see _.size
|
||||
**/
|
||||
size(): _Chain<T>;
|
||||
size(): _ChainSingle<number>;
|
||||
|
||||
/*********
|
||||
* Arrays *
|
||||
|
||||
Reference in New Issue
Block a user