Add lodash types for chainable contains/include/includes

This commit is contained in:
Tim Perry
2015-07-22 15:27:43 +01:00
parent 6baa15a0d7
commit da27def562
2 changed files with 67 additions and 1 deletions
+15
View File
@@ -370,16 +370,31 @@ result = <boolean>_.contains([1, 2, 3], 1, 2);
result = <boolean>_.contains({ 'moe': 30, 'larry': 40, 'curly': 67 }, 40);
result = <boolean>_.contains('curly', 'ur');
result = <boolean>_([1, 2, 3]).contains(1);
result = <boolean>_([1, 2, 3]).contains(1, 2);
result = <boolean>_({ 'moe': 30, 'larry': 40, 'curly': 67 }).contains(40);
result = <boolean>_('curly').contains('ur');
result = <boolean>_.include([1, 2, 3], 1);
result = <boolean>_.include([1, 2, 3], 1, 2);
result = <boolean>_.include({ 'moe': 30, 'larry': 40, 'curly': 67 }, 40);
result = <boolean>_.include('curly', 'ur');
result = <boolean>_([1, 2, 3]).include(1);
result = <boolean>_([1, 2, 3]).include(1, 2);
result = <boolean>_({ 'moe': 30, 'larry': 40, 'curly': 67 }).include(40);
result = <boolean>_('curly').include('ur');
result = <boolean>_.includes([1, 2, 3], 1);
result = <boolean>_.includes([1, 2, 3], 1, 2);
result = <boolean>_.includes({ 'moe': 30, 'larry': 40, 'curly': 67 }, 40);
result = <boolean>_.includes('curly', 'ur');
result = <boolean>_([1, 2, 3]).includes(1);
result = <boolean>_([1, 2, 3]).includes(1, 2);
result = <boolean>_({ 'moe': 30, 'larry': 40, 'curly': 67 }).includes(40);
result = <boolean>_('curly').includes('ur');
result = <_.Dictionary<number>>_.countBy([4.3, 6.1, 6.4], function (num) { return Math.floor(num); });
result = <_.Dictionary<number>>_.countBy([4.3, 6.1, 6.4], function (num) { return this.floor(num); }, Math);
result = <_.Dictionary<number>>_.countBy(['one', 'two', 'three'], 'length');
+52 -1
View File
@@ -39,7 +39,7 @@ declare module _ {
* Explicit chaining can be enabled by using the _.chain method.
**/
(value: number): LoDashWrapper<number>;
(value: string): LoDashWrapper<string>;
(value: string): LoDashStringWrapper;
(value: boolean): LoDashWrapper<boolean>;
(value: Array<number>): LoDashNumberArrayWrapper;
<T>(value: Array<T>): LoDashArrayWrapper<T>;
@@ -2149,6 +2149,57 @@ declare module _ {
fromIndex?: number): boolean;
}
interface LoDashArrayWrapper<T> {
/**
* @see _.contains
**/
contains(target: T, fromIndex?: number): boolean;
/**
* @see _.contains
**/
include(target: T, fromIndex?: number): boolean;
/**
* @see _.contains
**/
includes(target: T, fromIndex?: number): boolean;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.contains
**/
contains(target: any, fromIndex?: number): boolean;
/**
* @see _.contains
**/
include(target: any, fromIndex?: number): boolean;
/**
* @see _.contains
**/
includes(target: any, fromIndex?: number): boolean;
}
interface LoDashStringWrapper extends LoDashWrapper<string> {
/**
* @see _.contains
**/
contains(target: string, fromIndex?: number): boolean;
/**
* @see _.contains
**/
include(target: string, fromIndex?: number): boolean;
/**
* @see _.contains
**/
includes(target: string, fromIndex?: number): boolean;
}
//_.countBy
interface LoDashStatic {
/**