{"version":3,"file":"intersectionWith.cjs","names":["purryFromLazy","SKIP_ITEM"],"sources":["../src/intersectionWith.ts"],"sourcesContent":["import { purryFromLazy } from \"./internal/purryFromLazy\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport { SKIP_ITEM } from \"./internal/utilityEvaluators\";\n\ntype Comparator<TFirst, TSecond> = (a: TFirst, b: TSecond) => boolean;\n\n/**\n * Returns a list of intersecting values based on a custom\n * comparator function that compares elements of both arrays.\n *\n * @param array - The source array.\n * @param other - The second array.\n * @param comparator - The custom comparator.\n * @signature\n *    intersectionWith(array, other, comparator)\n * @example\n *    intersectionWith(\n *      [\n *        { id: 1, name: 'Ryan' },\n *        { id: 3, name: 'Emma' },\n *      ],\n *      [3, 5],\n *      (a, b) => a.id === b,\n *    ) // => [{ id: 3, name: 'Emma' }]\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function intersectionWith<TFirst, TSecond>(\n  array: readonly TFirst[],\n  other: readonly TSecond[],\n  comparator: Comparator<TFirst, TSecond>,\n): TFirst[];\n\n/**\n * Returns a list of intersecting values based on a custom\n * comparator function that compares elements of both arrays.\n *\n * @param other - The second array.\n * @param comparator - The custom comparator.\n * @signature\n *    intersectionWith(other, comparator)(array)\n * @example\n *    intersectionWith(\n *      [3, 5],\n *      (a, b) => a.id === b\n *      )([\n *        { id: 1, name: 'Ryan' },\n *        { id: 3, name: 'Emma' },\n *      ]); // => [{ id: 3, name: 'Emma' }]\n * @dataLast\n * @lazy\n * @category Array\n */\nexport function intersectionWith<TFirst, TSecond>(\n  other: readonly TSecond[],\n  /**\n   * Type inference doesn't work properly for the comparator's first parameter\n   * in data last variant.\n   */\n  comparator: Comparator<TFirst, TSecond>,\n): (array: readonly TFirst[]) => TFirst[];\n\nexport function intersectionWith(...args: readonly unknown[]): unknown {\n  return purryFromLazy(lazyImplementation, args);\n}\n\nconst lazyImplementation =\n  <TFirst, TSecond>(\n    other: readonly TSecond[],\n    comparator: Comparator<TFirst, TSecond>,\n  ): LazyEvaluator<TFirst> =>\n  (value) =>\n    other.some((otherValue) => comparator(value, otherValue))\n      ? { done: false, hasNext: true, next: value }\n      : SKIP_ITEM;\n"],"mappings":"iKA+DA,SAAgB,EAAiB,GAAG,EAAmC,CACrE,OAAOA,EAAAA,EAAc,EAAoB,EAAK,CAGhD,MAAM,GAEF,EACA,IAED,GACC,EAAM,KAAM,GAAe,EAAW,EAAO,EAAW,CAAC,CACrD,CAAE,KAAM,GAAO,QAAS,GAAM,KAAM,EAAO,CAC3CC,EAAAA"}