<commit_before>/**
 * A Command extends the Function class by generating Javascript
 * and passing it directly to the Function (super) constructor.
 */
let commandCount = 0
export class Command extends Function {
  static count() { return count }
  static codegen(fn) {
    if ('function' != typeof fn) { throw new TypeError("Expecting a function") }
    else { return `return (${String(fn)}).apply(this, arguments);` }
  }

  constructor(fn) {
    if ('function' != typeof fn) {
      throw new TypeError("Command constructor expects a function.")
    }
    // initialize underlying function wrap
    super(Command.codegen(function wrap(fn) {
      return fn.apply(fn, Array.prototype.slice.call(arguments, 1))
    }))
    const exec = (...args) => this(fn, ...args)
    this.constructor = exec.constructor = Command
    void commandCount ++
    return Object.assign(exec, {'this': this})
  }
}
<commit_msg>refactor(src/core/command.js): Add 'use strict' to Command wrap<commit_after>/**
 * A Command extends the Function class by generating Javascript
 * and passing it directly to the Function (super) constructor.
 */
let commandCount = 0
export class Command extends Function {
  static count() { return count }
  static codegen(fn) {
    if ('function' != typeof fn) { throw new TypeError("Expecting a function") }
    else { return `"use strict"; return (${String(fn)}).apply(this, arguments);` }
  }

  constructor(fn) {
    if ('function' != typeof fn) {
      throw new TypeError("Command constructor expects a function.")
    }
    // initialize underlying function wrap
    super(Command.codegen(function wrap(fn) {
      return fn.apply(fn, Array.prototype.slice.call(arguments, 1))
    }))
    const exec = (...args) => this(fn, ...args)
    this.constructor = exec.constructor = Command
    void commandCount ++
    return Object.assign(exec, {'this': this})
  }
}

{'fraction_non_alphanumeric': 0.1324468085106383, 'fraction_numerical': 0.002127659574468085, 'mean_word_length': 3.5216346153846154, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1160105', 'n_tokens_mistral': 529, 'n_tokens_neox': 518, 'n_words': 174}