You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2019/02/24 07:04:00 UTC

[jira] [Commented] (TINKERPOP-2167) Gremlin Javascript Traversal as async iterable

    [ https://issues.apache.org/jira/browse/TINKERPOP-2167?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16776139#comment-16776139 ] 

ASF GitHub Bot commented on TINKERPOP-2167:
-------------------------------------------

joestrouth1 commented on pull request #1071: TINKERPOP-2167 Traversals as async iterables in gremlin-javascript
URL: https://github.com/apache/tinkerpop/pull/1071
 
 
   https://issues.apache.org/jira/browse/TINKERPOP-2167
   
   Summary of changes:
   - Added `[Symbol.asyncIterator]` member to the Traversal class to support `for await ... of` loops (async iterables)
   
   Change was tested by modifying the latest published version of `gremlin` on npm. Reviewed current tests for `gremlin-javascript` and saw none that might conflict.
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> 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 a {{[Symbol.asyncIterator]}} method to the Traversal class.



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