{"size": 565, "ext": "js", "max_stars_repo_path": "src/index.js", "max_stars_repo_name": "Shuumatsu/promise-channel", "max_stars_repo_stars_event_min_datetime": "2019-07-16T03:32:44.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-16T03:32:44.000Z", "max_issues_repo_path": "src/index.js", "max_issues_repo_name": "Shuumatsu/promise-channel", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/index.js", "max_forks_repo_name": "Shuumatsu/promise-channel", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 31.3888888889, "max_line_length": 78, "alphanum_fraction": 0.5716814159}
import { make as internal_make, is_completed, take } from './channel.bs'
export * from './channel.bs'

// Receiving from a channel until it's closed is normally done using for range
// make it async iterator here
export const make = (...args) => {
    const chan = internal_make(...args)
    chan[Symbol.asyncIterator] = () => ({
        next: () => {
            if (!is_completed(chan)) {
                return take(chan).then(value => ({ value, done: false }))
            }
            return Promise.resolve({ done: true })
        }
    })
    return chan
}
