From cd9004ce5badc66b6e323cffcf091bc08da73706 Mon Sep 17 00:00:00 2001 From: "Michael \"Z\" Goddard" Date: Fri, 3 Nov 2017 11:40:20 -0400 Subject: [PATCH] Write src/engine/execute so it can be optimized Testing with implicitly casted `value` and `value.then` is deoptimizing isPromise, which deoptimizes execute. In this case deoptimizing means that the JavaScript VM cannot compile the functions into a form that can be run faster. --- src/engine/execute.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/engine/execute.js b/src/engine/execute.js index a4bf76b2a..24864592f 100644 --- a/src/engine/execute.js +++ b/src/engine/execute.js @@ -8,7 +8,11 @@ const {Map} = require('immutable'); * @return {boolean} True if the value appears to be a Promise. */ const isPromise = function (value) { - return value && value.then && typeof value.then === 'function'; + return ( + value !== null && + typeof value === 'object' && + typeof value.then === 'function' + ); }; /**