[ 
https://issues.apache.org/jira/browse/TINKERPOP-2167?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

stephen mallette updated TINKERPOP-2167:
----------------------------------------
    Labels:   (was: pull-request-available)

> Gremlin Javascript Traversal as async iterable
> ----------------------------------------------
>
>                 Key: TINKERPOP-2167
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2167
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: javascript
>    Affects Versions: 3.4.0
>         Environment: Node v10.15.0
>            Reporter: Joe Strouth
>            Priority: Minor
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> Traversals in Gremlin javascript are async iterators, as they implement a 
> {{next()}} method that returns a Promise, which resolves to an object with 
> {{value}} and {{done}} properties. It would be helpful if they were also 
> async iterables - traversable via {{for await ... of}} loops.
> {code:javascript}
> (async function() {
>   for await (const continent of g.V().hasLabel('continent').values('desc')) {
>     console.log(continent)
>   }
> })()
> {code}
> Expected output:
> {noformat}
> > Africa
> Antarctica
> North America
> Asia
> Oceania
> Europe
> South America
> {noformat}
> Current output: (Node v10.15.0)
> {noformat}
> > (node:14698) UnhandledPromiseRejectionWarning: TypeError: 
> > g.V(...).hasLabel(...).values(...) is not a function or its return value is 
> > not async iterable
>     at repl:1:78
>     at repl:1:122
>     at Script.runInThisContext (vm.js:96:20)
>     at REPLServer.defaultEval (repl.js:332:29)
>     at bound (domain.js:395:14)
>     at REPLServer.runBound [as eval] (domain.js:408:12)
>     at REPLServer.onLine (repl.js:639:10)
>     at REPLServer.emit (events.js:187:15)
>     at REPLServer.EventEmitter.emit (domain.js:441:20)
>     at REPLServer.Interface._onLine (readline.js:290:10)
> (node:14698) UnhandledPromiseRejectionWarning: Unhandled promise rejection. 
> This error originated either by throwing inside of an async function without 
> a catch block, or by rejecting a promise which was not handled with .catch(). 
> (rejection id: 1)
> (node:14698) [DEP0018] DeprecationWarning: Unhandled promise rejections are 
> deprecated. In the future, promise rejections that are not handled will 
> terminate the Node.js process with a non-zero exit code.
> {noformat}
> This can be achieved by adding {{[Symbol.asyncIterator]}} to the Traversal 
> class.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to