'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports['default'] =


















childContext;var _hash = require('eslint-module-utils/hash');var optionsHash = '';var prevOptions = '';var settingsHash = '';var prevSettings = ''; // Replacer function helps us with serializing the parser nested within `languageOptions`.
function stringifyReplacerFn(_, value) {if (typeof value === 'function') {return String(value);}return value;} /**
                                                                                                                * don't hold full context object in memory, just grab what we need.
                                                                                                                * also calculate a cacheKey, where parts of the cacheKey hash are memoized
                                                                                                                */function childContext(path, context) {var settings = context.settings,parserOptions = context.parserOptions,parserPath = context.parserPath,languageOptions = context.languageOptions;if (JSON.stringify(settings) !== prevSettings) {settingsHash = (0, _hash.hashObject)({ settings: settings }).digest('hex');
    prevSettings = JSON.stringify(settings);
  }

  // We'll use either a combination of `parserOptions` and `parserPath` or `languageOptions`
  // to construct the cache key, depending on whether this is using a flat config or not.
  var optionsToken = void 0;
  if (!parserPath && languageOptions) {
    if (JSON.stringify(languageOptions, stringifyReplacerFn) !== prevOptions) {
      optionsHash = (0, _hash.hashObject)({ languageOptions: languageOptions }).digest('hex');
      prevOptions = JSON.stringify(languageOptions, stringifyReplacerFn);
    }
    // For languageOptions, we're just using the hashed options as the options token
    optionsToken = optionsHash;
  } else {
    if (JSON.stringify(parserOptions) !== prevOptions) {
      optionsHash = (0, _hash.hashObject)({ parserOptions: parserOptions }).digest('hex');
      prevOptions = JSON.stringify(parserOptions);
    }
    // When not using flat config, we use a combination of the hashed parserOptions
    // and parserPath as the token
    optionsToken = String(parserPath) + optionsHash;
  }

  return {
    cacheKey: optionsToken + settingsHash + String(path),
    settings: settings,
    parserOptions: parserOptions,
    parserPath: parserPath,
    path: path,
    languageOptions: languageOptions };

}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,[encoded data, 4848 characters]