From 14394df1810b7899ae4b7c843dfbd326e9230529 Mon Sep 17 00:00:00 2001 From: Felipe Barriga Richards Date: Mon, 17 Aug 2015 14:50:12 -0300 Subject: [PATCH] lodash: Fix _.has and _.result --- lodash/lodash-tests.ts | 6 ++++++ lodash/lodash.d.ts | 21 +++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 2cbec6853..4e741f5dc 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1571,6 +1571,10 @@ result = _(any).noop(true, 'a', 1); var object = { 'cheese': 'crumpets', + 'one': 1, + 'nested': { + 'two': 2 + }, 'stuff': function () { return 'nonsense'; } @@ -1578,6 +1582,8 @@ var object = { result = _.result(object, 'cheese'); result = _.result(object, 'stuff'); +result = _.result(object, 'one'); +result = _.result(object, ['nested', 'two'] ); var tempObject = {}; result = _.runInContext(tempObject); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index c088f5459..7fd62eb4b 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -6810,13 +6810,12 @@ declare module _ { //_.has interface LoDashStatic { /** - * Checks if the specified object property exists and is a direct property, instead of an - * inherited property. - * @param object The object to check. - * @param property The property to check for. - * @return True if key is a direct property, else false. + * Checks if path is a direct property. + * @param object The object to query. + * @param path The path to check. + * @return True if path is a direct property, else False. **/ - has(object: any, property: string): boolean; + has(object: any, path: string|string[]): boolean; } //_.invert @@ -7822,12 +7821,14 @@ declare module _ { /** * Resolves the value of property on object. If property is a function it will be invoked with * the this binding of object and its result returned, else the property value is returned. If - * object is falsey then undefined is returned. - * @param object The object to inspect. - * @param property The property to get the value of. + * object is false then undefined is returned. + * @param object The object to query. + * @param path The path of the property to resolve. + * @param defaultValue The value returned if the resolved value is undefined. * @return The resolved value. **/ - result(object: any, property: string): any; + + result(object: any, path: string|string[], defaultValue?: T): T; } //_.runInContext