How to use the tstl/utility/node.is_node function in tstl

To help you get started, we’ve selected a few tstl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github samchon / tgrid / src / protocols / workers / WorkerServer.ts View on Github external
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);
        }
github samchon / tgrid / src / protocols / workers / WorkerServer.ts View on Github external
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_!;
    }