Copy of webpack/lib/RuleSet.js: normalizeCondition
19485
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);
}
879349
function normalizeModules(modules) {
    var normalized = {};

    Object.keys(modules).forEach(function (key) {
        var module = modules[key];

        // make sure each vuex module has all keys defined
        normalized[key] = {
            actions: module.actions || {},
            getters: module.getters || {},
            modules: module.modules ? normalizeModules(module.modules) : {},
            mutations: module.mutations || {},
            namespaced: module.namespaced || false,
            state: {}
        };

        // make sure our state is a fresh object
        if (typeof module.state === 'function') {
            normalized[key].state = module.state();
        } else if (_typeof(module.state) === 'object') {
            normalized[key].state = JSON.parse(JSON.stringify(module.state));
        }
    });

    return normalized;
}
47771
function parseProperties(source, baseDirectory) {
  // Get the raw SCSS concrete syntax tree.
  const rawTree = parseCSS(source);
  removeWhitespace(rawTree);

  // Convert the concrete syntax tree into a more convenient AST.
  let schema
  const rootRules = []
  for (const rule of rawTree.value) {
    if (rule.type === 'atrule') {
      removeWhitespace(rule);
      const [keyword, argument] = rule.value;
      if (keyword.value === 'schema') {
        schema = visitSchema(argument, baseDirectory)
      } else if (keyword.value === 'import') {
        rootRules.push(...visitImport(argument, baseDirectory))
      }
    } else {
      rootRules.push(visitRule(rule, false))
    }
  }

  // Flatten out any nested selectors.
  const rules = []
  for (const rootRule of rootRules) {
    flattenRule(rootRule, rules, [[]]);
  }

  const validator = new Validator();

  for (const rule of rules) {
    // Validate each rule's properties against the schema.
    for (const property in rule.properties) {
      if (schema) {
        const propertySchema = schema[property]
        const value = rule.properties[property]
        if (!propertySchema) {
          throw new Error(`Property '${property}' is not present in the schema`);
        }
        const {errors} = validator.validate(value, propertySchema);
        if (errors.length > 0) {
          throw new Error(`Invalid value '${value}' for property '${property}'`)
        }
      }
    }

    rule.selectors = rule.selectors.map(applyPseudoClasses)
  }

  return rules;
}
696638
function normalizeSource(source) {
		if (source.className) {
			// TODO: repeat code, same code for event classNames
			if (typeof source.className == 'string') {
				source.className = source.className.split(/\s+/);
			}
		}else{
			source.className = [];
		}
		var normalizers = fc.sourceNormalizers;
		for (var i=0; i<normalizers.length; i++) {
			normalizers[i](source);
		}
	}
1235494
function getEnrichedConfig(rule, config) {
	if (!config) { return rule; }

	if (config.include) {
		rule.include = config.include;
	}
	if (config.exclude) {
		rule.exclude = config.exclude;
	}
	return rule;
}
142905
def _rules_from_env(self, val):
        """"""
        val = val.split(':')
        if 'DEFAULT_RULES' in val:
            val = const.DEFAULT_RULES + [rule for rule in val if rule != 'DEFAULT_RULES']
        return val
504942
def normalize_rules(rules)
      deps          = Hash.new { |h, k| h[k] = [] }
      substitutions = {}

      # replace before with after on oposite direction and build the
      # substitutions dictionary
      rules.each do |middleware_class, middleware_rules|
        deps[middleware_class].concat(middleware_rules[:after])
        middleware_rules[:before].each do |dependent_class|
          deps[dependent_class] << middleware_class
        end
        middleware_rules[:replace].each do |replaced|
          substitutions[replaced] = middleware_class
        end
      end

      # replace the middleware to be substituted
      substitutions.each do |old, new|
        deps[new].concat(deps[old])
        deps.delete(old)
      end

      # ignore deps, that are not present in the stack
      deps.each do |middleware_class, middleware_deps|
        middleware_deps.reject! { |dep| !deps.has_key?(dep) }
      end

      return deps.delete_if {|klass, _| klass.nil? }
    end
