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
/* | |
concatMap takes an iter and returns one. | |
It takes a mapper of (value, push, done) | |
You may call `push` zero or more times with a value. | |
You must call `done` with either `Error` or `null` | |
You may not call `push` after `done` |
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
(* | |
next(cb). | |
- Calls cb(Error) if error | |
- Calls cb(null, value) if value | |
- Calls cb(null, undefined) if finished | |
end(cb) | |
- Aborts the underlying stream | |
- calls cb() once cleaned up | |
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 bundle = require('./bundle.js') | |
bundle('whatever/code/you/want.js', function (err, module) { | |
/* do shit, hooray */ | |
}) |
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 setInterval = require('timers').setInterval; | |
setInterval(function () { | |
var handles = process._getActiveHandles(); | |
console.log('no of handles', handles.length); | |
handles.forEach(function (obj) { | |
if ('ontimeout' in obj) { | |
console.log('timer handle', obj); | |
} else if ('readable' in obj && 'writable' in obj) { |
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
interface Car { | |
run(fuel: string); | |
} | |
interface Human { | |
run(distance: number); | |
} | |
// Makes the specified object go | |
// run := (Car, string) | |
// run := (Human, number) |
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 foo(opts: {host: string, port: number }) { | |
var host = opts.host; // string | |
var port = opts.port; // number | |
} |
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 mercury = require('mercury'); | |
var h = mercury.h; | |
var PopOver = (function () { | |
var offset = require('offset'); | |
PopOverFn.render = popoverRender; | |
function PopOverFn() { | |
var events = mercury.input(['toggle']); |
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 setTimeout = require('timers').setTimeout; | |
var work = 0; | |
console.log('version: ' + process.version); | |
if (typeof gc === 'undefined') { | |
throw new Error('run node foo.js --expose-gc'); | |
} |
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 Observ = require('observ'); | |
/* flatMap := (Observ<T>, (T) => Observ<S>) => Observ<S> | |
*/ | |
function flatMap(observ, fn) { | |
var v = fn(observ()); | |
var result = Observ(v()); | |
v(result.set); |
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 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, |