Signal represents collection of values (over time) associated with a single identity. It can be expressed as follows:
function signal(next) {
next(1)
next(2)
next(3)| // A pull stream is a function readable(closing, cb<err, chunk>) | |
| // To extract a chunk out of the stream simply call (null, cb) | |
| // to get another value call it again. | |
| // The stream will tell you if it's ended by invoking cb(true) | |
| // The stream will tell you if it errored by invoking cb(Error) | |
| // You can tell the stream to close / destroy by calling stream(true, cb) | |
| var stream = (function () { | |
| var list = [1, 2, 3, 4] | |
| return function stream(closing, callback) { |
| // Load the TCP Library | |
| net = require('net'); | |
| // Keep track of the chat clients | |
| var clients = []; | |
| // Start a TCP Server | |
| net.createServer(function (socket) { | |
| // Identify this client |
| var task = require("monk") | |
| var shell = require("monk-shell") | |
| var buildTask = task("build", function (rule) { | |
| rule("hello.c", "hello.o", | |
| shell("gcc -Wall -c %i -o %o")) | |
| rule("square.c", "square.o", | |
| shell("gcc -Wall -c %i -o %o")) | |
| // don't pass monk in as an argument, just require it | |
| var monk = require("monk") | |
| var rule = require("monk/rule") | |
| var less = require("monk-less"); | |
| var compress = require("monk-compress") | |
| // don't exports.x = bar | |
| // just create functions. | |
| function build() { | |
| // don't have magic glob or mapFile. Just have sensible defaults |
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:
| var hash = require('observ-hash') | |
| var array = require('observ-array') | |
| var observ = require('observ') | |
| var dom = React.DOM; | |
| var App = React.createClass({ | |
| getInitialState: function() { | |
| // create observable immutable data structure | |
| var state = hash({ |
| var cuid = require("cuid") | |
| var dom = require("./render") | |
| var diff = require("./diff") | |
| var patch = require("./patch") | |
| var isString = require("./lib/is-string") | |
| /* Usage | |
| var thunk = require("virtual-dom/thunk") |
| var mercury = require("mercury") | |
| var h = mercury.h | |
| var state = mercury.hash({}) | |
| function render(state) { | |
| return h("ul", [ | |
| h('li', h('a', { href: '#foo' }, 'link without array')), | |
| h('li', [ h('a', { href: '#bar' }, 'link with array') ]) | |
| ]) |
| var people = varhash({}, function setPerson (obj, key), { | |
| return struct({ | |
| id: key, | |
| name: value(obj.name) | |
| }) | |
| }) | |
| var teams = varhash({}, function setTeam (obj, key) { | |
| return struct({ | |
| id: key, |