This file contains hidden or 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 test = require('mocha').it | |
var assert = require('assert') | |
var request = require('request') | |
var http = require('http') | |
test('request things', function (done) { | |
var PORT = Math.floor(Math.random() * 10000 + 20000) | |
var serv = http.createServer(function (req, res) { | |
if (Math.random() < 0.5) { | |
// throws, `serv.close()` never called |
This file contains hidden or 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 Assert = require('assert-tap2') | |
var run = require('gens2/run') | |
// NO FRAMEWORK. Just node style assert | |
// that outputs TAP. | |
run(function* () { | |
var assert = Assert('a test case') | |
... |
This file contains hidden or 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
function Router(options) { | |
options = options || {} | |
var notFound = options.notFound || defaultNotFound | |
var errorHandler = options.errorHandler || defaultErrorHandler | |
var router = new RoutesRouter() |
This file contains hidden or 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 cache = require('continuable-cache'); | |
var extend = require('xtend/mutable'); | |
function MemoizedServer(createServer) { | |
var createCachedServer = cache(createServer); | |
var started = false; | |
var server = { | |
start: function start(callback) { | |
server.counter++; |
This file contains hidden or 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
function diff(left, right) { | |
if (isThunk(left) && isThunk(right)) { | |
if (thunkType(left) !== thunkType(right)) { | |
pushOntoPatchQueue(right) | |
} | |
var comparator = getComparator(left) || function (a, b) { return a === b } | |
var recurse = !comparator(getArg(left), getArg(right)) | |
pushOntoPatchQueue(diff( |
This file contains hidden or 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 toElement = require("virtual-dom/render") | |
var diff = require("virtual-dom/diff") | |
var patch = require("virtual-dom/patch") | |
var raf = require("raf").polyfill | |
module.exports = main | |
function main(obs, render, elem) { | |
var currTree = render(obs()) | |
var rootNode = toElement(currTree) |
This file contains hidden or 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
function diff(left, right) { | |
if (isThunk(left) && isThunk(right)) { | |
var argsLeft = getArgs(left) | |
var fnLeft = getFn(left) | |
var argsRight = getArgs(right) | |
var fnRight = getFn(right) | |
if (fnLeft !== fnRight) { | |
var tree = fnRight.apply(null, argsRight) | |
var oldTree = getTree(left) |
This file contains hidden or 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
(* | |
A Diffable<T> can be embedded in a VirtualDOMNode | |
When `diff(left, right)` encounters a `Diffable` in | |
`right` it will invoke `right.diffable(left, right)` | |
When doing so `left` could be another `Diffable` or a | |
previous VirtualDOMNode, `Diffable` must handle - | |
both cases. | |
This file contains hidden or 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 counter = 0; | |
var ticks = 0; | |
setImmediate(function countTick() { | |
ticks++ | |
setImmediate(countTick) | |
}) | |
var todo = new ImObject({ |
This file contains hidden or 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 h = require("virtual-dom/h") | |
var extend = require("xtend") | |
var Delegator = require("dom-delegator") | |
var uuid = require("uuid") | |
var event = require("dom-delegator/event") | |
/* example function | |
function render() { | |
return h("div", [ | |
h("span", "Details hello world example"), |
OlderNewer