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.
This commit is contained in:
Michael "Z" Goddard 2017-11-03 11:40:20 -04:00
parent ef961c5a4b
commit cd9004ce5b
No known key found for this signature in database
GPG key ID: 762CD40DD5349872

View file

@ -8,7 +8,11 @@ const {Map} = require('immutable');
* @return {boolean} True if the value appears to be a Promise. * @return {boolean} True if the value appears to be a Promise.
*/ */
const isPromise = function (value) { const isPromise = function (value) {
return value && value.then && typeof value.then === 'function'; return (
value !== null &&
typeof value === 'object' &&
typeof value.then === 'function'
);
}; };
/** /**