lib/stub.js
// convert functions into object/method normal form
convert functions into object/method normal form
convert functions into object / method normal form
function normalizeArgs( object, methodName, overrideMethod ) {
    if (_typeof(overrideMethod) === 'object' && arguments[3] === undefined) overrideMethod = undefined;
    if (object != null && _typeof(methodName) === 'string') {
        return { ob: object, me: methodName, ov: overrideMethod };
    }
    if (object == null && _typeof(methodName) === 'function') {
        return { ob: { fn: methodName }, me: 'fn', ov: overrideMethod };
    }
    if (object == null && methodName == null) {
        return { ob: { fn: object }, me: 'fn', ov: null };
    }
    if (_typeof(object) === 'function' && _typeof(methodName) === 'function') {
        return { ob: { fn: object }, me: 'fn', ov: methodName };
    }
    if (_typeof(object) === 'function' && methodName == null && (overrideMethod == null || _typeof(overrideMethod) === 'function')) {
        return { ob: { fn: object }, me: 'fn', ov: overrideMethod };
    }
    if (object == null) throw new Error('null object to spy/stub');
    throw new Error('invalid arguments to spy/stub: ' + _typeof(object) + ',' + _typeof(methodName) + ',' + _typeof(overrideMethod));
    function _typeof(v) {
        var type = typeof v;
        return type === 'object' && !v ? 'null' : type;
    }
}
function normalizeArgs ( object , methodName , overrideMethod ) { if ( _typeof ( overrideMethod ) === 'object' && arguments [ 3 ] === undefined ) overrideMethod = undefined ; if ( object != null && _typeof ( methodName ) === 'string' ) { return { ob : object , me : methodName , ov : overrideMethod } ; } if ( object == null && _typeof ( methodName ) === 'function' ) { return { ob : { fn : methodName } , me : 'fn' , ov : overrideMethod } ; } if ( object == null && methodName == null ) { return { ob : { fn : object } , me : 'fn' , ov : null } ; } if ( _typeof ( object ) === 'function' && _typeof ( methodName ) === 'function' ) { return { ob : { fn : object } , me : 'fn' , ov : methodName } ; } if ( _typeof ( object ) === 'function' && methodName == null && ( overrideMethod == null || _typeof ( overrideMethod ) === 'function' ) ) { return { ob : { fn : object } , me : 'fn' , ov : overrideMethod } ; } if ( object == null ) throw new Error ( 'null object to spy/stub' ) ; throw new Error ( 'invalid arguments to spy/stub: ' + _typeof ( object ) + ',' + _typeof ( methodName ) + ',' + _typeof ( overrideMethod ) ) ; function _typeof ( v ) { var type = typeof v ; return type === 'object' && ! v ? 'null' : type ; } }
convert functions into object/method normal form
convert functions into object / method normal form
// backward compat: allow an obsolete `options` last parameter // named method on anything that might have a property // backward compat: spy(null, func) // no args // function and override // backward compat: function and optional archaic override