Operator: map

The synchronous version of processor(). The processSync function does not take a callback function as argument, instead, its returned value is sent as the outgoing signal.


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


Arguement Type Description
comment string optional, the comment of the processor
inputs map optional, the input description
outputs map optional, the output description
processSync function optional, the process function, it throws Error or returns the new signal. If an error is threw, an error signal will be sent, otherwise, the returned signal will be emitted

processSync function signature:

function processSync(signal : Signal) : Signal

If error is threw, an ERROR signal is sent to stream, otherwise the return signal is emitted


Type Description
Node the processor node

Create a sync processor

const ns = collar.ns('collarjs.demo.actuatorSync');
const input = ns.input('input');

  .map("double the value", signal => {
    return signal.set('value', signal.get('value') * 2);
  .do(signal => console.log(s.get('value')));

input.push({value : 3}); // --> 6

results matching ""

    No results matching ""