This commit is contained in:
thororen1234 2025-02-20 23:40:53 -05:00
commit 32b44e9822
No known key found for this signature in database
15 changed files with 142 additions and 74 deletions

View file

@ -20,9 +20,9 @@ export function makeLazy<T>(factory: () => T, attempts = 5): () => T {
let tries = 0;
let cache: T;
return () => {
if (!cache && attempts > tries++) {
if (cache === undefined && attempts > tries++) {
cache = factory();
if (!cache && attempts === tries)
if (cache === undefined && attempts === tries)
console.error("Lazy factory failed:", factory);
}
return cache;

View file

@ -41,7 +41,12 @@ export interface PatchReplacement {
match: string | RegExp;
/** The replacement string or function which returns the string for the patch replacement */
replace: string | ReplaceFn;
/** A function which returns whether this patch replacement should be applied */
/** Do not warn if this replacement did no changes */
noWarn?: boolean;
/**
* A function which returns whether this patch replacement should be applied.
* This is ran before patches are registered, so if this returns false, the patch will never be registered.
*/
predicate?(): boolean;
/** The minimum build number for this patch to be applied */
fromBuild?: number;
@ -61,7 +66,10 @@ export interface Patch {
noWarn?: boolean;
/** Only apply this set of replacements if all of them succeed. Use this if your replacements depend on each other */
group?: boolean;
/** A function which returns whether this patch should be applied */
/**
* A function which returns whether this patch replacement should be applied.
* This is ran before patches are registered, so if this returns false, the patch will never be registered.
*/
predicate?(): boolean;
/** The minimum build number for this patch to be applied */
fromBuild?: number;