"use strict";
var util = require("./util.js");
var ASSERT = require("./assert.js");
var isPrimitive = util.isPrimitive;
var wrapsPrimitiveReceiver = util.wrapsPrimitiveReceiver;

module.exports = function(Promise) {
var returner = function () {
    return this;
};
var thrower = function () {
    throw this;
};

var wrapper = function (value, action) {
    if (action === THROW) {
        return function () {
            throw value;
        };
    } else if (action === RETURN) {
        return function () {
            return value;
        };
    }
    ASSERT(false);
};


Promise.prototype["return"] =
Promise.prototype.thenReturn = function (value) {
    if (wrapsPrimitiveReceiver && isPrimitive(value)) {
        return this._then(
            wrapper(value, RETURN),
            undefined,
            undefined,
            undefined,
            undefined
       );
    }
    return this._then(returner, undefined, undefined, value, undefined);
};

Promise.prototype["throw"] =
Promise.prototype.thenThrow = function (reason) {
    if (wrapsPrimitiveReceiver && isPrimitive(reason)) {
        return this._then(
            wrapper(reason, THROW),
            undefined,
            undefined,
            undefined,
            undefined
       );
    }
    return this._then(thrower, undefined, undefined, reason, undefined);
};
};

@@ -11,571 +11,200 @@
 t%22;%0A
-var util = require(%22./util.js%22);%0Avar ASSERT = require(%22./assert.js%22);%0Avar isPrimitive = util.isPrimitive;%0Avar wrapsPrimitiveReceiver = util.wrapsPrimitiveReceiver;%0A%0Amodule.exports = function(Promise) %7B%0Avar returner = function () %7B%0A    return this;%0A%7D;%0Avar thrower = function () %7B%0A    throw this;%0A%7D;%0A%0Avar wrapper = function (value, action) %7B%0A    if (action === THROW) %7B%0A        return function () %7B%0A            throw value;%0A        %7D;%0A    %7D else if (action === RETURN) %7B%0A        return function () %7B%0A            return value;%0A        %7D;%0A    %7D%0A    ASSERT(false)
+module.exports = function(Promise) %7B%0Avar es5 = require(%22./es5.js%22).isES5;%0Afunction returner() %7B%0A    return es5 ? this : this.value;%0A%7D%0Afunction thrower() %7B%0A    throw es5 ? this : this.reason
 ;%0A%7D
-;%0A
 %0A%0APr
@@ -293,60 +293,38 @@
 if (
-wrapsPrimitiveReceiver && isPrimitive(
+!es5) value = %7Bvalue: 
 value
-)) %7B%0A    
+%7D;%0A
     
@@ -354,525 +354,182 @@
     
-    wrapper(value, RETURN),%0A            undefined,%0A            undefined,%0A            undefined,%0A            undefined%0A       );%0A    %7D%0A    return this._then(returner, undefined, undefined, value, undefined);%0A%7D;%0A%0APromise.prototype%5B%22throw%22%5D =%0APromise.prototype.thenThrow = function (reason) %7B%0A    if (wrapsPrimitiveReceiver && isPrimitive(reason)) %7B%0A        return this._then(%0A            wrapper(reason, THROW),%0A            undefined,%0A            undefined,%0A            undefined,%0A            undefined%0A       );%0A    %7D
+returner, undefined, undefined, value, undefined);%0A%7D;%0A%0APromise.prototype%5B%22throw%22%5D =%0APromise.prototype.thenThrow = function (reason) %7B%0A    if (!es5) reason = %7Breason: reason%7D;
 %0A   

Simplify direct_resolve implementation