feat: refactoring project

This commit is contained in:
Carlos
2024-11-23 14:56:07 -05:00
parent f0c2a50c18
commit 1c6db5818d
2351 changed files with 39323 additions and 60326 deletions

View File

@@ -45,7 +45,7 @@ class SerializerMiddleware {
* @param {any=} serializedValue serialized value
* @returns {function(): Promise<any> | any} lazy function
*/
static createLazy(value, target, options = {}, serializedValue) {
static createLazy(value, target, options = {}, serializedValue = undefined) {
if (SerializerMiddleware.isLazy(value, target)) return value;
const fn = typeof value === "function" ? value : () => value;
fn[LAZY_TARGET] = target;
@@ -62,24 +62,24 @@ class SerializerMiddleware {
static isLazy(fn, target) {
if (typeof fn !== "function") return false;
const t = fn[LAZY_TARGET];
return target ? t === target : !!t;
return target ? t === target : Boolean(t);
}
/**
* @param {function(): Promise<any> | any} fn lazy function
* @returns {object} options
* @returns {object | undefined} options
*/
static getLazyOptions(fn) {
if (typeof fn !== "function") return undefined;
if (typeof fn !== "function") return;
return /** @type {any} */ (fn).options;
}
/**
* @param {function(): Promise<any> | any} fn lazy function
* @returns {any} serialized value
* @returns {any | undefined} serialized value
*/
static getLazySerializedValue(fn) {
if (typeof fn !== "function") return undefined;
if (typeof fn !== "function") return;
return fn[LAZY_SERIALIZED_VALUE];
}
@@ -112,9 +112,10 @@ class SerializerMiddleware {
}
/**
* @template T
* @param {function(): Promise<any> | any} lazy lazy function
* @param {function(any): Promise<any> | any} deserialize deserialize function
* @returns {function(): Promise<any> | any} new lazy
* @param {function(T): Promise<T> | T} deserialize deserialize function
* @returns {function(): Promise<T> | T} new lazy
*/
static deserializeLazy(lazy, deserialize) {
const fn = memoize(() => {