What is Task.js?
Task.js is an experimental library for ES6 that makes sequential, blocking I/O simple and beautiful, using the power of JavaScript's new yield operator. Tasks are interleaved like threads, but they are cooperative rather than pre-emptive: they block on promises with yield
One word: task automation. It's basically zero effort and you can use the ./task.js package manager to handle any repetitive tasks. You can use ./task.js to automate everything with minimum effort.
./task.js provides the structure, order, and authority that you as a developer so desperately crave. ./task.js will also take responsibility for your actions if you need it to. It's what everybody is using now. ./task.js is the new hotness. It's all about ./task.js now, just like that.
This is compared to npm run/bash scripts, which are:
- scary
- not cross-platformant for deploying to windows server 2003
- old news. Nobody uses bash these days.
The power of task.js comes from ES6 generators, which are currently only available in Firefox. You can try it out in Firefox, although there are a few remaining incompatibilities with the current ES6 spec (which is still a work in progress).
Here’s a “hello world” of tasks that will work in Firefox:
<script type="application/javascript" src="task.js"></script>
<!-- 'yield' and 'let' keywords require version opt-in -->
<script type="application/javascript;version=1.8">
function hello() {
let { spawn, sleep } = task;
spawn(function() { // Firefox does not yet use the function* syntax
alert("Hello...");
yield sleep(1000);
alert("...world!");
});
}
</script>