@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 • 2 kB
Source Map (JSON)
{"version":3,"file":"index.mjs","sources":[""],"sourcesContent":["export type TIsObjPrototypeOfArgs = Parameters<typeof isObjPrototypeOf>;\r\n\r\nexport type TIsObjPrototypeOfReturn = ReturnType<typeof isObjPrototypeOf>;\r\n\r\n/**\r\n * Checks whether a given object exists in the prototype chain of another value.\r\n *\r\n * This is a safe wrapper around Object.prototype.isPrototypeOf that validates inputs and orks with non-plain objects and primitives (primitives always return false)\r\n * @param {object} prototype The potential prototype object\r\n * @param {unknown} value The value whose prototype chain is checked\r\n * @returns {boolean} True if `prototype` is in the prototype chain of `value`\r\n * @throws {TypeError} isObjPrototypeOf: prototype must be a non-null object\r\n * @example\r\n * // Basic usage\r\n * const proto = {};\r\n * const obj = Object.create(proto);\r\n * isObjPrototypeOf(proto, obj); // => true\r\n *\r\n * @example\r\n * // With classes\r\n * class A {}\r\n * class B extends A {}\r\n * const b = new B();\r\n * isObjPrototypeOf(A.prototype, b); // => true\r\n *\r\n * @example\r\n * // Primitives\r\n * isObjPrototypeOf(Object.prototype, 123); // => false\r\n */\r\nexport const isObjPrototypeOf = (prototype: object, value: unknown): boolean => {\r\n if (prototype === null || typeof prototype !== \"object\" && typeof prototype !== \"function\") {\r\n throw new TypeError(\"isObjPrototypeOf: prototype must be a non-null object\");\r\n }\r\n if (value === null || (typeof value !== \"object\" && typeof value !== \"function\")) {\r\n return false;\r\n }\r\n return Object.prototype.isPrototypeOf.call(prototype, value);\r\n};\r\n"],"names":["isObjPrototypeOf","prototype","value","TypeError","Object","isPrototypeOf","call"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;MA6BaA,iBAAmBA,CAACC,UAAmBC,SAClD,GAAID,YAAc,aAAeA,YAAc,iBAAmBA,YAAc,WAC9E,MAAM,IAAIE,UAAU,yDAEtB,GAAID,QAAU,aAAgBA,QAAU,iBAAmBA,QAAU,WACnE,OAAO,MAET,OAAOE,OAAOH,UAAUI,cAAcC,KAAKL,UAAWC"}