Operator: processor

A processor modifies the incoming signal and emits it. It does not interact with external world. The process function takes a callback function to emit an error signal or the modified signal.

Signature

NS.processor(comment : string, inputs : map, outputs : map, process : function) : Node

Arguments

Arguement Type Description
comment string optional, the comment of the processor
inputs map optional, the input description
outputs map optional, the output description
process function optional, the process function, it takes a callback function as the second argument, which accepts an error and new signal. If the error argument is not empty, an error signal will be sent, otherwise, the new signal will be sent

processSync function signature:

function process(signal : Signal, done : function) : void

done argument is a callback function with signature:

function done(error : Error, newSignal : Signal) : void

If error argument is not null, an ERROR signal is sent to stream otherwise the new signal is emitted.

Return

Type Description
Node the processor node

Create an async processor

const ns = collar.ns('collarjs.demo.processor')
const proc = ns.processor("double the payload",
  ( signal, done ) => {
    let v = signal.get('value');
    done(null, signal.new({value: v * 2}));
  });

results matching ""

    No results matching ""