1

The part of source code is:

getAllKeys(spec).forEach(function(key) {
  if (hasOwnProperty.call(commands, key)) {
    var objectWasNextObject = object === nextObject;
    
    nextObject = commands[key](spec[key], nextObject, spec, object);
    if (objectWasNextObject && update.isEquals(nextObject, object)) {
      nextObject = object;
    }
  } else {
    // ...
  }
})

and the update.isEquals code is

update.isEquals = function(a, b) { return a === b; };

Why is nextObject = object; needed? When isEquals returns true, nextObject equals object already.

Sebastian Simon
  • 18,263
  • 7
  • 55
  • 75
Eason
  • 33
  • 5
  • The code is TypeScript now and in the [most recent commit](//github.com/kolodny/immutability-helper/blob/3dc903960b8411da84704052d511c20648c45ead/index.ts#L109), this statement still remains. The [issue](//github.com/kolodny/immutability-helper/issues/105) asking about this apparently explains this. – Sebastian Simon Oct 20 '22 at 10:01

0 Answers0