How to use the settle function from when

Find comprehensive JavaScript when.settle code examples handpicked from public code repositorys.

100
101
102
103
104
105
106
107
108
109
    } else {
        callback.call(node);
    }
}
if (promises.length > 0) {
    return when.settle(promises).then(function() {
        if (this._context) {
           return context.delete(this._alias||this.id,this.z);
        }
    });
fork icon14
star icon73
watch icon0

197
198
199
200
201
202
203
204
205
206
describe("uninstalls module", function() {
    it("rejects invalid module names", function(done) {
        var promises = [];
        promises.push(installer.uninstallModule("this_wont_exist "));
        promises.push(installer.uninstallModule("this_wont_exist;no_it_really_wont"));
        when.settle(promises).then(function(results) {
            results[0].state.should.be.eql("rejected");
            results[1].state.should.be.eql("rejected");
            done();
        });
fork icon14
star icon73
watch icon0

208
209
210
211
212
213
214
215
216
217
    } else {
        promises.push(when.resolve(r));
    }
});
var i=0;
when.settle(promises).then(function(res2) {
    var result = {};
    res2.forEach(function(r) {
        // TODO: name||fn
        if (r.value.fn) {
fork icon14
star icon73
watch icon0

60
61
62
63
64
65
66
67
68
69
        }
    } else {
        console.log(">> No default credentials found");
    }
    */
    when.settle(promises).then(function() {
            resolve();
    });
} else {
    resolve();
fork icon11
star icon4
watch icon0

122
123
124
125
126
127
128
129
130
131
132
133
        //     project.paths.credentialsFile = fspath.join(project.path,"flow_cred.json");
        // }


        promises.push(project.loadRemotes());


        return when.settle(promises).then(function(results) {
            return project;
        })
    });
};
fork icon1
star icon3
watch icon0

+ 2 other calls in file

26
27
28
29
30
31
32
33
34
35
36
37


function registerMessageCatalogs(catalogs) {
    var promises = catalogs.map(function(catalog) {
        return registerMessageCatalog(catalog.namespace,catalog.dir,catalog.file);
    });
    return when.settle(promises);
}


function registerMessageCatalog(namespace,dir,file) {
    return when.promise(function(resolve,reject) {
fork icon1
star icon3
watch icon0

26
27
28
29
30
31
32
33
34
35
if (!username || !password) {
    response.status(400).send('please add username and password on your post request');
    return;
}

const [getJsession, getSmsession] = await when.settle([
    axios('https://portalprepagos.cgd.pt/portalprepagos/login.seam', {
        method: 'get'
    }),
    axios('https://portalprepagos.cgd.pt/portalprepagos/auth/forms/login.fcc', {
fork icon0
star icon2
watch icon0

160
161
162
163
164
165
166
167
168
169
 *   roles_users
 */

// Write changes to DB, if successful commit, otherwise rollback
// when.all() does not work as expected, when.settle() does.
when.settle(ops).then(function (descriptors) {
    var rej = false,
        error = '';
    descriptors.forEach(function (d) {
        if (d.state === 'rejected') {
fork icon0
star icon0
watch icon0