jbmusso / gremlin-javascript

JavaScript tools for graph processing in Node.js and the browser inspired by the Apache TinkerPop API
MIT License
214 stars 63 forks source link

Examples seem out of date with current execute() argument list #62

Open zedrdave opened 7 years ago

zedrdave commented 7 years ago

After fixing the connection issue, examples still fail with this error:

TypeError: callback is not a function

Looking at the code for node-example.js, execute() is called with:

client.execute(script, function(err, res) {

However, the prototype for execute() is:

execute(script, bindings = {}, message = {}, ...args) {

Where the callback is either taken from args or from message (if message has type function).

I guess this could be fixed by adding an empty dict to the call in the example scripts (so that the callback becomes the 3rd argument) or, more elegantly, by adding a check for bindings as well as message:

   if (typeof message === 'function') {
      callback = message;
      message = {};
    }
    else if (typeof bindings === 'function') {
        callback = bindings;
        bindings = {};
    }

I'll be happy to submit a PR if that helps.