How to use the node-opcua-utils.getFunctionParameterNames function in node-opcua-utils

To help you get started, we’ve selected a few node-opcua-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-opcua / node-opcua / packages / node-opcua-client / src / client_session.js View on Github external
const self = this;

    if (!callback) {
        callback = maxAge;
        maxAge = 0;
    }
    const isArray = _.isArray(nodesToRead);
    if (!isArray) {
        nodesToRead = [nodesToRead];
    }
    assert(_.isArray(nodesToRead));
    assert(_.isFunction(callback));

    if (helpAPIChange) {
        // the read method deprecation detection and warning
        if (!(getFunctionParameterNames(callback)[1] === "dataValues" || getFunctionParameterNames(callback)[1] === "dataValue")) {
            console.log("ERROR ClientSession#read  API has changed !!, please fix the client code".red);
            console.log("   replace ..:".red);
            console.log("   session.read(nodesToRead,function(err,nodesToRead,results) {}".cyan);
            console.log("   with .... :".red);
            console.log("   session.read(nodesToRead,function(err,dataValues) {}".cyan);
            console.log("");
            console.log("please make sure to refactor your code and check that he second argument of your callback function is named".yellow,("dataValue" + (isArray?"s":"")).cyan);
            console.log("to make this exception disappear".yellow);
            throw new Error("ERROR ClientSession#read  API has changed !!, please fix the client code");
        }
    }

    // coerce nodeIds
    for (const node of nodesToRead) {
        node.nodeId = resolveNodeId(node.nodeId);
    }