Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant