mirror of
https://github.com/motajs/template.git
synced 2026-10-14 17:10:20 +08:00
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:
parent
59b709e43e
commit
15f329b61d
@ -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 {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user