@peerbit/program
Advanced tools
Comparing version 2.4.0 to 2.4.1
@@ -88,12 +88,24 @@ import PQueue from "p-queue"; | ||
} | ||
else if (!program.closed) { | ||
const existing = this.items.get(program.address); | ||
if (existing === program) { | ||
return program; | ||
else { | ||
if (options.parent == program) { | ||
throw new Error("Parent program can not be equal to the program"); | ||
} | ||
else if (existing) { | ||
const existing = await this.checkProcessExisting(program.address, program, options?.existing); | ||
if (existing) { | ||
return existing; | ||
if (!program.closed) { | ||
const existing = this.items.get(program.address); | ||
if (existing === program) { | ||
return program; | ||
} | ||
else if (existing) { | ||
// we got existing, but it is not the same instance | ||
const existing = await this.checkProcessExisting(program.address, program, options?.existing); | ||
if (existing) { | ||
return existing; | ||
} | ||
} | ||
else { | ||
// assume new instance was not added to monitored items, just add it | ||
// and return it as we would opened it normally | ||
this.items.set(program.address, program); | ||
return program; | ||
} | ||
} | ||
@@ -100,0 +112,0 @@ } |
{ | ||
"name": "@peerbit/program", | ||
"version": "2.4.0", | ||
"version": "2.4.1", | ||
"description": "Program interface", | ||
@@ -38,3 +38,3 @@ "type": "module", | ||
}, | ||
"gitHead": "851f1a4fdff94efd0f9331a43d6f8652e27e6d26" | ||
"gitHead": "1a57e60b02b5ea1c0c743871a92404a0115ed683" | ||
} |
@@ -191,15 +191,27 @@ import { Blocks } from "@peerbit/blocks-interface"; | ||
} | ||
} else if (!program.closed) { | ||
const existing = this.items.get(program.address); | ||
if (existing === program) { | ||
return program; | ||
} else if (existing) { | ||
const existing = await this.checkProcessExisting( | ||
program.address, | ||
program, | ||
options?.existing | ||
); | ||
} else { | ||
if (options.parent == program) { | ||
throw new Error("Parent program can not be equal to the program"); | ||
} | ||
if (existing) { | ||
return existing as S; | ||
if (!program.closed) { | ||
const existing = this.items.get(program.address); | ||
if (existing === program) { | ||
return program; | ||
} else if (existing) { | ||
// we got existing, but it is not the same instance | ||
const existing = await this.checkProcessExisting( | ||
program.address, | ||
program, | ||
options?.existing | ||
); | ||
if (existing) { | ||
return existing as S; | ||
} | ||
} else { | ||
// assume new instance was not added to monitored items, just add it | ||
// and return it as we would opened it normally | ||
this.items.set(program.address, program); | ||
return program; | ||
} | ||
@@ -224,2 +236,3 @@ } | ||
} | ||
await program.beforeOpen(this.properties.client, { | ||
@@ -226,0 +239,0 @@ onBeforeOpen: async (p) => { |
Sorry, the diff of this file is not supported yet
72786
1552