Made sequential modifiers lazy

This commit is contained in:
thepaperpilot 2022-07-26 18:17:08 -05:00
parent ad89cc4933
commit 2850216934

View file

@ -206,7 +206,7 @@ export function createExponentialModifier<
* Takes an array of modifiers and applies and reverses them in order.
* Modifiers that are not enabled will not be applied nor reversed.
* Also joins their descriptions together.
* @param modifiers The modifiers to perform sequentially.
* @param modifiersFunc The modifiers to perform sequentially.
* @see {@link createModifierSection}.
*/
export function createSequentialModifier<
@ -214,7 +214,10 @@ export function createSequentialModifier<
S = T extends WithRequired<Modifier, "revert">[]
? WithRequired<Modifier, "description" | "revert">
: Omit<WithRequired<Modifier, "description">, "revert">
>(...modifiers: T): S {
>(modifiersFunc: () => T): S {
return createLazyProxy(() => {
const modifiers = modifiersFunc();
return {
apply: (gain: DecimalSource) =>
modifiers
@ -238,7 +241,8 @@ export function createSequentialModifier<
).map(renderJSX)}
</>
))
} as unknown as S;
};
}) as unknown as S;
}
/**