X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=node_modules%2Fphridge%2Flib%2FdisposeAll.js;fp=node_modules%2Fphridge%2Flib%2FdisposeAll.js;h=30325d06d61887c8b4f2592b450e98c323160b9e;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/node_modules/phridge/lib/disposeAll.js b/node_modules/phridge/lib/disposeAll.js new file mode 100644 index 000000000..30325d06d --- /dev/null +++ b/node_modules/phridge/lib/disposeAll.js @@ -0,0 +1,26 @@ +"use strict"; + +var instances = require("./instances.js"); + +/** + * Terminates all running PhantomJS processes. Returns a Promises/A+ compliant promise + * which resolves when a processes terminated cleanly. + * + * @returns {Promise} + */ +function disposeAll() { + var copy = instances.slice(0); // copy the array because phantom.dispose() will modify it + + return Promise.all(copy.map(exit)); +} + +/** + * @private + * @param {Phantom} phantom + * @returns {Promise} + */ +function exit(phantom) { + return phantom.dispose(); +} + +module.exports = disposeAll;