UNPKG

lil-http

Version:

Tiny, lightweight, full featured HTTP client

32 lines (29 loc) 619 B
<html> <head> <meta charset="utf-8"> </head> <body> <script src="../thread.js"></script> <script> var worker = thread({ env: { x: 2, defer: function (fn) { setTimeout(fn, 1) } } }) var task = worker.run(function (done) { var sum = env.x * 2 env.defer(function () { done(null, sum) }, 250) }).then(function (value) { console.log('Result:', value) }) task.finally(function (result) { console.log('Finally:', result) }) </script> </body> </html>