chore: refactor is_promise function (#9794)

* Refactor is_promise function

* Update packages/svelte/src/internal/common.js

---------

Co-authored-by: Mike <prince-poley@yandex.ru>
Co-authored-by: Rich Harris <hello@rich-harris.dev>
pull/9817/head
Михаил Туник 1 year ago committed by GitHub
parent dcdd645480
commit edc569e73b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -10,11 +10,7 @@ export const EMPTY_FUNC = () => {};
* @returns {value is PromiseLike<T>} * @returns {value is PromiseLike<T>}
*/ */
export function is_promise(value) { export function is_promise(value) {
return ( return typeof value?.then === 'function';
!!value &&
(typeof value === 'object' || typeof value === 'function') &&
typeof (/** @type {any} */ (value).then) === 'function'
);
} }
/** @param {Array<() => void>} arr */ /** @param {Array<() => void>} arr */

Loading…
Cancel
Save