self._executeCommands([command]) .then(function(cmdResults) { fulfill(cmdResults[0]); // only one will return }).catch(function(error) { self._log('error','Unexepected error in _execute(): ' + error + ' ' + error.stack); reject(error); });
self._pool.drain(function() { self._log('info',"shutting down all" + " pooled ProcessProxies..."); self._pool.destroyAllNow(); fulfill(); });
request.get(meta, function (err, httpResponse, body) { if (err) { reject(err); } else { fulfill({httpResponse: httpResponse, body: body}); } });
// push command to stack self._commandStack.push( new Command(command, function(cmd, stdout, stderr) { cmdResults.push({ 'command': cmd, 'stdout': stdout, 'stderr': stderr }); if (cmdResults.length == commands.length) { fulfill(cmdResults); } }));
http.request(options, function(response) { var body = ''; if (response.statusCode >= 400) { reject(error); return; } response.on('data', function(chunk) { body += chunk; }); response.on('end', function() { fulfill(JSON.parse(body)); }); })
self._statefulProcessCommandProxy.executeCommands(commands) .then(function(cmdResults) { fulfill(cmdResults); }).catch(function(error) { self._log('error','Unexepected error from _statefulProcessCommandProxy.executeCommands(): ' + error + ' ' + error.stack); reject(error); });
_connect() { this._debug("Connecting...") this.afterConnected = new Promise((fulfill, reject) => { this._refreshToken().then(() => { this._refreshWebsocket().then(() => { fulfill() }, reject) }, reject) }) this.afterConnected.done(() => { this.ready = true this.emit('connect') this._stopSelfHeal() if (["iex", "cryptoquote", "fxcm"].includes(this.options.provider)) { this._refreshChannels() } }, () => { this.ready = false this._trySelfHeal() }) return this.afterConnected }
self._executeCommands(commandsToExec) .then(function(cmdResults) { // iterate over them (the order will match the order of the cmdName2ArgValuesList) // modify each cmdResult adding the commandName attribute for (var i=0; i<cmdResults.length; i++) { var cmdResult = cmdResults[i]; var cmdRequest = cmdName2ArgValuesList[i]; cmdResult['commandName'] = cmdRequest.commandName; } fulfill(cmdResults); }).catch(function(error) { self._log('error','Unexepected error in executeAll(): ' + error + ' ' + error.stack); reject(error); });
request.post(meta, function (err, httpResponse, body) { if (err) { reject(err); } else { fulfill({httpResponse: httpResponse, body: body}); } });
self._execute(command) .then(function(cmdResult) { // tack on commandName cmdResult['commandName'] = commandName; fulfill(cmdResult); }).catch(function(error){ reject(error); });
new Promise(function (fulfill, reject){ request(options, function(error, response, body) { // return body if (error){ reject(error); } else if(!body.status){ // Error from API?? error = body; body = null; reject(error); } else{ fulfill(body); } }); }).then(function(value) { if(callback) { return callback(null, value); } return value; }).catch(function(reason) { if(callback) { return callback(reason, null); } return reason; })
self._executeCommands(shutdownCommands,false) // skip black/whitelists .then(function(cmdResults) { self._destroySelf(); fulfill(cmdResults); // invoke when done! }).catch(function(exception) { self._log('error',"shutdown - shutdownCommands, " + " exception thrown: " + exception); self._destroySelf(); reject(exception); });
self._executeCommands(initCommands,false) // skip black/whitelists .then(function(cmdResults) { // init auto invalidation self._initAutoInvalidation(); fulfill(cmdResults); // invoke when done! }).catch(function(exception) { self._log('error',"initialize - initCommands, " + "exception thrown: " + exception); this._isValid = false; // set ourself int invalid reject(exception); });
self.executeCommands([command]) .then(function(cmdResults) { fulfill(cmdResults[0]); }).catch(function(error) { reject(error); });