You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by "jorgebay (GitHub)" <gi...@apache.org> on 2019/02/25 08:37:11 UTC

[GitHub] [tinkerpop] jorgebay commented on issue #1071: TINKERPOP-2167 Traversals as async iterables in gremlin-javascript

Thanks for your contribution @joestrouth1 ! Its a good idea to expose a `Symbol.asyncIterator` method.

We must support Node.js 6 and 8 runtimes, that don't expose `Symbol.asyncIterator`.
You can fix it by define it conditionally:

```javascript
const asyncIteratorSymbol = Symbol.asyncIterator || Symbol('@@asyncIterator');

// ...
  [asyncIteratorSymbol]() {
    // This wont work for Node.js 6 and 8, but at least the method will be exposed
    // under symbol name
    return this;
  }
```

Also, it would be nice it we could add a [unit test](https://github.com/apache/tinkerpop/blob/master/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js) validating that `Symbol.asyncIterator` is defined for a `Traversal` instance:

```javascript
if (Symbol.asyncIterator) {
  describe('@@iterator', () => {
    it('should expose the async iterator');
  });
}
```

[ Full content available at: https://github.com/apache/tinkerpop/pull/1071 ]
This message was relayed via gitbox.apache.org for dev@tinkerpop.apache.org