/** * basic usage of bluebird */ var Promise = require("bluebird"); //defining an async function var clAsync = function () { var P = new Promise(function (resolve, reject) { console.log('Write from function'); resolve('ok'); reject('not ok'); }); /* { "isFulfilled": true, "isRejected": false, "fulfillmentValue": "ok" } */ console.log(JSON.stringify(P, null, 2)); return P; }; console.log(JSON.stringify(clAsync, null, 2)); //undefined //executing promisified function clAsync() and adding new callback with then method clAsync() .then(function (returnedVal) { console.log('THEN 1 - fulfillmentValue= ' + returnedVal); return {one: 1, two: 'drugi'}; //returning to next then }) .then(function (returnedVal) { console.logs('THEN 2 - fulfillmentValue= ' + returnedVal.one + returnedVal.two); // return new Error('Namjerna greška'); --doesn't work throw new Error('Namjerna greška', 'someFile.js', 152); }) //catch type errors .catch(TypeError, function (e) { console.error(e.stack); // console.error(e.message); }) //catch all other errors .catch(function (e) { console.error(e.message); // console.error(e.stack); });
$ps -aux | grep node (list all node processes) sasa 849 0.5 0.5 1319424 88004 ? Ssl Oct08 283:30 node /home/sasa/regoch/regoch-www/server sasa 880 0.4 0.5 1319240 87604 ? Ssl Oct08 235:57 node /home/sasa/dex8/dex8-www/server/index.js sasa 890 0.5 0.5 11797800 85024 ? Ssl Oct08 334:48 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js sasa 903 0.7 0.5 1329652 82344 ? Ssl Oct08 431:27 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js sasa 929 0.4 0.4 1300184 69188 ? Ssl Oct08 226:30 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js sasa 943 0.4 0.4 1300808 66620 ? Ssl Oct08 233:36 node /home/sasa/dex8/dex8-kiosk/server/index.js sasa 980 0.6 0.4 11795444 81860 ? Ssl Oct08 365:03 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js sasa 981 0.7 0.6 1148036 103788 ? Ssl Oct08 395:26 node /home/sasa/voovuu/voovuu-api/starter.js sasa 1039 0.9 1.4 11945524 245476 ? Ssl Oct08 555:31 node /home/sasa/voovuu/voovuu-pub/server/index.js sasa 2044488 0.3 0.4 1298112 66524 ? Ssl Nov01 77:36 node /home/sasa/dex8/dex8-panel/server/index.js sasa 2574087 0.3 0.4 11792920 77508 ? Ssl Nov08 42:13 node /home/sasa/@mikosoft/dodo-examples/server/index.js sasa 2702010 0.4 0.6 22296696 100132 ? Ssl Nov10 35:23 node /home/sasa/dex8/dex8-worker/starter.js sasa 2702011 0.3 0.4 1100276 66912 ? Ssl Nov10 31:30 node /home/sasa/dex8/dex8-worker/starter.js sasa 2702018 0.3 0.4 1100140 65996 ? Ssl Nov10 31:33 node /home/sasa/dex8/dex8-worker/starter.js sasa 2702019 0.3 0.4 1100516 67320 ? Ssl Nov10 31:31 node /home/sasa/dex8/dex8-worker/starter.js sasa 2702046 0.9 0.7 22311780 124336 ? Ssl Nov10 84:38 node /home/sasa/dex8/dex8-worker/starter.js sasa 2702047 0.3 0.4 1100516 66272 ? Ssl Nov10 31:49 node /home/sasa/dex8/dex8-worker/starter.js sasa 2702088 0.3 0.4 1100264 65996 ? Ssl Nov10 31:33 node /home/sasa/dex8/dex8-worker/starter.js sasa 2702089 0.3 0.4 1100520 66960 ? Ssl Nov10 31:30 node /home/sasa/dex8/dex8-worker/starter.js sasa 2702137 0.3 0.4 1099864 66048 ? Ssl Nov10 31:20 node /home/sasa/dex8/dex8-worker/starter.js sasa 2702139 0.4 0.6 22297196 101612 ? Ssl Nov10 35:54 node /home/sasa/dex8/dex8-worker/starter.js sasa 3097623 1.1 0.8 11716736 131204 ? Ssl Nov13 44:33 node /home/sasa/dex8/dex8-api/starter.js www-data 3369925 0.0 0.0 2608 604 ? S 09:41 0:00 sh -c ps -aux | grep node www-data 3369927 0.0 0.0 3304 732 ? S 09:41 0:00 grep node