1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge pull request #4227 from node-red/4196-add-callback-opt-to-env.get

Adds optional callback to env.get in function node
This commit is contained in:
Nick O'Leary 2023-06-21 15:55:40 +01:00 committed by GitHub
commit b382d048de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -281,4 +281,21 @@ declare class env {
* ```const flowName = env.get("NR_FLOW_NAME");```
*/
static get(name:string) :any;
/**
* Get an environment variable value (asynchronous).
*
* Predefined node-red variables...
* * `NR_NODE_ID` - the ID of the node
* * `NR_NODE_NAME` - the Name of the node
* * `NR_NODE_PATH` - the Path of the node
* * `NR_GROUP_ID` - the ID of the containing group
* * `NR_GROUP_NAME` - the Name of the containing group
* * `NR_FLOW_ID` - the ID of the flow the node is on
* * `NR_FLOW_NAME` - the Name of the flow the node is on
* @param name Name of the environment variable to get
* @param callback Callback function (`(err,value) => {}`)
* @example
* ```const flowName = env.get("NR_FLOW_NAME");```
*/
static get(name:string, callback: Function) :void;
}

View File

@ -235,8 +235,8 @@ module.exports = function(RED) {
}
},
env: {
get: function(envVar) {
return RED.util.getSetting(node, envVar);
get: function(envVar, callback) {
return RED.util.getSetting(node, envVar, node._flow, callback);
}
},
setTimeout: function () {