code: function normalizeCondition(condition) {
      if (!condition) throw new Error("Expected condition but got falsy value");
      if (typeof condition === "string") {
          return str => str.indexOf(condition) === 0;
      }
      if (typeof condition === "function") {
          return condition;
      }
      if (condition instanceof RegExp) {
          return condition.test.bind(condition);
      }
      if (Array.isArray(condition)) {
          const items = condition.map(c => normalizeCondition(c));
          return orMatcher(items);
      }
      if (typeof condition !== "object")
          throw Error(
              "Unexcepted " +
                  typeof condition +
                  " when condition was expected (" +
                  condition +
                  ")"
          );
  
      const matchers = [];
      Object.keys(condition).forEach(key => {
          const value = condition[key];
          switch (key) {
              case "or":
              case "include":
              case "test":
                  if (value) matchers.push(RuleSet.normalizeCondition(value));
                  break;
              case "and":
                  if (value) {
                      const items = value.map(c => RuleSet.normalizeCondition(c));
                      matchers.push(andMatcher(items));
                  }
                  break;
              case "not":
              case "exclude":
                  if (value) {
                      const matcher = RuleSet.normalizeCondition(value);
                      matchers.push(notMatcher(matcher));
                  }
                  break;
              default:
                  throw new Error("Unexcepted property " + key + " in condition");
          }
      });
      if (matchers.length === 0)
          throw new Error("Excepted condition but got " + condition);
      if (matchers.length === 1) return matchers[0];
      return andMatcher(matchers);
  }
docs: Copy of webpack/lib/RuleSet.js: normalizeCondition