Component from noflo-calc

noflo = require "noflo"
mathjs = require "mathjs"

This component evaluates mathematical expressions received on the IN port and sends the output to the OUT port.

           |                            |----OUT---->
----IN---->| SimpleExpressionCalculator |
           |                            |---ERROR--->
class SimpleExpressionCalculator extends noflo.Component
  constructor: ->
    @inPorts =

IN in port receives text of an expression to be evaluated. You can see examples of expressions on the MathJS web site

      in: new noflo.Port()
    @outPorts =

OUT out port sends the value calculated from the expression received on the IN port.

      out: new noflo.Port()

ERROR out port sends any error messages from parsing the expression received on the IN port.

      error: new noflo.Port() "data", (expression) =>
        @outPorts.out.send mathjs.eval(expression)
      catch e
        @outPorts.error.send expression: expression, message: e.message

Cascade the group and disconnection behaviour of the in port. "begingroup", (group) =>
      @outPorts.error.beginGroup(group) "endgroup", =>
      @outPorts.error.endGroup() "disconnect", =>

exports.getComponent = -> new SimpleExpressionCalculator()