<commit_before>'use strict';

var util = require('util');

//
// Async
//

function Spec() {
}

Spec.prototype.isSatisfiedBy = function isSatisfiedBy(candidate, cb) {
  cb(new Error('isSatisfiedBy not implemented'));
};

Spec.prototype.and = function and(other) {
  return new AndSpec(this, other);
};

Spec.prototype.or = function or(other) {
  return new OrSpec(this, other);
};

Spec.prototype.not = function or(other) {
  return new NotSpec(this);
};

module.exports.Spec = Spec;


// AND
function AndSpec(lhs, rhs) {
  this.lhs = lhs;
  this.rhs = rhs;
}

util.inherits(AndSpec, Spec);

AndSpec.prototype.isSatisfiedBy = function isSatisfiedBy(candidate, cb) {
  var self = this;
  self.lhs.isSatisfiedBy(candidate, function(err, flag) {
    if(err) {
      return cb(err);
    }

    if(!flag) {
      return cb(null, flag);
    }

    self.rhs.isSatisfiedBy(candidate, function(err, flag) {
      if(err) {
        return cb(err);
      }

      return cb(null, flag);
    });
  });
};

// OR
function OrSpec(lhs, rhs) {
  this.lhs = lhs;
  this.rhs = rhs;
}

util.inherits(OrSpec, Spec);

OrSpec.prototype.isSatisfiedBy = function isSatisfiedBy(candidate, cb) {
  var self = this;
  self.lhs.isSatisfiedBy(candidate, function(err, flag) {
    if(err) {
      cb(err);
    }

    if(flag) {
      return cb(null, flag);
    }

    self.rhs.isSatisfiedBy(candidate, function(err, flag) {
      if(err) {
        return cb(err);
      }

      cb(null, flag);
    });
  });
};


// NOT
function NotSpec(other) {
  this.other = other;
}

util.inherits(NotSpec, Spec);

NotSpec.prototype.isSatisfiedBy = function isSatisfiedBy(candidate, cb) {
  this.other.isSatisfiedBy(candidate, function(err, flag) {
    if(err) {
      return cb(err);
    }

    cb(null, !flag);
  });
};

/**
 * Create a new basic async specification
 * @param func isSatisfiedBy function, provided by a user
 * @returns {Spec}
 */
function make(func) {
  function BasicSpec() {
  }
  util.inherits(BasicSpec, Spec);
  BasicSpec.prototype.isSatisfiedBy = func;
  return new BasicSpec();
}

module.exports.make = make;


//
// Sync
//

function SyncSpec() {
}

SyncSpec.prototype.isSatisfiedBy = function isSatisfiedBy(candidate) {
  throw new Error('isSatisfiedBy not implemented');
};

SyncSpec.prototype.and = function and(other) {
  return new SyncAndSpec(this, other);
};

SyncSpec.prototype.or = function or(other) {
  return new SyncOrSpec(this, other);
};

SyncSpec.prototype.not = function or(other) {
  return new SyncNotSpec(this);
};

module.exports.SyncSpec = SyncSpec;


// AND
function SyncAndSpec(lhs, rhs) {
  this.lhs = lhs;
  this.rhs = rhs;
}

util.inherits(SyncAndSpec, SyncSpec);

SyncAndSpec.prototype.isSatisfiedBy = function isSatisfiedBy(candidate) {
  return this.lhs.isSatisfiedBy(candidate) && this.rhs.isSatisfiedBy(candidate);
};


// OR
function SyncOrSpec(lhs, rhs) {
  this.lhs = lhs;
  this.rhs = rhs;
}

util.inherits(SyncOrSpec, SyncSpec);

SyncOrSpec.prototype.isSatisfiedBy = function isSatisfiedBy(candidate) {
  return this.lhs.isSatisfiedBy(candidate) || this.rhs.isSatisfiedBy(candidate);
};


// NOT
function SyncNotSpec(other) {
  this.other = other;
}

util.inherits(SyncNotSpec, SyncSpec);

SyncNotSpec.prototype.isSatisfiedBy = function isSatisfiedBy(candidate) {
  return !this.other.isSatisfiedBy(candidate);
};


/**
 * Create a new basic sync specification
 * @param func isSatisfiedBy function, provided by a user
 * @returns {Spec}
 */
