import { SEMAPHORE } from "@thi.ng/api/api";
import { compR } from "./compr.js";
import { __iter } from "./iterator.js";
function dedupe(...args) {
  return __iter(dedupe, args) || ((rfn) => {
    const r = rfn[2];
    const equiv = args[0];
    let prev = SEMAPHORE;
    return compR(
      rfn,
      equiv ? (acc, x) => {
        acc = prev !== SEMAPHORE && equiv(prev, x) ? acc : r(acc, x);
        prev = x;
        return acc;
      } : (acc, x) => {
        acc = prev === x ? acc : r(acc, x);
        prev = x;
        return acc;
      }
    );
  });
}
export {
  dedupe
};
