Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-1684

Define [Symbol.iterator] on our Cursor objects

    • Type: Icon: New Feature New Feature
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.2.0
    • Affects Version/s: None
    • Component/s: Core, Native
    • Labels:
      None

      Starting in Node 10.3, you can have async for...of loops

      async function() {
        for await (const item of interable) {
        }
      }
      

      and in Node 8, we could still use an iterator to return promises to for...of

       
      async function foo() {
        for (const _item of iterable) {
          const item = await _item;
        }
      }
      

      It would be a good idea to add a Symbol.iterator method to our cursors to allow them to be used in for...of loops

            Assignee:
            daniel.aprahamian@mongodb.com Daniel Aprahamian (Inactive)
            Reporter:
            daniel.aprahamian@mongodb.com Daniel Aprahamian (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: