{"size": 977, "ext": "js", "max_stars_repo_path": "lab/yield.js", "max_stars_repo_name": "WeAreBreak/inq-core", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lab/yield.js", "max_issues_repo_name": "WeAreBreak/inq-core", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lab/yield.js", "max_forks_repo_name": "WeAreBreak/inq-core", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 18.4339622642, "max_line_length": 66, "alphanum_fraction": 0.4851586489}
/**
 * Created by schwarzkopfb on 14/10/16.
 */

const N = +process.argv.slice(2)[0]

require('../lib/inq')

var start, data = { text: 'awaited and then returned. yay!' }

function now(label) {
    var stamp = 0

    if(start)
        stamp = (+new Date - start)
    else
        start = +new Date

    console.log(':' + label, stamp)
}

function test(value, callback) {
    setTimeout(callback.bind(0, null, value), 500)
}

$(
    function* () {
        now('start')

        switch(N) {
            case 1:
            default:
                return (yield test.$(data)).text

            case 2:
                return yield test.$(data)

            case 3:
                yield test.$(data)
                return 'haha, text is lost but awaited!'

            case 4:
                return test.$(data) // nothing was awaited for! :(
        }
    },

    function done(err, res) {
        now('done')

        console.log(err || res)
        console.log('OK')
    }
)