1066232
function normalize(gj) {
    if (!gj || !gj.type) return null;
    var type = types[gj.type];
    if (!type) return null;

    if (type === 'geometry') {
        return {
            type: 'FeatureCollection',
            features: [{
                type: 'Feature',
                properties: {},
                geometry: gj
            }]
        };
    } else if (type === 'feature') {
        return {
            type: 'FeatureCollection',
            features: [gj]
        };
    } else if (type === 'featurecollection') {
        return gj;
    }
}
186845
function applyReplacementRules(rulesset, content) {
  return rulesset.reduce((a,b) => {
    return a.replace(b[0], b[1]);
  }, content);
}
63651
function partition(predicate, thisArg) {
    return function (source) {
        return [
            Object(_filter__WEBPACK_IMPORTED_MODULE_1__["filter"])(predicate, thisArg)(source),
            Object(_filter__WEBPACK_IMPORTED_MODULE_1__["filter"])(Object(_util_not__WEBPACK_IMPORTED_MODULE_0__["not"])(predicate, thisArg))(source)
        ];
    };
}
293178
function rule() {
        if (!settings.preserveStatic) {
            const balancedMatch = balanced('{', '}', css);

            // Skip rulset if it does not contain a :root variable declaration
            // of a variable function value
            if (balancedMatch) {
                const hasVarDecl = balancedMatch.pre.indexOf(':root') !== -1 && /--\S*\s*:/.test(balancedMatch.body);
                const hasVarFunc = /var\(/.test(balancedMatch.body);

                if (!hasVarDecl && !hasVarFunc) {
                    css = css.slice(balancedMatch.end + 1);

                    return {};
                }
            }
        }

        const sel   = selector() || [];
        const decls = settings.preserveStatic ? declarations() : declarations().filter(decl => {
            const hasVarDecl = sel.some(s => s.indexOf(':root') !== -1) && /^--\S/.test(decl.property);
            const hasVarFunc = /var\(/.test(decl.value);

            return hasVarDecl || hasVarFunc;
        });

        if (!sel.length) {
            error('selector missing');
        }

        return {
            type        : 'rule',
            selectors   : sel,
            declarations: decls
        };
    }
263929
function normalize( pkgs, data ) {
	var keys;
	var tmp;
	var i;

	// {"error":"..."} || {"status":404,"message":"..."}
	if ( data.error || data.status === 404 ) {
		tmp = {};
		for ( i = 0; i < pkgs.length; i++ ) {
			tmp[ pkgs[ i ] ] = null;
		}
		data = tmp;
	}
	// {"downloads":[...],"package":"..."}
	else if ( data.package ) {
		tmp = {};
		tmp[ data.package ] = data;
		data = tmp;
	}
	// Check for packages missing from the results...
	keys = getKeys( data );
	if ( keys.length !== pkgs.length ) {
		for ( i = 0; i < pkgs.length; i++ ) {
			if ( data[ pkgs[i] ] === void 0 ) {
				data[ pkgs[i] ] = null;
			}
		}
	}
	return data;
}
620961
function normalizeModuleIdentifiers(ast, load, options) {
	visitRequireArgument(ast, function(argument) {
		var normalized = optionsNormalize(
			options,
			argument.value,
			load.name,
			load.address
		);

		argument.value = normalized;
		argument.raw = `"${normalized}"`;
	});
}
1162769
function beautifyWarnings(configFilePath, warnings) {
	if (warnings.length === 0) {
		return;
	}
	const intro = `⚠️ ts-config-webpack-plugin found ${warnings.length} warning${
		warnings.length ? 's' : ''
	} in "${configFilePath}".`;
	return intro + '\n' + warnings.map((warning) => 'Warning: \n   ' + warning.split('\n').join('\n   ')).join('\n\n');
}
2896
function applyRules(_string, _ruleSet, _skip) {

      if(_skip.indexOf(_string.toLowerCase()) === -1) {
        var i = 0, rule;
        while(rule = _ruleSet[i++]) {
          if(_string.match(rule[0])) {
            return _string.replace(rule[0], rule[1]);
          }
        }
      }

      return _string;
    }
1137999
function createRegExpForIgnorePatterns(normalizedOptions) {
    Object.keys(normalizedOptions).forEach(key => {
        const ignorePatternStr = normalizedOptions[key].ignorePattern;

        if (ignorePatternStr) {
            const regExp = RegExp(`^\\s*(?:${ignorePatternStr})`, "u");

            normalizedOptions[key].ignorePatternRegExp = regExp;
        }
    });
}
866423
function normalizeBundleItem(items) {
  var i, len;
  if (!istype('Array', items))
    return;
  len = items.length;
  for (i = 0; i < len; i++)
    if (istype('String', items[i]))
      items[i] = { src: items[i] };
  return items;
}