<commit_before>"use strict";

var tool = require("./tool.js");
var common = require("./common.js");
var signals = common.signals;

var ID_UNRESOLVED = signals.ID_UNRESOLVED;
var EXECUTION_DELAYED = signals.EXECUTION_DELAYED;

var isAsyncTask = common.isAsyncTask;
var isAEC = common.isAEC;
var isTask = common.isTask;
var labAEC = common.labAEC;

Task.prototype = Object.create(Function.prototype);
function Task (fn, args, opts) {
  var ret = function task() {
    return ret.execute.apply(ret, arguments);
  };
  var i;
  ret.fn = fn;
  ret.sets = {
    "final": [],
    "passed": [],
    "internal": [],
    "task": [],
    "dep": []
  };
  // options
  opts = opts || {};
  ret.defAEC = "function" === typeof opts.defAEC ? labAEC(opts.defAEC) :
                labAEC(function NOP(){});
  ret.autoRetry = "autoRetry" in opts ? Boolean(opts.autoRetry) : true;

  ret.__proto__ = Task.prototype;

  args.forEach(function regTaskArgs(actual) {
    var set = "task", executable = false, index = null, once = false;

    ret._addSetEntry(set, actual, executable, index, once);

  }, null);

  return ret;
}

Task.prototype.addDep = function (fn, index, set) {
  var set, actual = fn, executable = true, index, once = false;
  if (!actual instanceof Function) throw new TypeError("bad `fn` arg");
  if (arguments.length == 3) {
    set = String(set);
    index = +index;
  } else if ("1" in arguments) {
    switch(typeof index) {
      case "number":
      index = index;
      set = "dep";
      break;

      case "string":
      if (!/^(?:dep|task|internal|passed|final)$/i.test(index)) {
        throw new TypeError;<commit_msg>add opts capability<commit_after>"use strict";

var tool = require("./tool.js");
var common = require("./common.js");
var signals = common.signals;

var ID_UNRESOLVED = signals.ID_UNRESOLVED;
var EXECUTION_DELAYED = signals.EXECUTION_DELAYED;

var isAsyncTask = common.isAsyncTask;
var isAEC = common.isAEC;
var isTask = common.isTask;
var labAEC = common.labAEC;

Task.prototype = Object.create(Function.prototype);
function Task (fn, args, opts) {
  var ret = function task() {
    return ret.execute.apply(ret, arguments);
  };
  var i;
  ret.fn = fn;
  ret.sets = {
    "final": [],
    "passed": [],
    "internal": [],
    "task": [],
    "dep": []
  };
  // options
  opts = opts || {};
  ret.defAEC = "function" === typeof opts.defAEC ? labAEC(opts.defAEC) :
                labAEC(function NOP(){});
  ret.autoRetry = "autoRetry" in opts ? Boolean(opts.autoRetry) : true;
  ret.logging = "logging" in opts ? Boolean(opts.logging) : true;
  ret.logStream = "logStream" in opts && opts.logStream.write ? opts.logStream :
                  process.stdout;

  ret.__proto__ = Task.prototype;

  args.forEach(function regTaskArgs(actual) {
    var set = "task", executable = false, index = null, once = false;

    ret._addSetEntry(set, actual, executable, index, once);

  }, null);

  return ret;
}

Task.prototype.addDep = function (fn, index, set) {
  var set, actual = fn, executable = true, index, once = false;
  if (!actual instanceof Function) throw new TypeError("bad `fn` arg");
  if (arguments.length == 3) {
    set = String(set);
    index = +index;
  } else if ("1" in arguments) {
    switch(typeof index) {
      case "number":
      index = index;
      set = "dep";
      break;

      case "string":
      if (!/^(?:dep|task|internal|passed|final)$/i.test(index)) {
        throw new TypeError;
{'fraction_non_alphanumeric': 0.15685706001739635, 'fraction_numerical': 0.0011597564511452595, 'mean_word_length': 3.197080291970803, 'pattern_counts': {'":': 14, '<': 3, '<?xml version=': 0, '>': 3, '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': '6662875', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1154, 'n_words': 296}