Tighten and simplify

This commit is contained in:
Tony Garnock-Jones 2021-02-22 22:32:09 +01:00
parent 2f3a249ab5
commit a7f5589881
1 changed files with 7 additions and 11 deletions

View File

@ -92,10 +92,8 @@ export class Turn {
return new Ref(this._ensureActor(what), t);
}
spawn(bootProc: (t: Turn) => void, initialAssertions?: IdentitySet<Handle>): void {
if ((initialAssertions !== void 0) && (initialAssertions.size > 0)) {
this._ensureActor("spawn with initialAssertions");
}
spawn(bootProc: (t: Turn) => void, initialAssertions = new IdentitySet<Handle>()): void {
if (initialAssertions.size > 0) this._ensureActor("spawn with initialAssertions");
this.localActions.push(() => {
const child = new Actor(this.actor === null
? void 0
@ -157,13 +155,11 @@ export class Turn {
}
}
function extractFromMap<K, V>(map: Map<K, V>, keys?: IdentitySet<K>): Map<K, V> {
function extractFromMap<K, V>(map: Map<K, V>, keys: IdentitySet<K>): Map<K, V> {
const result: Map<K, V> = new Map();
if (keys !== void 0) {
keys.forEach(key => {
if (map.has(key)) result.set(key, map.get(key)!);
map.delete(key);
});
}
keys.forEach(key => {
if (map.has(key)) result.set(key, map.get(key)!);
map.delete(key);
});
return result;
}