remeda
Version:
A utility library for JavaScript and Typescript.
1 lines • 826 B
Source Map (JSON)
{"version":3,"file":"isPromise.cjs","names":[],"sources":["../src/isPromise.ts"],"sourcesContent":["import type { NarrowedTo } from \"./internal/types/NarrowedTo\";\n\n/**\n * A function that checks if the passed parameter is a Promise and narrows its type accordingly.\n *\n * @param data - The variable to check.\n * @returns True if the passed input is a Promise, false otherwise.\n * @signature\n * R.isPromise(data)\n * @example\n * R.isPromise(Promise.resolve(5)) //=> true\n * R.isPromise(Promise.reject(5)) //=> true\n * R.isPromise('somethingElse') //=> false\n * @category Guard\n */\nexport function isPromise<T>(\n data: Readonly<PromiseLike<unknown>> | T,\n): data is NarrowedTo<T, PromiseLike<unknown>> {\n return data instanceof Promise;\n}\n"],"mappings":"AAeA,SAAgB,EACd,EAC6C,CAC7C,OAAO,aAAgB"}