Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
node.on("input", function(msg) {
if (msg.seed) { dummyjson.seed = msg.seed; }
try {
var value = dummyjson.parse(node.template, {mockdata: msg});
if (node.syntax === "json") {
try { value = JSON.parse(value); }
catch(e) { node.error(RED._("datagen.errors.json-error")); }
}
if (node.fieldType === 'msg') {
RED.util.setMessageProperty(msg,node.field,value);
}
else if (node.fieldType === 'flow') {
node.context().flow.set(node.field,value);
}
else if (node.fieldType === 'global') {
node.context().global.set(node.field,value);
}
node.send(msg);