Merge pull request #5026 from pimterry/lodash-contains-chain

Add Lodash contains/include/includes as chained methods
This commit is contained in:
Masahiro Wakame
2015-07-29 00:21:59 +09:00
2 changed files with 69 additions and 1 deletions
+15
View File
@@ -366,16 +366,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');
+54 -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>;
@@ -205,6 +205,8 @@ declare module _ {
interface LoDashWrapper<T> extends LoDashWrapperBase<T, LoDashWrapper<T>> { }
interface LoDashStringWrapper extends LoDashWrapper<string> { }
interface LoDashObjectWrapper<T> extends LoDashWrapperBase<T, LoDashObjectWrapper<T>> { }
interface LoDashArrayWrapper<T> extends LoDashWrapperBase<T[], LoDashArrayWrapper<T>> {
@@ -2164,6 +2166,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<TValue>(target: TValue, fromIndex?: number): boolean;
/**
* @see _.contains
**/
include<TValue>(target: TValue, fromIndex?: number): boolean;
/**
* @see _.contains
**/
includes<TValue>(target: TValue, fromIndex?: number): boolean;
}
interface LoDashStringWrapper {
/**
* @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 {
/**