From eff54af628a053f78dc63d6d79da6862a8a71439 Mon Sep 17 00:00:00 2001 From: peferron Date: Mon, 13 Apr 2015 21:02:00 -0700 Subject: [PATCH] lodash: update _.zipObject and _.object - Update the jsdoc and parameter names. - Add the 'two-dimensional array' invocation type. - Add chaining. - In the test file, replace `{ [key: string]: any }` by `Dictionary` for consistency with the rest of the code. --- lodash/lodash-tests.ts | 10 +++++++-- lodash/lodash.d.ts | 46 +++++++++++++++++++++++++++++++----------- 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 46c11ebf6f..4c19db806b 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -255,8 +255,14 @@ result = _.last(foodsType, { 'type': 'vegetable' }); result = _.lastIndexOf([1, 2, 3, 1, 2, 3], 2); result = _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); -result = <{ [key: string]: any }>_.zipObject(['moe', 'larry'], [30, 40]); -result = <{ [key: string]: any }>_.object(['moe', 'larry'], [30, 40]); +result = <_.Dictionary>_.zipObject(['moe', 'larry'], [30, 40]); +result = <_.LoDashObjectWrapper<_.Dictionary>>_(['moe', 'larry']).zipObject([30, 40]); +result = <_.Dictionary>_.object(['moe', 'larry'], [30, 40]); +result = <_.LoDashObjectWrapper<_.Dictionary>>_(['moe', 'larry']).object([30, 40]); +result = <_.Dictionary>_.zipObject([['moe', 30], ['larry', 40]]); +result = <_.LoDashObjectWrapper<_.Dictionary>>_([['moe', 30], ['larry', 40]]).zipObject(); +result = <_.Dictionary>_.object([['moe', 30], ['larry', 40]]); +result = <_.LoDashObjectWrapper<_.Dictionary>>_([['moe', 30], ['larry', 40]]).object(); result = _.pull([1, 2, 3, 1, 2, 3], 2, 3); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 55d35707fb..55d099f183 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -2042,25 +2042,47 @@ declare module _ { //_.zipObject interface LoDashStatic { /** - * Creates an object composed from arrays of keys and values. Provide either a single - * two dimensional array, i.e. [[key1, value1], [key2, value2]] or two arrays, one of - * keys and one of corresponding values. - * @param keys The array of keys. - * @param values The array of values. - * @return An object composed of the given keys and corresponding values. + * The inverse of _.pairs; this method returns an object composed from arrays of property + * names and values. Provide either a single two dimensional array, e.g. [[key1, value1], + * [key2, value2]] or two arrays, one of property names and one of corresponding values. + * @param props The property names. + * @param values The property values. + * @return Returns the new object. **/ zipObject( - keys: List, - values: List): TResult; + props: List, + values?: List): TResult; /** - * @see _.object + * @see _.zipObject + **/ + zipObject(props: List>): Dictionary; + + /** + * @see _.zipObject **/ object( - keys: List, - values: List): TResult; - } + props: List, + values?: List): TResult; + /** + * @see _.zipObject + **/ + object(props: List>): Dictionary; + } + + interface LoDashArrayWrapper { + /** + * @see _.zipObject + **/ + zipObject(values?: List): _.LoDashObjectWrapper>; + + /** + * @see _.zipObject + **/ + object(values?: List): _.LoDashObjectWrapper>; + } + /* ************* * Collections * ************* */