Skip to content
This repository was archived by the owner on Oct 8, 2024. It is now read-only.
This repository was archived by the owner on Oct 8, 2024. It is now read-only.

Should take() close the iterator when remaining is 0? #71

@senocular

Description

@senocular

take() returns undefined when remaining is 0 without calling back up to close the iterator. I'd expect iterator to get closed when this happens. For example

function* readLines() {
  try {
    open()
    while(1) yield read()
  } finally {
    close()
  }
}

// manual 
let count = 3
for (let line of readLines()) {
  // use line
  if (--count === 0) break; // closes
}
  
// using take()
for (let line of readLines().take(3)) {
  // use line
}
// not closed
  

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions