UNPKG

@frauschert/ts-guard

Version:

ts-guard is a typescript library that provides composable type guards. Its inspired by zod but focusses only on type guards and is more lightweight.

18 lines 587 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isPromise = isPromise; function isPromise(valueGuard) { return (value) => { if (!(typeof value === "object" && value !== null && typeof value.then === "function" && typeof value.catch === "function")) { return false; } if (!valueGuard) { return true; } const promise = value; return promise.then((resolvedValue) => valueGuard(resolvedValue), () => false); }; } //# sourceMappingURL=isPromise.js.map