This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mosca = require("mosca"); | |
var mqtt = require("mqtt"); | |
function promiseMosca(){ | |
var moscaOpts = { | |
http:{ | |
port:3000, | |
static:false, | |
bundle:false | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var chai = require("chai"), | |
chaiAsPromised = require("chai-as-promised"), | |
selenium = require("selenium-standalone"), | |
wd = require("wd"), | |
Q=require("q"); | |
chai.use(chaiAsPromised); | |
chai.should(); | |
chaiAsPromised.transferPromiseness = wd.transferPromiseness; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Kefir = require("kefir"), | |
asap = require("asap"); | |
function cacheStream(source){ | |
var eventCache = null; | |
var sink = Kefir.stream(function(emitter){ | |
var handler = function(event){ | |
if(event.type==="value"){ | |
eventCache = event; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _ = require("lodash"); | |
/** A draft approach to substituting Kefir streams with a bespoke library, suitable as a means of replacing the chained filters by withHandler calls. | |
* Benefits: more lightweight, (not cloning a stream for every operation), more debuggable (inspectable through the stack). | |
* */ | |
function Listenable(){ | |
this.listeners = {}; | |
this.active = false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Of course, these can't really be called tests, but they indicate the syntax which successfully produces console | |
//output validating the various referenced functions | |
it("Can create a stream", function(){ | |
var stream = makeStream(); | |
}); | |
it("Can log a stream", function(){ | |
var stream = makeStream(); | |
stream.log("Original"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Kefir = require("kefir"); | |
var period = 1000; | |
//var wait = 2 * period; //success condition | |
var wait = 0.5 * period; //failure condition | |
function promiseNextBefore(stream, timeout){ | |
return new Promise(function(resolve, reject){ | |
function handler(event){ | |
if(event.type==="value"){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var child_process = require("child_process"), | |
spawn = child_process.spawn, | |
mqtt = require("mqtt"), | |
mosca = require("mosca"); | |
//uses the callback convention of calling 'done()' with | |
// callback with no argument for success | |
// callback with an argument for error | |
// no callback if nothing to report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var albumBinder = | |
pivot("album", ".album", | |
pivot("*", ".song", | |
pivot("verses/*", ".verse", | |
pivot("*", ".line", function(topic, control){ | |
return screenplay.bindLeaf(tree, topic, control); | |
}) | |
) | |
) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="browserified/track_template.js"></script> | |
</head> | |
<body> | |
<section class="template"> | |
<ul class="album"> | |
<li class="song"> | |
<h1>Song Title</h1> | |
<ul class="verse"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var albumSource = { | |
hello:{ | |
chorus:[ | |
"Hello, I love you", | |
"Won't you tell me your name?", | |
"Hello, I love you", | |
"Let me jump in your game", | |
], | |
verses:[ | |
[ |