Sha256: 68dcb11cf851771a16eb144a01a93b0d39f45dd594426a0e6f2cbb2b4a4bd83d
Contents?: true
Size: 1.58 KB
Versions: 3
Compression:
Stored size: 1.58 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.ArrayReference, [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) ) } appendArgument(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
3 entries across 3 versions & 1 rubygems