<commit_before>module.exports.fragments_session = (
  fragments_sessionMiddleware
  fragments_req
  fragments_res
  fragments_Promise
) ->
  # req has already been passed through sessionMiddleware and req.session
  # has been added.
  # either because sessionMiddleware is in the middleware chain or
  # on demand (see below).
  if fragments_req.session?
    fragments_req.session
  # req has not been through sessionMiddleware.
  # do it now.
  # by doing it on demand we save one redis request on routes that dont
  # use the session.
  # this happens at most once per request.
  else
    new fragments_Promise (resolve, reject) ->
      fragments_sessionMiddleware fragments_req, fragments_res, (err) ->
        if err?
          return reject err
        resolve fragments_req.session

module.exports.fragments_sessionID = (
  fragments_req
  # force req to be passed through fragments_sessionMiddleware which
  # sets res.sessionID
  fragments_session
) ->
  fragments_req.sessionID<commit_msg>improve code of `session` fragment<commit_after>module.exports.fragments_session = (
  fragments_sessionMiddleware
  fragments_req
  fragments_res
  fragments_Promise
) ->
  # req has already been passed through sessionMiddleware and req.session
  # has been added.
  # either because sessionMiddleware is in the middleware chain or
  # on demand (see below).
  if fragments_req.session?
    return fragments_req.session
  # req has not been through sessionMiddleware.
  # do it now.
  # by doing it on demand we save one redis request on routes that dont
  # use the session.
  # this happens at most once per request.
  new fragments_Promise (resolve, reject) ->
    fragments_sessionMiddleware fragments_req, fragments_res, (err) ->
      if err?
        return reject err
      resolve fragments_req.session

module.exports.fragments_sessionID = (
  fragments_req
  # force req to be passed through fragments_sessionMiddleware which
  # sets res.sessionID
  fragments_session
) ->
  fragments_req.sessionID
{'fraction_non_alphanumeric': 0.05574912891986063, 'fraction_numerical': 0.0, 'mean_word_length': 3.7072599531615924, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '3596737', 'n_tokens_mistral': 535, 'n_tokens_neox': 561, 'n_words': 195}