How to use the resolve function from bluebird
Find comprehensive JavaScript bluebird.resolve code examples handpicked from public code repositorys.
GitHub: labulakalia/ibm_bak
192 193 194 195 196 197 198 199 200
##### 清单 9\. 异步 Promise 链式调用 ``` function redis_setget_string_async() { var promise = redis.setAsync('key', ['string']).then(function(res) { return redis.getAsync('key'); //返回 Promise }).then(function(res) { console.log(res); //打印'string' Q.resolve(res); //返回 Promise }); return promise; } ```
166
336
10
+ 5 other calls in file
GitHub: MarkBind/markbind
145 146 147 148 149 150 151 152 153 154
const addHandler = (filePath) => { logger.info(`[${new Date().toLocaleTimeString()}] Reload for file add: ${filePath}`); if (onePagePath) { syncOpenedPages(); } Promise.resolve('').then(async () => { if (site.isFilepathAPage(filePath) || site.isDependencyOfPage(filePath)) { return site.rebuildSourceFiles(filePath); } return site.buildAsset(filePath);
105
95
13
+ 32 other calls in file
11 12 13 14 15 16 17 18 19 20
const makePool_ = ({ limit = 1, isSpecificBrowserLimiter = true } = {}) => new LimitedPool(underlyingPool, { limit, isSpecificBrowserLimiter }); beforeEach(() => { underlyingPool = { getBrowser: sinon.stub().callsFake(id => Promise.resolve(stubBrowser(id))), freeBrowser: sinon.stub().returns(Promise.resolve()), cancel: sinon.stub(), }; });
56
555
11
+ 15 other calls in file
19 20 21 22 23 24 25 26 27 28
_callCommand(command, injectAllowed) { return this._browser .evalScript(command) .then(result => { if (!result || !result.isClientScriptNotInjected) { return Promise.resolve(result); } if (injectAllowed) { return this._inject().then(() => this._callCommand(command, false));
56
555
11
+ 11 other calls in file
GitHub: gemini-testing/hermione
15 16 17 18 19 20 21 22 23 24
const callsFakeLoadFiles_ = ({ cb = () => {}, tests = ["default-test"] } = {}) => { TestParser.prototype.loadFiles.reset(); TestParser.prototype.loadFiles.callsFake(async function () { await cb.call(this); this._tests = tests; return Promise.resolve(this); }); }; const readTests_ = ({ opts, config, reader } = {}) => {
56
555
11
+ 21 other calls in file
13 14 15 16 17 18 19 20 21 22
{limit, isSpecificBrowserLimiter} ); beforeEach(() => { underlyingPool = { getBrowser: sinon.stub().callsFake((id) => Promise.resolve(stubBrowser(id))), freeBrowser: sinon.stub().returns(Promise.resolve()), cancel: sinon.stub() }; });
56
556
11
+ 15 other calls in file
GitHub: Nexus-Mods/vortex-games
368 369 370 371 372 373 374 375 376 377 378
// add oculus as a game store and we need to launch the game through // the store - this here needs to change. return findGame() .then(steamPath => (steamPath.toLowerCase() === gamePath.toLowerCase()) ? Promise.resolve({ launcher: 'steam', addInfo: '629730' }) : Promise.resolve(undefined)) .catch(() => Promise.resolve(undefined)); } function main(context) {
46
28
7
+ 153 other calls in file
GitHub: terascope/teraslice
228 229 230 231 232 233 234 235 236 237
// no results which is not always an error if (isWildCardRegexSearch !== null) { logger.warn( `Running a regex or cross cluster search for ${config.index}, there is no reliable way to verify index and max_result_window` ); return Promise.resolve(true); } return client.indices .getSettings({})
13
48
10
+ 101 other calls in file
130 131 132 133 134 135 136 137 138 139
if (commandOptions.fail) { throw new errors.CommandExecutionError(command, commandOptions.code, commandOptions.stdout, commandOptions.stderr); } return Bluebird.resolve(commandOptions.code || 0); } else { if (_this.mockOptions.throwIfMockNotDefined) { throw new Error('Mock for "' + command + '" not defined');
8
6
2
GitHub: mbroadst/thinkagain
177 178 179 180 181 182 183 184 185 186
* Create the model's table. * @return {Promise=} Returns a promise which will resolve when the table is ready. */ tableReady() { let model = this._getModel(); if (!this._initModel) return Promise.resolve(); if (this._tableReadyPromise) return this._tableReadyPromise; // Create the table, or push the table name in the queue. let r = model._thinkagain.r;
4
30
4
35 36 37 38 39 40 41 42 43 44
'properties.survey': surveyId }).cancellable(); var boundsPromise = Promise.promisify(Response.getBounds, Response)(surveyId).cancellable(); Promise.resolve(Survey.findOne({ id: surveyId }).lean().exec()) .then(function (survey) { if (!survey) { // Cancel the count and bounds promises. countPromise.cancel();
14
20
4
115 116 117 118 119 120 121 122 123 124
ports.push(i); log('Trying to find open ports between range %s and %s', options.min, options.max); var promise = bluebird.resolve(ports) .each(function(port) { return that.test(port, iface) .then(function(open) { if (options.retrieve && result.length >= options.retrieve) {
8
76
1
54 55 56 57 58 59 60 61 62
else if (_.isObject(myRequests)) { var keys = _.keys(myRequests); return Promise.settle(wrapped).then(function(settledValues) { var resolved = _.zipObject(keys, getSettledValues(settledValues)); return Promise.resolve(resolved); }); } };
5
56
1
GitHub: TruenoDB/trueno
1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852
Promise.prototype._isBound = function () { return (this._bitField & 2097152) === 2097152; }; Promise.bind = function (thisArg, value) { return Promise.resolve(value).bind(thisArg); }; }; },{}],4:[function(_dereq_,module,exports){
3
16
0
+ 4 other calls in file
GitHub: owljsorg/owljs
119 120 121 122 123 124 125 126 127 128 129
}); }); } function ensureDirectory(dir, isUsed, clean) { return (clean ? rimraf(dir) : Promise.resolve()).then(function() { if (!isUsed) return dir; return mkdirp(dir).thenReturn(dir); }); }
7
9
0
GitHub: bvschwartz/nock-step
5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513
var ret = new Promise(INTERNAL); setTimeout(function() { ret._fulfill(); }, ms); return ret; } ms = +ms; return Promise.resolve(value)._then(afterValue, null, null, ms, undefined); }; Promise.prototype.delay = function (ms) { return delay(this, ms);
2
11
0
+ 7 other calls in file
358 359 360 361 362 363 364 365 366 367
*/ authorized(request, sessionState) { if (sessionState.authenticated) { request.username = sessionState.username; request.ssoToken = request.cookies[TOKEN_NAME]; return Promise.resolve({ authenticated: true, authorized: true }); } else { return Promise.resolve({ authenticated: false, authorized: false }); } }
32
5
0
+ 3 other calls in file
452 453 454 455 456 457 458 459 460 461
apiManagement(webApp) { const r = express.Router(); r.post('/plugins', jsonParser, function api(req, res) { const pluginDef = req.body; //TODO rewrite to EvenEmitter Promise.resolve().then(() => webApp.options.newPluginHandler(pluginDef)) .then(() => { res.status(200).send('plugin added'); }, (err) => { res.status(400).send('ZWED0059W - failed to add the plugin: ' + err.message);
32
5
0
+ 2 other calls in file
GitHub: owljsorg/owljs
491 492 493 494 495 496 497 498 499 500
var task = payload.task; var code = task.code; var context = task.context; var id = payload.id; var promise = payload.isolated ? waitForPreviousOutput(id) : Promise.resolve(); return promise .then(function() {
7
9
4
119 120 121 122 123 124 125 126 127 128
if (proxyStr) { options["proxy"] = proxyStr; } options = this.getOptions(options); return new Promise(function (resolve, reject) { var _promise = Promise.resolve(options); if (_this.authProvider) { _promise = _this.authProvider.preCall(options); } _promise.then(function (opt) {
5
6
3
+ 45 other calls in file
bluebird.reject is the most popular function in bluebird (2988 examples)