<commit_before>import { applyMiddleware, compose, createStore } from 'redux'
import thunk from 'redux-thunk'

export default ({ middlewares, custom_enhancers }, cookies) => {

  // ======================================================
  // Middleware Configuration
  // ======================================================
  const middleware = [
    thunk.withExtraArgument({
      cookies,
    }),
  ]

  // Check if the logger middleware is enabled in the config
  if (middlewares.logger && middlewares.logger.enabled) {
    const loggerOptions = middlewares.logger.options || {}
    const createLogger = require('redux-logger').createLogger
    const logger = createLogger(loggerOptions)

    middleware.push(logger)
  }

  // ======================================================
  // Add all custom middlewares
  // ======================================================
  // Add from the folder if enabled
  if (middlewares.byFolder) {
    const customMiddlewares = require('store/middleware').default()

    customMiddlewares.forEach(customMiddleware => {
      middleware.push(customMiddleware)
    })
  }

  // Add from the collection if there are any
  if (middlewares.collection && middlewares.collection.length > 0) {
    middlewares.collection.forEach(customMiddleware => {
      middleware.push(customMiddleware)
    })
  }

  // ======================================================
  // Store Enhancers
  // ======================================================
  const enhancers = []
  if (__DEBUG__ && typeof window !== 'undefined' && window) {
    const devToolsExtension = window.devToolsExtension
    if (typeof devToolsExtension === 'function') {
      enhancers.push(devToolsExtension())
    }
  }

  // Add the custom enhancers
  if (custom_enhancers.length > 0) {
    custom_enhancers.forEach(enhancer => {
      enhancers.push(enhancer)
    })<commit_msg>feat(esc): Give cookies with loading the middlewares so it can be used there to<commit_after>import { applyMiddleware, compose, createStore } from 'redux'
import thunk from 'redux-thunk'

export default ({ middlewares, custom_enhancers }, cookies) => {

  // ======================================================
  // Middleware Configuration
  // ======================================================
  const middleware = [
    thunk.withExtraArgument({
      cookies,
    }),
  ]

  // Check if the logger middleware is enabled in the config
  if (middlewares.logger && middlewares.logger.enabled) {
    const loggerOptions = middlewares.logger.options || {}
    const createLogger = require('redux-logger').createLogger
    const logger = createLogger(loggerOptions)

    middleware.push(logger)
  }

  // ======================================================
  // Add all custom middlewares
  // ======================================================
  // Add from the folder if enabled
  if (middlewares.byFolder) {
    // Also give cookies with the function so middelwares can also use cookiesun
    const customMiddlewares = require('store/middleware').default({
      cookies
    })

    customMiddlewares.forEach(customMiddleware => {
      middleware.push(customMiddleware)
    })
  }

  // Add from the collection if there are any
  if (middlewares.collection && middlewares.collection.length > 0) {
    middlewares.collection.forEach(customMiddleware => {
      middleware.push(customMiddleware)
    })
  }

  // ======================================================
  // Store Enhancers
  // ======================================================
  const enhancers = []
  if (__DEBUG__ && typeof window !== 'undefined' && window) {
    const devToolsExtension = window.devToolsExtension
    if (typeof devToolsExtension === 'function') {
      enhancers.push(devToolsExtension())
    }
  }

  // Add the custom enhancers
  if (custom_enhancers.length > 0) {
    custom_enhancers.forEach(enhancer => {
      enhancers.push(enhancer)
    })
{'fraction_non_alphanumeric': 0.256468797564688, 'fraction_numerical': 0.0010147133434804667, 'mean_word_length': 3.997465145754119, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '2974350', 'n_tokens_mistral': 1039, 'n_tokens_neox': 991, 'n_words': 230}