test(06-01): polyfill Map.getOrInsert in combat test harness

- keep the global Map stub uniform across combat test files so modules using
  getOrInsert/getOrInsertComputed load under Node
This commit is contained in:
unanmed 2026-09-14 08:49:55 +08:00
parent 59b709e43e
commit 15f329b61d

View File

@ -26,6 +26,16 @@ vi.hoisted(() => {
this.set(key, value);
return value;
};
Map.prototype.getOrInsert ??= function <K, V>(
this: Map<K, V>,
key: K,
defaultValue: V
): V {
const existing = this.get(key);
if (existing !== undefined) return existing;
this.set(key, defaultValue);
return defaultValue;
};
});
interface TestEnemyAttr {