<commit_before>{KiteError} = require './errors'

class Request
  constructor: (@options)->
    @Method         = @options.Method
    @Args           = @options.Args
    @LocalKite      = @options.LocalKite
    @RemoteKite     = @options.RemoteKite
    @Username       = @options.UserName
    @Authentication = @options.Authentication
    @RemoteAddr     = @options.RemoteAddr

    if @Args[0]? and typeof(@Args[0]) is "object" and @Args[0].type? 
      if @Args[0].type.indexOf("Error")
        # we replace error struct with a KiteError
        @Args[0] = new KiteError @Args[0]

class RequestFilter
  constructor: (@worker)->
  run: (request, next)-><commit_msg>kite: nodejs kite: document why check args[0]<commit_after>{KiteError} = require './errors'

class Request
  constructor: (@options)->
    @Method         = @options.Method
    @Args           = @options.Args
    @LocalKite      = @options.LocalKite
    @RemoteKite     = @options.RemoteKite
    @Username       = @options.UserName
    @Authentication = @options.Authentication
    @RemoteAddr     = @options.RemoteAddr

    # go returns an error struct as the first argument for an error
    # > { type: 'serverError',
    # >   message: 'Timeout',
    # >   error: { [Function] id: 2 } }
    # we wrap this into a KiteError and send it to our callback
    if @Args[0]? and typeof(@Args[0]) is "object" and @Args[0].type?
      if @Args[0].type.indexOf("Error")
        # we replace error struct with a KiteError
        @Args[0] = new KiteError @Args[0]

class RequestFilter
  constructor: (@worker)->
  run: (request, next)->
{'fraction_non_alphanumeric': 0.12939698492462312, 'fraction_numerical': 0.008793969849246231, 'mean_word_length': 2.7748815165876777, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '3425736', 'n_tokens_mistral': 487, 'n_tokens_neox': 482, 'n_words': 135}