mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
lodash: changed _.get() (added to the chainable wrapper)
This commit is contained in:
+14
-1
@@ -936,7 +936,20 @@ result = <string[]>_.methods(_);
|
||||
result = <_.LoDashArrayWrapper<string>>_(_).functions();
|
||||
result = <_.LoDashArrayWrapper<string>>_(_).methods();
|
||||
|
||||
result = <number>_.get({ 'a': 1, 'b': 2, 'c': 3 }, 'b');
|
||||
// _.get
|
||||
result = <number>_.get<number>({ 'a': [{ 'b': { 'c': 3 } }] }, 'a[0].b.c');
|
||||
// → 3
|
||||
result = <number>_.get<number>({ 'a': [{ 'b': { 'c': 3 } }] }, ['a', '0', 'b', 'c']);
|
||||
// → 3
|
||||
result = <string>_.get<string>({ 'a': [{ 'b': { 'c': 3 } }] }, 'a.b.c', 'default');
|
||||
// → 'default'
|
||||
|
||||
result = <number>_({ 'a': [{ 'b': { 'c': 3 } }] }).get<number>('a[0].b.c');
|
||||
// → 3
|
||||
result = <number>_({ 'a': [{ 'b': { 'c': 3 } }] }).get<number>(['a', '0', 'b', 'c']);
|
||||
// → 3
|
||||
result = <string>_({ 'a': [{ 'b': { 'c': 3 } }] }).get<string>('a.b.c', 'default');
|
||||
// → 'default'
|
||||
|
||||
result = <boolean>_.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b');
|
||||
|
||||
|
||||
Vendored
+11
-2
@@ -5756,12 +5756,21 @@ declare module _ {
|
||||
* @param defaultValue The value returned if the resolved value is undefined.
|
||||
* @return Returns the resolved value.
|
||||
**/
|
||||
get<T>(object : Object,
|
||||
path:string|string[],
|
||||
get<T>(object: Object,
|
||||
path: string|string[],
|
||||
defaultValue?:T
|
||||
): T;
|
||||
}
|
||||
|
||||
interface LoDashObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.get
|
||||
**/
|
||||
get<TResult>(path: string|string[],
|
||||
defaultValue?: TResult
|
||||
): TResult;
|
||||
}
|
||||
|
||||
//_.has
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user