UNPKG

@daiso-tech/core

Version:

The library offers flexible, framework-agnostic solutions for modern web applications, built on adaptable components that integrate seamlessly with popular frameworks like Next Js.

52 lines 1.25 kB
/** * @module Utilities */ import { isNullable } from "../../utilities/functions/is-nullable.js"; import { getConstructorName } from "../../utilities/functions/get-constructor-name.js"; /** * @internal */ export function isInvokableObject(invokable) { const invokable_ = invokable; return !isNullable(invokable) && typeof invokable_["invoke"] === "function"; } /** * @internal */ export function isInvokableFn(invokable) { return typeof invokable === "function"; } /** * @internal */ export function isInvokable(invokable) { return isInvokableObject(invokable) || isInvokableFn(invokable); } /** * @internal */ export function resolveInvokable(invokable) { if (isInvokableObject(invokable)) { return (...args) => invokable.invoke(...args); } return (...args) => invokable(...args); } /** * @internal */ export function callInvokable(invokable, ...args) { if (isInvokableObject(invokable)) { return invokable.invoke(...args); } return invokable(...args); } /** * @internal */ export function getInvokableName(invokable) { if (isInvokableFn(invokable)) { return invokable.name; } return getConstructorName(invokable); } //# sourceMappingURL=invokable.js.map