Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/fourtyone11/origin-hugo-theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'assets/node_modules/read-pkg/node_modules/type-fest/source/promisable.d.ts')
-rw-r--r--assets/node_modules/read-pkg/node_modules/type-fest/source/promisable.d.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/assets/node_modules/read-pkg/node_modules/type-fest/source/promisable.d.ts b/assets/node_modules/read-pkg/node_modules/type-fest/source/promisable.d.ts
new file mode 100644
index 0000000..71242a5
--- /dev/null
+++ b/assets/node_modules/read-pkg/node_modules/type-fest/source/promisable.d.ts
@@ -0,0 +1,23 @@
+/**
+Create a type that represents either the value or the value wrapped in `PromiseLike`.
+
+Use-cases:
+- A function accepts a callback that may either return a value synchronously or may return a promised value.
+- This type could be the return type of `Promise#then()`, `Promise#catch()`, and `Promise#finally()` callbacks.
+
+Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/31394) if you want to have this type as a built-in in TypeScript.
+
+@example
+```
+import {Promisable} from 'type-fest';
+
+async function logger(getLogEntry: () => Promisable<string>): Promise<void> {
+ const entry = await getLogEntry();
+ console.log(entry);
+}
+
+logger(() => 'foo');
+logger(() => Promise.resolve('bar'));
+```
+*/
+export type Promisable<T> = T | PromiseLike<T>;