All files / lib Agent.js

100% Statements 17/17
100% Branches 17/17
71.43% Functions 5/7
100% Lines 16/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39        371x 371x 371x 642x 371x   371x 10x 26x       371x       651x   651x   651x 3x   648x         353x         3x  
'use strict';
 
class Agent {
  constructor(options = {}) {
    this.options = options;
    this.hostPath = options.hostPath;
    this.args = options.hostArguments || [];
    this.transform = options.transform || (x => x);
    this.out = options.out || '';
 
    if (typeof this.args === 'string') {
      this.args = this.args.includes(' ') ?
        this.args.split(' ').filter(v => v.trim()) :
        [this.args];
    }
 
    this.shortName = options.shortName || '$262';
  }
 
  compile(code, options) {
    options = options || {};
 
    code = this.transform(code);
 
    if (options.async) {
      return code;
    } else {
      return `${code}\n;${this.shortName}.destroy();`;
    }
  }
 
  // defaults that do nothing
  async initialize() { return this; }
  async destroy() {}
  stop() {}
}
 
module.exports = Agent;