@thisisagile/easy
Version:
Straightforward library for building domain-driven microservice architectures
36 lines (34 loc) • 998 B
JavaScript
import {
isPrimitive
} from "./chunk-DXQSIBC7.mjs";
import {
isFunc
} from "./chunk-PIRWVOO2.mjs";
import {
isDefined,
isFunction
} from "./chunk-DEJ7A5PY.mjs";
// src/types/Constructor.ts
var isConstructor = (c) => (isDefined(c) && isFunc(c) && c.prototype && c.prototype.constructor) === c;
var isInstance = (ctor, o) => isFunction(ctor) && o instanceof ctor;
var ofConstruct = (c, ...args) => isConstructor(c) ? new c(...args) : isFunc(c) ? c(...args) : c;
var toName = (subject, postfix = "") => subject?.constructor?.name?.replace(postfix, "").toLowerCase() ?? "";
var isPromise = (value) => {
return value instanceof Promise;
};
var on = (t, f) => {
const result = f(t);
return isPromise(result) ? result.then(() => t) : t;
};
var use = (t, f) => f(t);
var ifA = (c, t, alt) => !isPrimitive(t) && t instanceof c ? t : alt ? ifA(c, alt) : void 0;
export {
isConstructor,
isInstance,
ofConstruct,
toName,
on,
use,
ifA
};
//# sourceMappingURL=chunk-ZPNFXK7Y.mjs.map