From b687009d330c33686f5909f022e6304ce25cb96a Mon Sep 17 00:00:00 2001 From: Brian Zengel Date: Sun, 20 Oct 2013 12:43:35 -0400 Subject: [PATCH] added _.has definition --- lodash/lodash-tests.ts | 4 +++- lodash/lodash.d.ts | 18 +++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 92e7a1f943..dfe0131593 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -579,7 +579,9 @@ _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { }); _.functions(_); -_.methods(_); + _.methods(_); + +_.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); var mergeNames = { 'stooges': [ diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index b8a3d28b02..6252417a82 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -2330,6 +2330,15 @@ declare module _ { **/ export function methods(object: any): string[]; + /** + * 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. + **/ + export function has(object: any, property: string): boolean; + /** * Recursively merges own enumerable properties of the source object(s), that don't resolve * to undefined into the destination object. Subsequent sources will overwrite property @@ -2551,15 +2560,6 @@ declare module _ { **/ export function tap(object: T, intercepter: Function): T; - /** - * Does the object contain the given key? Identical to object.hasOwnProperty(key), but uses a safe - * reference to the hasOwnProperty function, in case it's been overridden accidentally. - * @param object Object to check for `key`. - * @param key The key to check for on `object`. - * @return True if `key` is a property on `object`, otherwise false. - **/ - export function has(object: any, key: string): boolean; - /** * Performs an optimized deep comparison between the two objects, * to determine if they should be considered equal.