mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-01 11:50:54 +08:00
Merge pull request #5026 from pimterry/lodash-contains-chain
Add Lodash contains/include/includes as chained methods
This commit is contained in:
@@ -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');
|
||||
|
||||
Vendored
+54
-1
@@ -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 {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user