No Description

worker.js 363B

12345678910111213141516
  1. importScripts('es6-promise.js');
  2. new ES6Promise.Promise(function(resolve, reject) {
  3. self.onmessage = function (e) {
  4. if (e.data === 'ping') {
  5. resolve('pong');
  6. } else {
  7. reject(new Error('wrong message'));
  8. }
  9. };
  10. }).then(function (result) {
  11. self.postMessage(result);
  12. }, function (err){
  13. setTimeout(function () {
  14. throw err;
  15. });
  16. });