How to use the kew.all function in kew

To help you get started, we’ve selected a few kew examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Medium / zcache / test / test_MultiplexingCache.js View on Github external
builder.add(function testConcurrentGetWithSet(test) {
  fake.setSync('abc', 'donkey')

  var p1 = cache.get('abc')
  var p2 = cache.get('abc')
  cache.set('abc', 'elephant')
  var p3 = cache.get('abc')

  return Q.all([p1, p2, p3]).then(function (results) {
    test.equal(results[0], 'donkey')
    test.equal(results[1], 'donkey')
    test.equal(results[2], 'elephant')
    test.equal(fake.getRequestCounts().mget, 2, 'Two requests should be made to delegate')
    test.equal(fake.getRequestCounts().get, 0, 'get() really calls mget()')
  })
})
github Medium / shepherd / test / types.js View on Github external
.builds('object-object')
      .run()
      .then(test.ok.bind(test, "Object is a valid object"))
  )

  promises.push(
    this.graph
      .add('object-array', this.graph.literal([]))
      .newBuilder()
      .builds('object-array')
      .run()
      .then(test.fail.bind(test, "Array is not a valid object"))
      .fail(test.ok.bind(test, "Array is not a valid object"))
  )

  return Q.all(promises)
})
github volumio / Volumio2 / app / plugins / music_services / dirble / index.js View on Github external
}
	};

	var id = uri.split('/')[2];


	var paginationPromises = [];

	for (var i = 0; i < 1; i++) {
		var dirbleDefer = libQ.defer();
		self.getRadioForCategory(id, 30, i, dirbleDefer.makeNodeResolver());

		paginationPromises.push(dirbleDefer);
	}

	libQ.all(paginationPromises)
		.then(function (results) {
			//console.log(results);
			for (var j in results) {
				var pageData = results[j];
				//console.log(pageData);

				for (var k in pageData) {
					var category = {
						service: 'dirble',
						type: 'webradio',
						title: pageData[k].name,
						id: pageData[k].id,
						artist: '',
						album: '',
						icon: 'fa fa-microphone',
						uri: pageData[k].streams[0].stream
github petkaantonov / bluebird / benchmark / doxbee-sequential / promises-obvious-kew.js View on Github external
module.exports = function upload(stream, idOrPath, tag, done) {
    var blob = blobManager.create(account);
    var tx = db.begin();
    var blobIdP = blob.put(stream); 
    var fileP = self.byUuidOrPath(idOrPath).get();
    var version, fileId, file;
    q.all([blobIdP, fileP]).then(function(all) {        
        var blobId = all[0], fileV = all[1];
        file = fileV;
        var previousId = file ? file.version : null;
        version = {
            userAccountId: userAccount.id,
            date: new Date(),
            blobId: blobId,
            creatorId: userAccount.id,
            previousId: previousId,
        };
        version.id = Version.createHash(version);
        return Version.insert(version).execWithin(tx);
    }).then(function() {
        if (!file) {
            var splitPath = idOrPath.split('/');
            var fileName = splitPath[splitPath.length - 1];
github volumio / Volumio2 / app / pluginmanager.js View on Github external
/*
	each plugin's onVolumioShutdown() is launched following plugins.json order.
	Note: there is no resolution strategy: each plugin completes
	at it's own pace, and in whatever order.
	Should completion order matter, a new promise strategy should be
	implemented below (chain by start order, or else...)
*/

	self.corePlugins.forEach(function (value, key) {
		if (self.isEnabled(value.category, value.name)) {
			var plugin_defer = self.onVolumioShutdownPlugin(value.category,value.name);
			defer_onShutdownList.push(plugin_defer);
		}
	});

	return  libQ.all(defer_onShutdownList);
};
github Medium / shepherd / lib / Graph.js View on Github external
Graph.prototype.ready = function () {
  this._state.isReady = true
  var promises = []
  while (this._config.readyHandlers.length) {
    var fn = this._config.readyHandlers.shift()
    var result = fn()
    if (result) {
      promises.push(result)
    }
  }
  return Q.all(promises)
}
github volumio / Volumio2 / app / index.js View on Github external
var self=this;
    var methodDefer=libQ.defer();
    var defers=[];


	try {
		fs.readJsonSync(dictionaryFile);
	} catch(e) {
		dictionaryFile = defaultDictionaryFile;
	}

    defers.push(libQ.nfcall(fs.readJson,dictionaryFile));
    defers.push(libQ.nfcall(fs.readJson,defaultDictionaryFile));
    defers.push(libQ.nfcall(fs.readJson,jsonFile));

    libQ.all(defers).
            then(function(documents)
    {

        var dictionary=documents[0];
        var defaultDictionary=documents[1];
        var jsonFile=documents[2];

        self.translateKeys(jsonFile,dictionary,defaultDictionary);

        methodDefer.resolve(jsonFile);
    })
    .fail(function(err){
        self.logger.info("ERROR LOADING JSON "+err);

        methodDefer.reject(new Error());
    });
github volumio / Volumio2 / app / plugins / music_service / mpd / nativeImplementation.js View on Github external
title: title,
                            artist: artist,
                            album: album,
                            uri: 'music-library/' + path,
                            albumart : self.getAlbumArt({artist: artist, album: album}, self.getParentFolder('/mnt/' + path),'fa-tags')
                        });
                    }
                }
                deferArray[2].resolve(subList);
            }
            else if(err)  deferArray[2].reject(new Error('Song:' +err));
            else deferArray[2].resolve();
        });
    });

    libQ.all(deferArray).then(function(values){

        var list = [];

        if(values[0])
        {
            var artistdesc = self.commandRouter.getI18nString('COMMON.ARTIST');
            if (artistcount > 1) artistdesc = self.commandRouter.getI18nString('COMMON.ARTISTS');
            list=[
                {
                    "title": self.commandRouter.getI18nString('COMMON.FOUND') + " " + artistcount + " " + artistdesc + " '" + query.value +"'",
                    "availableListViews": [
                        "list",
                        "grid"
                    ],
                    "items": []
                }];
github volumio / Volumio2 / app / pluginmanager.js View on Github external
/*
    each plugin's onVolumioStart() is launched by priority order.
	Note: there is no resolution strategy: each plugin completes
	at it's own pace, and in whatever order.
	Should completion order matter, a new promise strategy should be
	implemented below (chain by boot-priority order, or else...)
*/
	priority_array.forEach(function(plugin_array) {
		if (plugin_array != undefined) {
			plugin_array.forEach(function(folder) {
				defer_loadList.push(self.loadCorePlugin(folder));
			});
		}
	});

	return libQ.all(defer_loadList);
};
github volumio / Volumio2 / app / index.js View on Github external
CoreCommandRouter.prototype.broadcastMessage = function (emit,payload) {
	var self = this;
	return libQ.all(
		libFast.map(this.pluginManager.getPluginNames('user_interface'), function (sInterface) {
			var thisInterface = self.pluginManager.getPlugin('user_interface', sInterface);
			if (typeof thisInterface.broadcastMessage === "function")
				return thisInterface.broadcastMessage(emit,payload);
		})
	);
};

kew

a lightweight promise library for node

Apache-2.0
Latest version published 9 years ago

Package Health Score

59 / 100
Full package analysis