===== ISTEM =====
Solve the following programming task.

TASK: Object Diff

Write a function 'objectDiff(obj1, obj2)' that compares two JavaScript objects and returns only the changed properties as [oldValue, newValue].

STARTER CODE (javascript):
function objectDiff(obj1, obj2) {
  // Write your code here
}

module.exports = { objectDiff };


RULES:
- Keep the function name and signature EXACTLY as given.
- Return working code only. No explanations.
- Put the code in a single ``` block.
- Try to solve it first. If you genuinely cannot, write only this single
  line instead of producing faulty code: CANNOT_SOLVE

===== HAM YANIT =====
```javascript
function objectDiff(obj1, obj2) {
  const hasOwn = (obj, key) =>
    Object.prototype.hasOwnProperty.call(obj, key);

  function deepEqual(a, b, seen = new WeakMap()) {
    if (Object.is(a, b)) return true;

    if (
      a === null || b === null ||
      typeof a !== "object" || typeof b !== "object"
    ) {
      return false;
    }

    if (Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) {
      return false;
    }

    if (a instanceof Date) {
      return Object.is(a.getTime(), b.getTime());
    }

    if (a instanceof RegExp) {
      return a.source === b.source && a.flags === b.flags;
    }

    if (Array.isArray(a) && a.length !== b.length) return false;

    let partners = seen.get(a);
    if (partners && partners.has(b)) return true;
    if (!partners) {
      partners = new WeakSet();
      seen.set(a, partners);
    }
    partners.add(b);

    const keysA = Object.keys(a);
    const keysB = Object.keys(b);

    if (keysA.length !== keysB.length) return false;

    return keysA.every(
      key => hasOwn(b, key) && deepEqual(a[key], b[key], seen)
    );
  }

  const result = {};
  const keys = new Set([...Object.keys(obj1), ...Object.keys(obj2)]);

  for (const key of keys) {
    const inFirst = hasOwn(obj1, key);
    const inSecond = hasOwn(obj2, key);
    const oldValue = inFirst ? obj1[key] : undefined;
    const newValue = inSecond ? obj2[key] : undefined;

    if (inFirst !== inSecond || !deepEqual(oldValue, newValue)) {
      Object.defineProperty(result, key, {
        value: [oldValue, newValue],
        enumerable: true,
        configurable: true,
        writable: true
      });
    }
  }

  return result;
}

module.exports = { objectDiff };
```