Sha256: 1a5c2deef40f7da578700b5521e309e4dc45817cbbed30b1c344eb775f0a9bad

Contents?: true

Size: 1.51 KB

Versions: 51

Compression:

Stored size: 1.51 KB

Contents

let CommandType = require('./CommandType')

class Command {
    constructor(runtimeName, commandType, payload = []) {
        this.runtimeName = runtimeName
        this.commandType = commandType
        this.payload = payload
    }

    static createResponse(response, runtimeName) {
        return new Command(
            runtimeName,
            CommandType.Value,
            [response]
        )
    }

    static createReference(response, runtimeName) {
        return new Command(
            runtimeName,
            CommandType.Reference,
            [response]
        )
    }

    static createArrayResponse(response, runtimeName) {
        return new Command(
            runtimeName,
            CommandType.Array,
            response
        )
    }

    dropFirstPayloadArg() {
        return new Command(
            this.runtimeName,
            this.commandType,
            this.payload.slice(1)
        )
    }

    addArgToPayload(arg) {
        return new Command(
            this.runtimeName,
            this.commandType,
            this.payload.concat(arg)
        )
    }

    prependArgToPayload(current_command) {
        if (current_command == null) {
            return new Command(
                this.runtimeName,
                this.commandType,
                this.payload)
        } else {
            return new Command(
                this.runtimeName,
                this.commandType,
                [current_command].concat(this.payload)
            )
        }
    }
}

module.exports = Command

Version data entries

51 entries across 30 versions & 1 rubygems

Version Path
javonet-ruby-sdk-2.4.5 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/utils/Command.js
javonet-ruby-sdk-2.4.4 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/utils/Command.js
javonet-ruby-sdk-2.4.4 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/utils/Command.js
javonet-ruby-sdk-2.4.3 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/utils/Command.js
javonet-ruby-sdk-2.4.3 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/utils/Command.js
javonet-ruby-sdk-2.4.2 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/utils/Command.js
javonet-ruby-sdk-2.4.2 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/utils/Command.js
javonet-ruby-sdk-2.3.0 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/utils/Command.js
javonet-ruby-sdk-2.3.0 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/utils/Command.js
javonet-ruby-sdk-2.2.0 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/utils/Command.js
javonet-ruby-sdk-2.2.0 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/utils/Command.js
javonet-ruby-sdk-2.1.14 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/utils/Command.js
javonet-ruby-sdk-2.1.14 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/utils/Command.js
javonet-ruby-sdk-2.1.13 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/utils/Command.js
javonet-ruby-sdk-2.1.13 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/utils/Command.js
javonet-ruby-sdk-2.1.12 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/utils/Command.js
javonet-ruby-sdk-2.1.12 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/utils/Command.js
javonet-ruby-sdk-2.1.11 lib/javonet-ruby-sdk/Binaries/Nodejs/MacOs/X64/utils/Command.js
javonet-ruby-sdk-2.1.11 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/utils/Command.js
javonet-ruby-sdk-2.1.10 lib/javonet-ruby-sdk/Binaries/Nodejs/Linux/X64/utils/Command.js