<commit_before>noflo = require 'noflo'

class DetectTarget extends noflo.Component
  describe: 'Verify that the gesture target has the right properties'
  constructor: ->
    @target = null
    @inPorts =
      in: new noflo.Port 'object'
      target: new noflo.Port 'string'
      clear: new noflo.Port 'bang'
    @outPorts =
      pass: new noflo.Port 'object'
      fail: new noflo.Port 'object'
      target: new noflo.Port 'object'

    @inPorts.target.on 'data', (data) ->
      parts = data.split '='
      @target = {} unless @target
      @target[parts[0]] = parts[1]

    @inPorts.clear.on 'data', =>
      @target = null

    @inPorts.in.on 'data', (data) =>
      if Object.keys(data).length > 0
        passed = true
        for touch, element of data
          unless @detectTarget element
            passed = false
        if passed
          if @outPorts.target.isAttached()
            @outPorts.target.send data[Object.keys(data)[0].target]
          @outPorts.pass.send data
        else
          @outPorts.fail.send data
        return
      if @detectTarget data[Object.keys(data)[0]]
        if @outPorts.target.isAttached()
          @outPorts.target.send data[Object.keys(data)[0].targe]
        @outPorts.pass.send data
      else
        @outPorts.fail.send data
    @inPorts.in.on 'disconnect', =>
      @outPorts.pass.disconnect()
      @outPorts.fail.disconnect()
      if @outPorts.target.isAttached()
        @outPorts.target.disconnect()

  detectTarget: (element) ->
    for key, value of @target
      unless element[key] is value
        return false
    true

exports.getComponent = -> new DetectTarget
<commit_msg>Send the current element<commit_after>noflo = require 'noflo'

class DetectTarget extends noflo.Component
  describe: 'Verify that the gesture target has the right properties'
  constructor: ->
    @target = null
    @inPorts =
      in: new noflo.Port 'object'
      target: new noflo.Port 'string'
      clear: new noflo.Port 'bang'
    @outPorts =
      pass: new noflo.Port 'object'
      fail: new noflo.Port 'object'
      target: new noflo.Port 'object'

    @inPorts.target.on 'data', (data) ->
      parts = data.split '='
      @target = {} unless @target
      @target[parts[0]] = parts[1]

    @inPorts.clear.on 'data', =>
      @target = null

    @inPorts.in.on 'data', (data) =>
      if Object.keys(data).length > 0
        passed = true
        for touch, element of data
          unless @detectTarget element
            passed = false
        if passed
          if @outPorts.target.isAttached()
            @outPorts.target.send data[Object.keys(data)[0]].current
          @outPorts.pass.send data
        else
          @outPorts.fail.send data
        return
      if @detectTarget data[Object.keys(data)[0]]
        if @outPorts.target.isAttached()
          @outPorts.target.send data[Object.keys(data)[0]].current
        @outPorts.pass.send data
      else
        @outPorts.fail.send data
    @inPorts.in.on 'disconnect', =>
      @outPorts.pass.disconnect()
      @outPorts.fail.disconnect()
      if @outPorts.target.isAttached()
        @outPorts.target.disconnect()

  detectTarget: (element) ->
    for key, value of @target
      unless element[key] is value
        return false
    true

exports.getComponent = -> new DetectTarget

{'fraction_non_alphanumeric': 0.11619506321493077, 'fraction_numerical': 0.003612281757977122, 'mean_word_length': 2.29009900990099, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '1053093', 'n_tokens_mistral': 1069, 'n_tokens_neox': 1046, 'n_words': 255}