{"version":3,"file":"index.mjs","sources":[""],"sourcesContent":["export type TGetObjWithPickedPropsArgs = Parameters<typeof getObjWithPickedProps>;\n\nexport type TGetObjWithPickedPropsReturn = ReturnType<typeof getObjWithPickedProps>;\n\n/**\n * Creates an object containing selected own properties.\n * @template T,TKey\n * @param {T} obj Source object\n * @param {TKey[]} keys Keys to copy\n * @returns {Pick<T, TKey>} Picked properties\n * @throws {TypeError} getObjWithPickedProps: obj must be a plain object\n * @throws {TypeError} getObjWithPickedProps: keys must be an array\n * @example\n * getObjWithPickedProps({ id: 1, name: \"Ada\" }, [ \"id\" ]); // { id: 1 }\n * @example\n * // Select safe fields for a public user profile\n * const publicProfile = getObjWithPickedProps(user, [ \"id\", \"displayName\", \"avatarUrl\" ]);\n */\nexport const getObjWithPickedProps = <T extends object, TKey extends keyof T>(\n  obj: T,\n  keys: readonly TKey[]\n): Pick<T, TKey> => {\n  if (!obj || typeof obj !== \"object\" || Array.isArray(obj)) {\n    throw new TypeError(\"getObjWithPickedProps: obj must be a plain object\");\n  }\n  if (!Array.isArray(keys)) {\n    throw new TypeError(\"getObjWithPickedProps: keys must be an array\");\n  }\n\n  const result = {} as Pick<T, TKey>;\n  (keys as readonly TKey[]).forEach((key) => {\n    if (Object.prototype.hasOwnProperty.call(obj, key)) {\n      (result as Record<PropertyKey, unknown>)[key] = (obj as Record<PropertyKey, unknown>)[key];\n    }\n  });\n  return result;\n};\n"],"names":["getObjWithPickedProps","obj","keys","Array","isArray","TypeError","result","forEach","key","Object","prototype","hasOwnProperty","call"],"mappings":"MAkBaA,sBAAwB,CACnCC,IACAC,QAEA,IAAKD,YAAcA,MAAQ,UAAYE,MAAMC,QAAQH,KACnD,MAAM,IAAII,UAAU,qDAEtB,IAAKF,MAAMC,QAAQF,MACjB,MAAM,IAAIG,UAAU,gDAGtB,MAAMC,OAAS,CAAA,EACdJ,KAAyBK,QAASC,MACjC,GAAIC,OAAOC,UAAUC,eAAeC,KAAKX,IAAKO,KAC3CF,OAAwCE,KAAQP,IAAqCO,OAG1F,OAAOF"}