I'm investigating substack/shoe example code, especially node stream out out on browser side:
https://github.com/substack/shoe/blob/master/example/invert/client.js
stream.pipe(through(function (msg) {
result.appendChild(document.createTextNode(msg));
this.queue(String(Number(msg)^1));
})).pipe(stream);
I undersand what
result.appendChild(document.createTextNode(msg));
does, but I just can't figure out what
this.queue(String(Number(msg) ^ 1));
does along with
.pipe(stream)
queue and .pipe(stream) back to stream slightly meaningful to me for stream control, but String(Number(msg) ^ 1) is the one I know nothing of. what is ^ 1)??
I'd assume msg can be either "0” or "1”, and "^" here is a JavaScript XOR operator to flip its value, so 0^1 = 1, and 1^1=0.