patch.js
function compare(a,b,options) {
    debug('compare %j,%j options: %j', a, b, options);

    options = Options.addDefaults(options);

    debug('compare - options %j', options);
    if (a === b)
        return ops.NOP;
    if (b === undefined) 
        return ops.DEL;
    if (a === undefined) 
        return new ops.Rpl(b);

    if (typeof a === 'object' && typeof b === 'object') {
        if (utils.isArrayLike(a) && utils.isArrayLike(b)) { 
            if (options.map) {
                return _compareMaps(a,b,options);
            } else  {
                return _compareArrays(a,b,options);
            }
        } else if (a instanceof Map && b instanceof Map) {
            return _compareMaps(a,b,options);
        } else if (a.constructor === b.constructor) { // This isn't quite right, we can merge objects with a common base class
            return _compareObjects(a,b,options);
        } 
    }

    return new ops.Rpl(b);
}
function compare(a,b,options) {
    debug('compare %j,%j options: %j', a, b, options);

    options = Options.addDefaults(options);

    debug('compare - options %j', options);
    if (a === b)
        return ops.NOP;
    if (b === undefined) 
        return ops.DEL;
    if (a === undefined) 
        return new ops.Rpl(b);

    if (typeof a === 'object' && typeof b === 'object') {
        if (utils.isArrayLike(a) && utils.isArrayLike(b)) { 
            if (options.map) {
                return _compareMaps(a,b,options);
            } else  {
                return _compareArrays(a,b,options);
            }
        } else if (a instanceof Map && b instanceof Map) {
            return _compareMaps(a,b,options);
        } else if (a.constructor === b.constructor) { // This isn't quite right, we can merge objects with a common base class
            return _compareObjects(a,b,options);
        } 
    }

    return new ops.Rpl(b);
}
Compare two object to produce a patch object.

@param a First object for comparison
@param b Second object for comparison
@param options (optional) options to control comparison operation (see {@link DEFAULT_OPTIONS})