MCPcopy
hub / github.com/webpack/webpack / createLazy

Method createLazy

lib/serialization/SerializerMiddleware.js:71–85  ·  view source on GitHub ↗

* Creates a lazy from the provided value. * @template TLazyInputValue * @template TLazyOutputValue * @template {LazyTarget} TLazyTarget * @template {LazyOptions | undefined} TLazyOptions * @param {TLazyInputValue | (() => TLazyInputValue)} value contained value or function to value * @pa

(
		value,
		target,
		options = /** @type {TLazyOptions} */ ({}),
		serializedValue = undefined
	)

Source from the content-addressed store, hash-verified

69 * @returns {LazyFunction<TLazyInputValue, TLazyOutputValue, TLazyTarget, TLazyOptions>} lazy function
70 */
71 static createLazy(
72 value,
73 target,
74 options = /** @type {TLazyOptions} */ ({}),
75 serializedValue = undefined
76 ) {
77 if (SerializerMiddleware.isLazy(value, target)) return value;
78 const fn =
79 /** @type {LazyFunction<TLazyInputValue, TLazyOutputValue, TLazyTarget, TLazyOptions>} */
80 (typeof value === "function" ? value : () => value);
81 fn[LAZY_TARGET] = target;
82 fn.options = options;
83 fn[LAZY_SERIALIZED_VALUE] = serializedValue;
84 return fn;
85 }
86
87 /**
88 * Checks whether this serializer middleware is lazy.

Callers 5

deserializeFunction · 0.80
buffersSerializerFunction · 0.80
serialization.jsFile · 0.80

Calls 1

isLazyMethod · 0.45

Tested by

no test coverage detected