From c961ba33be17320362f130b12acdd75f44642779 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Sat, 5 Sep 2015 16:09:24 +0500 Subject: [PATCH] lodash: changed _.get() method --- lodash/lodash-tests.ts | 22 +++++++++++----------- lodash/lodash.d.ts | 10 +++++----- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 4e3bb97da..8eb727d38 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1482,18 +1482,18 @@ result = <_.LoDashArrayWrapper>_(_).methods(); // _.get result = _.get({ 'a': [{ 'b': { 'c': 3 } }] }, 'a[0].b.c'); -// → 3 -result = _.get({ 'a': [{ 'b': { 'c': 3 } }] }, ['a', '0', 'b', 'c']); -// → 3 -result = _.get({ 'a': [{ 'b': { 'c': 3 } }] }, 'a.b.c', 'default'); -// → 'default' -result = _({ 'a': [{ 'b': { 'c': 3 } }] }).get('a[0].b.c'); -// → 3 -result = _({ 'a': [{ 'b': { 'c': 3 } }] }).get(['a', '0', 'b', 'c']); -// → 3 -result = _({ 'a': [{ 'b': { 'c': 3 } }] }).get('a.b.c', 'default'); -// → 'default' +{ + let result: TResult; + result = _.get({}, ''); + result = _.get({}, 42); + result = _.get({}, true); + result = _.get({}, ['', 42, true]); + result = _({}).get(''); + result = _({}).get(42); + result = _({}).get(true); + result = _({}).get(['', 42, true]); +} result = _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index f54bbbbb4..9c4a59c4c 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -7117,17 +7117,17 @@ declare module _ { * @param defaultValue The value returned if the resolved value is undefined. * @return Returns the resolved value. **/ - get(object: Object, - path: string|string[], - defaultValue?:T - ): T; + get(object: Object, + path: string|number|boolean|Array, + defaultValue?:TResult + ): TResult; } interface LoDashObjectWrapper { /** * @see _.get **/ - get(path: string|string[], + get(path: string|number|boolean|Array, defaultValue?: TResult ): TResult; }