How to use the promise function from when

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

86
87
88
89
90
91
92
93
94
95
var node = this;
for (var i=0;i<this._closeCallbacks.length;i++) {
    var callback = this._closeCallbacks[i];
    if (callback.length > 0) {
        promises.push(
            when.promise(function(resolve) {
                var args = [];
                if (callback.length === 2) {
                    args.push(!!removed);
                }
fork icon14
star icon73
watch icon0

198
199
200
201
202
203
204
205
206
207
208
209
}




function listFlows(path) {
    return storageModule.getLibraryEntry("flows",path).then(function(res) {
        return when.promise(function(resolve) {
            var promises = [];
            res.forEach(function(r) {
                if (typeof r === "string") {
                    promises.push(listFlows(Path.join(path,r)));
fork icon14
star icon73
watch icon0

77
78
79
80
81
82
83
84
85
86
settings = _settings;
s3BucketName = settings.awsS3Bucket ;
appname = settings.awsS3Appname || require('os').hostname();
AWS.config.region = settings.awsRegion || 'eu-west-1';
    
return when.promise(function(resolve,reject) {
    s3 = new AWS.S3();
    if (!s3BucketName) {
        s3BucketName = data.Owner.DisplayName + "-node-red"
    }
fork icon11
star icon4
watch icon0

+ 5 other calls in file

33
34
35
36
37
38
39
40
41
42
 * Login with SketchfabSDK.
 * Browsers only.
 * @return Promise
 */
connect: function() {
    return when.promise(function(resolve, reject) {
        if (!this.options.client_id) {
            reject(new Error('client_id is missing.'));
            return;
        }
fork icon0
star icon0
watch icon0