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
"use strict" | |
global.autoloadExport = (invoke, deps = []) => { | |
const req = global.require, [file] = deps = deps.map(req.resolve) | |
return arg => { | |
const mod = req(file) | |
deps.forEach(dep => delete req.cache[dep]) | |
return invoke(mod, arg) | |
} | |
} |
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
"use strict" | |
function EventEmitter() { | |
this._events = Object.create(null) | |
} | |
EventEmitter.prototype.on = function (event, func) { | |
var handlers = this._events[event] = this._events[event] || [] | |
if (handlers.indexOf(func) < 0) handlers.push(func) | |
} |
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
"use strict" | |
const Module = require("module") | |
const loaded = new WeakMap() | |
let visited = new WeakSet() | |
const parents = new Set() | |
function removeRecursive(parent, mod) { | |
const index = loaded.get(mod) |
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
// This is careful to avoid memory leaks. Also, it is written in pure | |
// ES5 assuming a Promise polyfill (so it works with transpiled code | |
// without needing transpiled) and the relevant Symbol polyfills. | |
function run(route, render, onError) { | |
"use strict" | |
if (onError == null) onError = function (e) { console.error(e) } | |
function run(next) { | |
var current = next.value | |
if (Array.isArray(current)) current = current[0] |
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
// Adapted from https://github.com/isiahmeadows/thallium/blob/b0bce2d2b7a104f5aa73b1ba0b532bcb78418d48/r/spec.js | |
// Original: no pipeline operators | |
import * as R from "../lib/reporter" | |
import {color as c} from "../lib/reporter" | |
const printIndent = (_, str) => _.print(" ".repeat(_.state.level) + str) | |
const getLast = (report, _, key = "name") => report.path[_.state.level - 1][key] | |
export default R.on("spec", { |
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
// A complete set of type defs for Fantasy Land | |
type unknown = {} | null | undefined; | |
interface Setoid { | |
"fantasy-land/equals"(other: this): boolean; | |
} | |
interface Ord { | |
"fantasy-land/lte"(other: this): boolean; | |
} |
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
type PollResult<T> = | |
| {type: "pending"} | |
| {type: "resolved", value: T} | |
| {type: "rejected", value: Error} | |
| {type: "cancelled"} | |
interface Receiver<T> { | |
resolve?(value: T): any | |
reject?(value: Error): any | |
} |
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
{ | |
"middle": 39.01, | |
"files": [ | |
{ | |
"name": ".html", | |
"content": "\n" | |
}, | |
{ | |
"name": ".js", | |
"content": "// https://github.com/pakx/mithril-hn-basic\nvar settings = {\n apiHost : \"https://node-hnapi.herokuapp.com\"\n , routesDesc : [\n {name:\"news\", pagesMax:15, cacheMax:15, isMenu: true}\n , {name: \"show\", pagesMax: 3, cacheMax:3, isMenu: true}\n , {name: \"ask\", pagesMax: 3, cacheMax:3, isMenu: true}\n , {name: \"jobs\", pagesMax: 1, cacheMax:1, isMenu: true}\n , {name: \"item\", pagesMax: 0, cacheMax:10, isMenu: false}\n , {name: \"user\", pagesMax:0, cacheMax:10, isMenu: false}\n ]\n}\n\n/// Returns idempotent view-function that renders UI per passed-in model\nvar view = (function() {\n\n function view(model, actions) {\n return vwApp(model, actions)\n }\n\n function vwApp(model, actions) {\n return m(\".app\"\n , vwAppHeader(model, actions)\n |
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
// API: | |
// `m(RouteResolver, {onmatch(path), render(Comp)}) -> Component` | |
// | |
// Note: this is all in pure ES5 | |
// | |
// Assumed extensions: | |
// - `m.route.default()` - Get the default route | |
var RouteResolver = { | |
oninit: function (vnode) { |
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
// This wraps the `m.route` API to implement route resolvers | |
// | |
// Note: this is all in pure ES5 | |
// | |
// Assumed extensions: | |
// - `m.route.default()` - Get the default route | |
var route = (function () { | |
"use strict" | |