UNPKG

random-generator_node-red-contrib

Version:

A package to meet the randomness generation needs of node-red developers

22 lines (21 loc) 584 B
module.exports = function (RED) { const { uniqueNamesGenerator, adjectives, colors, animals, } = require("unique-names-generator"); function nameGenerator(config) { RED.nodes.createNode(this, config); var node = this; node.on("input", function (msg) { nameLength = config.nameLength == "" ? 2 : parseInt(config.nameLength); msg.payload = uniqueNamesGenerator({ dictionaries: [adjectives, colors, animals], length: nameLength, }); node.send(msg); }); } RED.nodes.registerType("Name", nameGenerator); };