<commit_before>noflo = require 'noflo'

class CreateCanvas extends noflo.Component
  description: 'Makes a Canvas with given dimensions'
  icon: 'pencil-square'
  constructor: ->
    @width = null
    @height = null

    @inPorts = new noflo.InPorts
      width:
        datatype: "int"
      height:
        datatype: "int"
    @outPorts = new noflo.OutPorts
      canvas:
        datatype: 'object'

    @inPorts.width.on 'data', (data) =>
      @width = data
      @create()

    @inPorts.height.on 'data', (data) =>
      @height = data
      @create()

  create: =>
    return unless @width>0 and @height>0
    canvas = document.createElement 'canvas'
    canvas.width = @width
    canvas.height = @height
    canvas.id = 'createdCanvas'
    unless document.getElementById canvas.id
      document.body.appendChild canvas

    if @outPorts.canvas.isAttached()
      @outPorts.canvas.send canvas

exports.getComponent = -> new CreateCanvas<commit_msg>we can use dom/AppendChild instead<commit_after>noflo = require 'noflo'

class CreateCanvas extends noflo.Component
  description: 'Makes a Canvas with given dimensions'
  icon: 'pencil-square'
  constructor: ->
    @width = null
    @height = null

    @inPorts = new noflo.InPorts
      width:
        datatype: "int"
      height:
        datatype: "int"
    @outPorts = new noflo.OutPorts
      canvas:
        datatype: 'object'

    @inPorts.width.on 'data', (data) =>
      @width = data
      @create()

    @inPorts.height.on 'data', (data) =>
      @height = data
      @create()

  create: =>
    return unless @width>0 and @height>0
    canvas = document.createElement 'canvas'
    canvas.width = @width
    canvas.height = @height

    if @outPorts.canvas.isAttached()
      @outPorts.canvas.send canvas

exports.getComponent = -> new CreateCanvas
{'fraction_non_alphanumeric': 0.11294765840220386, 'fraction_numerical': 0.0022038567493112946, 'mean_word_length': 2.653923541247485, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '3687967', 'n_tokens_mistral': 589, 'n_tokens_neox': 570, 'n_words': 146}