<commit_before><commit_msg>feat(Sprockets::Mime): rewrite from ruby version<commit_after># https://github.com/sstephenson/sprockets/commit/519a49e445261adfca1e651120e50f58ec7bb8a4#diff-ba679810faf4553186c83bc4afb68087
module.exports = do
  # Pubic: Mapping of MIME type Strings to properties Hash.
  #
  # key   - MIME Type String
  # value - Hash
  #   extensions - Array of extnames
  #   charset    - Default Encoding or function to detect encoding
  #
  # Returns Hash.
  # attr_reader :mime_types

  #
  # attr_reader :mime_exts

  registerMimeType: (mime_type, options || {}) ->
    const extnames = Array options.extensions .map (extname) ->
      # Sprockets::Utils.normalize_extension(extname)
      extname

    {charset} = options
    # charset ||= EncodingUtils::DETECT if mime_type.start_with?('text/')

    extnames.forEach !(extname) ->
      @mime_exts[extname] = mime_type
    , @

    @mime_types[mime_type] = {}
    @mime_types[mime_type].extensions = extnames
    @mime_types[mime_type].charset = charset if charset
    @mime_types[mime_type]

  mimeTypeForExtname: (extname) ->
    @mime_exts[extname] or 'application/octet-stream'


  # Public: Test mime type against mime range.
  #
  #    match_mime_type?('text/html', 'text/*') => true
  #    match_mime_type?('text/plain', '*') => true
  #    match_mime_type?('text/html', 'application/json') => false
  #
  # Returns true if the given value is a mime match for the given mime match
  # specification, false otherwise.
  matchMimeType: (value, matcher) ->
    const [v1, v2] = value.split '/', 2
    const [m1, m2] = matcher.split '/', 2

    (m1 is '*' or v1 is m1) and (not m2 or m2 is '*' or m2 is v2)
{'fraction_non_alphanumeric': 0.1244047619047619, 'fraction_numerical': 0.03511904761904762, 'mean_word_length': 3.5188172043010755, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 1, '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': '4854203', 'n_tokens_mistral': 656, 'n_tokens_neox': 592, 'n_words': 137}