Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Proper way to get Q via Chrome #776

Open
adjavaherian opened this issue Apr 21, 2016 · 0 comments
Open

Question: Proper way to get Q via Chrome #776

adjavaherian opened this issue Apr 21, 2016 · 0 comments

Comments

@adjavaherian
Copy link

What's the proper way to get a Q from this CDN version of this library? This example works in the browser, but it looks like the delay doesn't? https://jsfiddle.net/dzzas97p/6/
Its funny, because the equivalent works as expected in Node

// async_series.js
// example of using reduce and promises and closure to create async results in series

var q = require('Q');
var results = [1, 2, 3, 4, 5];

function workCollection(arr) {

    return arr.reduce(function(promise, item, index) {
        return promise.delay(1000).then(function(result) {
            console.log('item', item, 'result', result, 'index', index);
            return true;
        });
    }, q(true));

}

    q()
        .then(function(){
            console.log('start');
            return results
        })
        .then(workCollection)
        .then(function(){
            console.log('done');
        }, function(err){
            console.error(err);
        });

Perhaps my fiddle implementation is not equivalent?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant