Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async open(provider: Provider | null = null): Promise
{
// TEST CONDITION
if (is_node() === false)
{
if (self.document !== undefined)
throw new DomainError("This is not Worker.");
}
else if (global.process.send === undefined)
throw new DomainError("This is not Child Process.");
else if (this.state_ !== WorkerServer.State.NONE)
throw new DomainError("Server has opened yet.");
// OPEN WORKER
this.state_ = WorkerServer.State.OPENING;
{
this.provider_ = provider;
g.onmessage = this._Handle_message.bind(this);
g.postMessage(WorkerServer.State.OPEN);
}
public get arguments(): string[]
{
if (this.args_ === undefined)
if (is_node())
this.args_ = global.process.argv.slice(2);
else
{
let vars: URLVariables = new URLVariables(self.location.href);
this.args_ = vars.has("__m_pArgs")
? JSON.parse(vars.get("__m_pArgs"))
: [];
}
return this.args_!;
}