From 2f7754dceb349d4d1058bd4c11f144e6d9013536 Mon Sep 17 00:00:00 2001 From: Daniel Beckwith Date: Tue, 7 Jul 2015 17:49:06 -0400 Subject: [PATCH 1/2] Fixes contains searching keys instead of values on objects, also adds "includes" alias. --- lodash/lodash-tests.ts | 9 +++++++-- lodash/lodash.d.ts | 38 +++++++++++++++++++++++++++++++++++--- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index c7e6bf024..0c73066c5 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -363,14 +363,19 @@ result = _.at(['moe', 'larry', 'curly'], 0, 2); result = _.contains([1, 2, 3], 1); result = _.contains([1, 2, 3], 1, 2); -result = _.contains({ 'name': 'moe', 'age': 40 }, 'moe'); +result = _.contains({ 'moe': 30, 'larry': 40, 'curly': 67 }, 40); result = _.contains('curly', 'ur'); result = _.include([1, 2, 3], 1); result = _.include([1, 2, 3], 1, 2); -result = _.include({ 'name': 'moe', 'age': 40 }, 'moe'); +result = _.include({ 'moe': 30, 'larry': 40, 'curly': 67 }, 40); result = _.include('curly', 'ur'); +result = _.includes([1, 2, 3], 1); +result = _.includes([1, 2, 3], 1, 2); +result = _.includes({ 'moe': 30, 'larry': 40, 'curly': 67 }, 40); +result = _.includes('curly', 'ur'); + result = <_.Dictionary>_.countBy([4.3, 6.1, 6.4], function (num) { return Math.floor(num); }); result = <_.Dictionary>_.countBy([4.3, 6.1, 6.4], function (num) { return this.floor(num); }, Math); result = <_.Dictionary>_.countBy(['one', 'two', 'three'], 'length'); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index b4eaf7509..21bd2357f 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -2198,11 +2198,11 @@ declare module _ { /** * @see _.contains * @param dictionary The dictionary to iterate over. - * @param key The key in the dictionary to search for. + * @param value The value in the dictionary to search for. **/ contains( dictionary: Dictionary, - key: string, + value: T, fromIndex?: number): boolean; /** @@ -2236,7 +2236,7 @@ declare module _ { **/ include( dictionary: Dictionary, - key: string, + value: T, fromIndex?: number): boolean; /** @@ -2246,6 +2246,38 @@ declare module _ { searchString: string, targetString: string, fromIndex?: number): boolean; + + /** + * @see _.contains + **/ + includes( + collection: Array, + target: T, + fromIndex?: number): boolean; + + /** + * @see _.contains + **/ + includes( + collection: List, + target: T, + fromIndex?: number): boolean; + + /** + * @see _.contains + **/ + includes( + dictionary: Dictionary, + value: T, + fromIndex?: number): boolean; + + /** + * @see _.contains + **/ + includes( + searchString: string, + targetString: string, + fromIndex?: number): boolean; } //_.countBy From 9436ac816b62aebb13ceb2c3ab8397898832789c Mon Sep 17 00:00:00 2001 From: Daniel Beckwith Date: Tue, 7 Jul 2015 18:07:52 -0400 Subject: [PATCH 2/2] Remove includes from sequelize definition, since it's in lodash's now. --- sequelize/sequelize.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sequelize/sequelize.d.ts b/sequelize/sequelize.d.ts index 85d473f28..1bb6be593 100644 --- a/sequelize/sequelize.d.ts +++ b/sequelize/sequelize.d.ts @@ -2703,7 +2703,6 @@ declare module "sequelize" } interface Lodash extends _.LoDashStatic { - includes(str: string, needle: string): boolean; camelizeIf(str: string, condition: boolean): string; camelizeIf(str: string, condition: any): string; underscoredIf(str: string, condition: boolean): string; @@ -2785,4 +2784,4 @@ declare module "sequelize" var sequelize: sequelize.SequelizeStatic; export = sequelize; -} \ No newline at end of file +}