Hamsters.js also supports the use of promises using a method called hamsters.promise, the traditional method hamsters.run makes use of callbacks. Promises can give you more sequential control of your application.
hamsters.promise
hamsters.run
var params = { array: [1, 2, 3, 4] }; hamsters.promise(params, function() { for(var i = 0; i < params.array; i++) { rtn.data.push(params.array[i] * 4); } }).then(function(results) { console.log(results); }).catch(function(error) { console.error(error); });
This should enable the use of async await as well giving you the power to take the above example and make it even easier.
var params = { array: [1, 2, 3, 4]; }; var results = await hamsters.promise(params, functionToRun);