{"version":3,"file":"forEachObj.cjs","names":["purry"],"sources":["../src/forEachObj.ts"],"sourcesContent":["import type { EnumerableStringKeyOf } from \"./internal/types/EnumerableStringKeyOf\";\nimport type { EnumerableStringKeyedValueOf } from \"./internal/types/EnumerableStringKeyedValueOf\";\nimport { purry } from \"./purry\";\n\n/**\n * Iterate an object using a defined callback function.\n *\n * The dataLast version returns the original object (instead of not returning\n * anything (`void`)) to allow using it in a pipe. The returned object is the\n * same reference as the input object, and not a shallow copy of it!\n *\n * @param data - The object who'se entries would be iterated on.\n * @param callbackfn - A function to execute for each element in the array.\n * @signature\n *    forEachObj(object, fn)\n * @example\n *    forEachObj({a: 1}, (val, key, obj) => {\n *      console.log(`${key}: ${val}`)\n *    }) // \"a: 1\"\n * @dataFirst\n * @category Object\n */\nexport function forEachObj<T extends object>(\n  data: T,\n  callbackfn: (\n    value: EnumerableStringKeyedValueOf<T>,\n    key: EnumerableStringKeyOf<T>,\n    obj: T,\n  ) => void,\n): void;\n\n/**\n * Iterate an object using a defined callback function.\n *\n * The dataLast version returns the original object (instead of not returning\n * anything (`void`)) to allow using it in a pipe. The returned object is the\n * same reference as the input object, and not a shallow copy of it!\n *\n * @param callbackfn - A function to execute for each element in the array.\n * @returns The original object (the ref itself, not a shallow copy of it).\n * @signature\n *    forEachObj(fn)(object)\n * @example\n *    pipe(\n *      {a: 1},\n *      forEachObj((val, key) => console.log(`${key}: ${val}`))\n *    ) // \"a: 1\"\n * @dataLast\n * @category Object\n */\nexport function forEachObj<T extends object>(\n  callbackfn: (\n    value: EnumerableStringKeyedValueOf<T>,\n    key: EnumerableStringKeyOf<T>,\n    obj: T,\n  ) => void,\n): (object: T) => T;\n\nexport function forEachObj(...args: readonly unknown[]): unknown {\n  return purry(forEachObjImplementation, args);\n}\n\nfunction forEachObjImplementation<T extends object>(\n  data: T,\n  fn: (value: unknown, key: string, data: T) => void,\n): T {\n  for (const [key, value] of Object.entries(data)) {\n    fn(value, key, data);\n  }\n  return data;\n}\n"],"mappings":"kGA0DA,SAAgB,EAAW,GAAG,EAAmC,CAC/D,OAAOA,EAAAA,MAAM,EAA0B,EAAK,CAG9C,SAAS,EACP,EACA,EACG,CACH,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,EAAK,CAC7C,EAAG,EAAO,EAAK,EAAK,CAEtB,OAAO"}