@itwin/access-control-client
Version:
Access control client for the iTwin platform
22 lines • 979 B
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/**
* Type guard to check if an object has a specific property and narrows the type to Record<string, unknown>
* @param obj - Unknown object to check for property existence
* @param prop - Property key name to check for
* @returns True if the object has the specified property, false otherwise
*
* @example
* ```typescript
* const data: unknown = { name: "John", age: 30 };
* if (hasProperty(data, "name")) {
* console.log(data.name); // ✅ Type-safe access
* }
* ```
*/
export function hasProperty(obj, prop) {
return typeof obj === "object" && obj !== null && prop in obj;
}
//# sourceMappingURL=typeUtils.js.map