packages/shared/util/Recoil_isPromise.js (6 lines of code) (raw):
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @emails oncall+recoil
* @flow strict
* @format
*/
'use strict';
declare function isPromise(p: mixed): boolean %checks(p instanceof Promise);
// Split declaration and implementation to allow this function to pretend to
// check for actual instance of Promise instead of something with a `then`
// method.
// eslint-disable-next-line no-redeclare
function isPromise(p: $FlowFixMe): boolean {
return !!p && typeof p.then === 'function';
}
module.exports = isPromise;