包详细信息

node-red-contrib-noderedbase

peter.prib181GPL-3.00.0.16

Node-RED base javascript for common code

node-red, base extensions, javascript

自述文件

node-red-contrib-prib-noderedBase

Base module of functions when developing own nodes in Node-Red

Description

Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.


Usage

    const noderedBase=require("noderedBase");
    RED.nodes.createNode(this,n);
    const node=Object.assign(this,n);
    node._base=new noderedBase(RED,node);
    try{
        this._base.setSource("key").setTarget("target")
    } catch(ex) {
        node._base.error(ex,"Invalid setup "+ex.message);
        return;
    }
    node.on("input",function (msg) {
        try{
            const key=node.getKey(msg);
            node.setTarget(key,msg);
            node.send(msg);
        } catch(ex) {
            msg.error=ex.message;
            node.send([null,msg]);
    });

Installation

Run the following command in the root directory of your Node-RED install

npm install node-red-contrib-noderedbase

Tests

Test/example flow in test/generalTest.json


Version

0.0.1 initial base


Author

Peter Prib