function makeSync(func) {
  function BasicSyncSpec() {
  }
  util.inherits(BasicSyncSpec, SyncSpec);
  BasicSyncSpec.prototype.isSatisfiedBy = func;
  return new BasicSyncSpec();<commit_msg>added base ctor call<commit_after>'use strict';

var util = require('util');

//
// Async
//

function Spec() {
}

Spec.prototype.isSatisfiedBy = function isSatisfiedBy(candidate, cb) {
  cb(new Error('isSatisfiedBy not implemented'));
};

Spec.prototype.and = function and(other) {
  return new AndSpec(this, other);
};

Spec.prototype.or = function or(other) {
  return new OrSpec(this, other);
};

Spec.prototype.not = function or(other) {
  return new NotSpec(this);
};

module.exports.Spec = Spec;


// AND
function AndSpec(lhs, rhs) {
  Spec.call(this);
  this.lhs = lhs;
  this.rhs = rhs;
}

util.inherits(AndSpec, Spec);

AndSpec.prototype.isSatisfiedBy = function isSatisfiedBy(candidate, cb) {
  var self = this;
  self.lhs.isSatisfiedBy(candidate, function(err, flag) {
    if(err) {
      return cb(err);
    }

    if(!flag) {
      return cb(null, flag);
    }

    self.rhs.isSatisfiedBy(candidate, function(err, flag) {
      if(err) {
        return cb(err);
      }

      return cb(null, flag);
    });
  });
};

// OR
function OrSpec(lhs, rhs) {
  Spec.call(this);
  this.lhs = lhs;
  this.rhs = rhs;
}

util.inherits(OrSpec, Spec);

OrSpec.prototype.isSatisfiedBy = function isSatisfiedBy(candidate, cb) {
  var self = this;
  self.lhs.isSatisfiedBy(candidate, function(err, flag) {
    if(err) {
      cb(err);
    }

    if(flag) {
      return cb(null, flag);
    }

    self.rhs.isSatisfiedBy(candidate, function(err, flag) {
      if(err) {
        return cb(err);
      }

      cb(null, flag);
    });
  });
};


// NOT
function NotSpec(other) {
  Spec.call(this);
  this.other = other;
}

util.inherits(NotSpec, Spec);

NotSpec.prototype.isSatisfiedBy = function isSatisfiedBy(candidate, cb) {
  this.other.isSatisfiedBy(candidate, function(err, flag) {
    if(err) {
      return cb(err);
    }

    cb(null, !flag);
  });
};

/**
 * Create a new basic async specification
 * @param func isSatisfiedBy function, provided by a user
 * @returns {Spec}
 */
function make(func) {
  function BasicSpec() {
  }
  util.inherits(BasicSpec, Spec);
  BasicSpec.prototype.isSatisfiedBy = func;
  return new BasicSpec();
}

module.exports.make = make;


//
// Sync
//

function SyncSpec() {
}

SyncSpec.prototype.isSatisfiedBy = function isSatisfiedBy(candidate) {
  throw new Error('isSatisfiedBy not implemented');
};

SyncSpec.prototype.and = function and(other) {
  return new SyncAndSpec(this, other);
};

SyncSpec.prototype.or = function or(other) {
  return new SyncOrSpec(this, other);
};

SyncSpec.prototype.not = function or(other) {
  return new SyncNotSpec(this);
};

module.exports.SyncSpec = SyncSpec;


// AND
function SyncAndSpec(lhs, rhs) {
  SyncSpec.call(this);
  this.lhs = lhs;
  this.rhs = rhs;
}

util.inherits(SyncAndSpec, SyncSpec);

SyncAndSpec.prototype.isSatisfiedBy = function isSatisfiedBy(candidate) {
  return this.lhs.isSatisfiedBy(candidate) && this.rhs.isSatisfiedBy(candidate);
};


// OR
function SyncOrSpec(lhs, rhs) {
  SyncSpec.call(this);
  this.lhs = lhs;
  this.rhs = rhs;
}

util.inherits(SyncOrSpec, SyncSpec);

SyncOrSpec.prototype.isSatisfiedBy = function isSatisfiedBy(candidate) {
  return this.lhs.isSatisfiedBy(candidate) || this.rhs.isSatisfiedBy(candidate);
};


// NOT
function SyncNotSpec(other) {
  SyncSpec.call(this);
  this.other = other;
}

util.inherits(SyncNotSpec, SyncSpec);

SyncNotSpec.prototype.isSatisfiedBy = function isSatisfiedBy(candidate) {
  return !this.other.isSatisfiedBy(candidate);
};


/**
 * Create a new basic sync specification
 * @param func isSatisfiedBy function, provided by a user
 * @returns {Spec}
 */
function makeSync(func) {
  function BasicSyncSpec() {
  }
  util.inherits(BasicSyncSpec, SyncSpec);
  BasicSyncSpec.prototype.isSatisfiedBy = func;
  return new BasicSyncSpec();
{'fraction_non_alphanumeric': 0.1405347306193739, 'fraction_numerical': 0.0, 'mean_word_length': 3.7353689567430024, 'pattern_counts': {'":': 0, '<': 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': '6664361', 'n_tokens_mistral': 2739, 'n_tokens_neox': 2655, 'n_words': 528}