@web3r/flowerkit
Version:
Tree-shakable JavaScript and TypeScript utility library for frontend/browser apps: DOM, events, arrays, objects, strings, date, JSON, and network helpers (ESM/CJS, SSR-friendly).
1 lines • 1.66 kB
Source Map (JSON)
{"version":3,"file":"index.cjs","sources":[""],"sourcesContent":["export type TIsObjHasOwnPropArgs = Parameters<typeof isObjHasOwnProp>;\r\n\r\nexport type TIsObjHasOwnPropReturn = ReturnType<typeof isObjHasOwnProp>;\r\n\r\n/**\r\n * Checks if an object has own property\r\n * @param {object} obj Source object\r\n * @param {PropertyKey} prop Property name\r\n * @see https://eslint.org/docs/latest/rules/no-prototype-builtins\r\n * @returns {boolean} True if own property exists\r\n * @throws {TypeError} isObjHasOwnProp: obj must be an object\r\n * @throws {TypeError} isObjHasOwnProp: prop must be a string|number|symbol\r\n * @example\r\n * // How to check if an object has property without calling method directly?\r\n * const obj = { foo: \"bar\" };\r\n * const isHasOwnProp = isObjHasOwnProp(obj, \"foo\");\r\n * console.log(isHasOwnProp); // => true\r\n */\r\nexport const isObjHasOwnProp = (obj: unknown, prop: PropertyKey): boolean => {\r\n if (obj === null || typeof obj !== \"object\") {\r\n throw new TypeError(\"isObjHasOwnProp: obj must be an object\");\r\n }\r\n if (typeof prop !== \"string\" && typeof prop !== \"number\" && typeof prop !== \"symbol\") {\r\n throw new TypeError(\"isObjHasOwnProp: prop must be a string|number|symbol\");\r\n }\r\n return Object.prototype.hasOwnProperty.call(obj, prop);\r\n};\r\n"],"names":["isObjHasOwnProp","obj","prop","TypeError","Object","prototype","hasOwnProperty","call"],"mappings":";;;;;;;;;;;;;;SAkBaA,gBAAkBA,CAACC,IAAcC,QAC5C,GAAID,MAAQ,aAAeA,MAAQ,SACjC,MAAM,IAAIE,UAAU,0CAEtB,UAAWD,OAAS,iBAAmBA,OAAS,iBAAmBA,OAAS,SAC1E,MAAM,IAAIC,UAAU,wDAEtB,OAAOC,OAAOC,UAAUC,eAAeC,KAAKN,IAAKC"}