forked from openiap/opencore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtil.ts
More file actions
22 lines (21 loc) · 827 Bytes
/
Copy pathUtil.ts
File metadata and controls
22 lines (21 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import * as RED from "node-red";
export class Util {
public static EvaluateNodeProperty<T>(node: any, msg: any, name: string, ignoreerrors: boolean = false) {
return new Promise<T>((resolve, reject) => {
const _name = node.config[name];
let _type = node.config[name + "type"];
if (_name == null) return resolve(null);
// if (_type == null) _type = "msg";
RED.util.evaluateNodeProperty(_name, _type, node, msg, (err, value) => {
if (err && !ignoreerrors) {
reject(err);
} else {
resolve(value);
}
})
});
}
public static SetMessageProperty(msg: any, name: string, value: any) {
RED.util.setMessageProperty(msg, name, value);
}
}