Returns a restricted rule set,
in which at least one fact from the fact set
matches all rules.
@param rs
@param fs
@returns {Array}
503176
function(rs, fs) {
        var restriction = [];

        for (var i = 0; i < rs.length; i++) {
            var rule = rs[i], matches = false;

            for (var j = 0; j < rule.causes.length; j++) {
                var cause = rule.causes[j];

                for (var k = 0; k < fs.length; k++) {
                    var fact = fs[k];

                    if (this.causeMatchesFact(cause, fact)) {
                        matches = true;
                        break;
                    }
                }

                if (matches) {
                    restriction.push(rule);
                    break;
                }
            }
        }

        return restriction;
    }
1050908
protected function mapRules($rules) : Collection
	{
		return Collection::make($rules)
			->only($this->allowed)
			->flatMap(function ($item, $key) {
				if ($key == 'required') {
					$rule[] = $item ? 'required' : '';
				} else {
					$rule[] = $key . ':' . $item;
				}
				return $rule;
			});
	}
668496
function _getRuleAsString(responders, callback){

  var respondersArr = [];

  var respondersLen = responders.length;
  var srcLen;
  var fileStr;

  responders.forEach(function(entry, i){
    respondersArr.push(TAP + '{');
    respondersArr.push(TAP + TAP + 'pattern: \'' + entry.pattern + '\',' + entry.comment);
    respondersArr.push(TAP + TAP + 'responder: {');
    respondersArr.push(TAP + TAP + TAP + 'dir: ' + '\'' + entry.responder.dir + '\',');
    respondersArr.push(TAP + TAP + TAP + 'src: [');

    srcLen = entry.responder.src.length;

    entry.responder.src.forEach(function(file, j){
      fileStr = TAP + TAP + TAP + TAP + '\'' + file + '\'';
      if(j < srcLen - 1){
        fileStr += ',';
      }
      respondersArr.push(fileStr);
    });

    respondersArr.push(TAP + TAP + TAP + ']');
    respondersArr.push(TAP + TAP + '}');

    if( i < respondersLen - 1){
      respondersArr.push(TAP + '},');
    }else{
      respondersArr.push(TAP + '}');
    }

  });

  if(typeof callback === 'function'){
    callback(null, respondersArr.join(EOL));
  }
}
1215250
function gatherStateMachineRestrictions (stateMachines, permissionModel) {
  // Grab restrictions from state machines
  // -------------------------------------

  const docTasks = []

  if (!stateMachines) {
    return docTasks
  }

  for (const [name, stateMachine] of Object.entries(stateMachines)) {
    for (const restriction of (stateMachine.restrictions || [])) {
      restriction.stateMachineName = name
      docTasks.push({
        domain: 'stateMachineRestriction',
        docId: name + '_' + restriction.roleId,
        docSource: restriction,
        dao: permissionModel,
        docMaker: makePermissionDoc
      })
    }
  }

  return docTasks
}
1117183
function(factSet) {
        var that = this;
        for (var key in factSet) {
            if(that.equivalentTo(factSet[key])){
                return key;
            }
        }
        return false;
    }
341150
function (doc, ruleTree) {
    // Special case for "sets"
    if (_.isArray(doc))
      return _.map(doc, function (subdoc) { return transform(subdoc, ruleTree); });

    var res = details.including ? {} : EJSON.clone(doc);
    _.each(ruleTree, function (rule, key) {
      if (!_.has(doc, key))
        return;
      if (_.isObject(rule)) {
        // For sub-objects/subsets we branch
        if (_.isObject(doc[key]))
          res[key] = transform(doc[key], rule);
        // Otherwise we don't even touch this subfield
      } else if (details.including)
        res[key] = EJSON.clone(doc[key]);
      else
        delete res[key];
    });

    return res;
  }
1130273
async function combineRules(rulesList) {
  return Object.keys(rulesList)
    .reduce(async (collection, definitions) => {
      const isEnabled = rulesList[definitions];

      let { default: rules } = await import(`../rules/${definitions}`);
      if (!isEnabled) rules = await disableRules(rules);

      const previousRules = await collection;

      return {
        ...previousRules,
        ...rules,
      };
    }, Promise.resolve({}));
}
935487
function(fs1, fs2) {
        if(!fs2 || (fs2.length > fs1.length)) return false;
        for (var key in fs2) {
            var fact = fs2[key];
            if(!(fact.appearsIn(fs1))) {
                return false;
            }
        }
        return true;
    }
