lodash: changed _.has() method

This commit is contained in:
Ilya Mochalov
2015-09-04 01:21:11 +05:00
parent 7c228c0930
commit 8a5c6d0063
2 changed files with 23 additions and 7 deletions

View File

@@ -1495,7 +1495,15 @@ result = <number>_({ 'a': [{ 'b': { 'c': 3 } }] }).get<number>(['a', '0', 'b', '
result = <string>_({ 'a': [{ 'b': { 'c': 3 } }] }).get<string>('a.b.c', 'default');
// → 'default'
result = <boolean>_.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b');
// _.has
result = <boolean>_.has({}, '');
result = <boolean>_.has({}, 42);
result = <boolean>_.has({}, true);
result = <boolean>_.has({}, ['', 42, true]);
result = <boolean>_({}).has('');
result = <boolean>_({}).has(42);
result = <boolean>_({}).has(true);
result = <boolean>_({}).has(['', 42, true]);
interface FirstSecond {
first: string;

20
lodash/lodash.d.ts vendored
View File

@@ -7135,12 +7135,20 @@ declare module _ {
//_.has
interface LoDashStatic {
/**
* 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, path: string|string[]): boolean;
* Checks if path is a direct property.
*
* @param object The object to query.
* @param path The path to check.
* @return Returns true if path is a direct property, else false.
*/
has(object: any, path: string|number|boolean|Array<string|number|boolean>): boolean;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.has
*/
has(path: string|number|boolean|Array<string|number|boolean>): boolean;
}
//_.invert