CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
isPropertyAccessible.ts20 linesDownload Raw Back to utils
1/**2 * A function that validates if property access is possible on an object3 * without throwing. It returns `true` if the property access is possible4 * and `false` otherwise.5 *6 * Environments like miniflare will throw on property access on certain objects7 * like Request and Response, for unimplemented properties.8 */9export function isPropertyAccessible<Obj extends Record<string, any>>(10  obj: Obj,11  key: keyof Obj12) {13  try {14    obj[key]15    return true16  } catch {17    return false18  }19}20 
basant307/AI_Governance_Project · CoolFace