237300
public PluralRules getRulesForRulesId(String rulesId) {
        // synchronize on the map.  release the lock temporarily while we build the rules.
        PluralRules rules = null;
        boolean hasRules;  // Separate boolean because stored rules can be null.
        synchronized (rulesIdToRules) {
            hasRules = rulesIdToRules.containsKey(rulesId);
            if (hasRules) {
                rules = rulesIdToRules.get(rulesId);  // can be null
            }
        }
        if (!hasRules) {
            try {
                UResourceBundle pluralb = getPluralBundle();
                UResourceBundle rulesb = pluralb.get("rules");
                UResourceBundle setb = rulesb.get(rulesId);

                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < setb.getSize(); ++i) {
                    UResourceBundle b = setb.get(i);
                    if (i > 0) {
                        sb.append("; ");
                    }
                    sb.append(b.getKey());
                    sb.append(": ");
                    sb.append(b.getString());
                }
                rules = PluralRules.parseDescription(sb.toString());
            } catch (ParseException e) {
            } catch (MissingResourceException e) {
            }
            synchronized (rulesIdToRules) {
                if (rulesIdToRules.containsKey(rulesId)) {
                    rules = rulesIdToRules.get(rulesId);
                } else {
                    rulesIdToRules.put(rulesId, rules);  // can be null
                }
            }
        }
        return rules;
    }
1076606
function _explodeRules(rules) {
    for (var i in rules) {
      if (is_string(rules[i])) {
        rules[i] = rules[i].split('|');
      }
    }
    return rules;
  }
104562
function rule(type = 'multi', terms = [], roles = []) {
  generation += 1;
  // FIXME ?? deepClone ??
  return {
    type: 'rule',
    generation,
    rule: {
      type,
      terms,
      roles,
    },
  };
}
66126
public function getRules($ruleset)
    {
        $fileName = $this->directoryName.DIRECTORY_SEPARATOR.$ruleset.'.json';

        return json_decode(file_get_contents($fileName), true);
    }
1020330
function (rulesArray) {
    var rules = [];

    for (var i = 0, len = rulesArray.length; i < len; i++) {
      if (typeof rulesArray[i] === 'object') {
        for (var rule in rulesArray[i]) {
          rules.push({
            name: rule,
            value: rulesArray[i][rule]
          });
        }
      } else {
        rules.push(rulesArray[i]);
      }
    }

    return rules;
  }
1065196
function result(rule) {
  var r = {}

  var reserved = ['filename', 'exists', 'grep', 'jsonKeyExists']

  Object.keys(rule).forEach(function(key) {
    if (reserved.indexOf(key) !== -1) return
    r[key] = rule[key]
  })

  return r
}
973708
function getAriaQueryAttributes() {
				const ariaKeys = Array.from(props).map(([key]) => key);
				const roleAriaKeys = Array.from(roles).reduce((out, [name, rule]) => {
					return [...out, ...Object.keys(rule.props)];
				}, []);
				return new Set(axe.utils.uniqueArray(roleAriaKeys, ariaKeys));
			}
447015
private List<String> collectRuleNames() {
        List<String> ruleNames = new ArrayList<>();
        for (Rule rule : rules) {
            ruleNames.add(rule.getName());
        }
        Collections.sort(ruleNames);
        return ruleNames;
    }
402195
function find_rule_global(gender, name, nametype_rulesets, features) {
        if (!features) features = {};
        var tags = [];
        for (var key in features) {
            if (features.hasOwnProperty(key)) tags.push(key);
        }
        if (nametype_rulesets.exceptions) {
            var rule = find_rule_local(
                gender, name, nametype_rulesets.exceptions, true, tags);
            if (rule) return rule;
        }
        return find_rule_local(
            gender, name, nametype_rulesets.suffixes, false, tags);
    }